I'm having a difficulty with using Alfred to filter script results
I have a python script that queries an internal wiki
#!/usr/bin/env python
from __future__ import print_function
import sys
from workflow.workflow3 import Workflow3
from workflow import web
QUERY_URL = 'http://MYCOMPANY.ORG/mediawiki/api.php?action=opensearch&format=json&search={}&namespace=0&limit=50&suggest='
PAGE_URL = 'https://MYCOMPANY.ORG/mediawiki/index.php?search={}&title=Special%3ASearch'
def main(wf):
Workflow3().logger.info(wf.args[0])
Workflow3().logger.info("HI")
query = str(wf.args[0]).replace(' ', '%20')
results = web.get(QUERY_URL.format(query)).json()
for keyword in results[1]:
url = PAGE_URL.format(keyword.replace(' ', '+'))
wf.add_item(keyword, '', arg=url, copytext=url, icon='logo.png', valid=True)
wf.send_feedback()
if __name__ == '__main__':
wf = Workflow3()
sys.exit(wf.run(main))
I have this in a script filter and if I run with bash and use the command:
python wiki.py $1
Everything works fine.
If i select "Alfred filter results"
I get the following error
Is there something different in the way the script is being called if i have the Alfred filter results button pressed?
I'm assuming the query parameter is perhaps passed differently? Any insight?