Kim Aldis Posted May 9, 2018 Share Posted May 9, 2018 I have a script filter node that isn't behaving as I'd expect - see image attached. I have it's output connected to a post notification. What I'm thinking should happen is: 1. type 'jjj' <return> 2. type some argument <return> 3. the workflow runs and the argument I typed should appear in the post notification. What actually happens is that at step 2, when I try to type an argument the jjj workflow disappears and I see a list of google, amazon and Wikipedia searches. what am I missing? Link to comment
GuiB Posted May 10, 2018 Share Posted May 10, 2018 The workflow disappear has Alfred didn't see a JSON format string (or XML) as the output of your Script Filter. If you don't want to output JSON/XML than it would be better with a simple Keyword object connected to a Run Script object. Then you will be able to do what you want (but you shouldn't press <enter> on your step 1, but more: 'jjj' <space>). If you want to do it with a Script Filter, just replace your script with: import sys, json query = sys.argv[1] data = { 'items' : [{ 'title': 'goto collection', 'subtitle': query, 'arg': query, }] } sys.stdout.write(json.dumps(data)) Link to comment
deanishe Posted May 10, 2018 Share Posted May 10, 2018 17 hours ago, GuiB said: sys.stdout.write(json.dumps(data)) That can be shortened to json.dump(data, sys.stdout). GuiB 1 Link to comment
GuiB Posted May 12, 2018 Share Posted May 12, 2018 On 5/10/2018 at 6:18 PM, deanishe said: That can be shortened to json.dump(data, sys.stdout). Thanks @deanishe, it's always great to have tips to have better code and get better! Thanks for your help! deanishe 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now