villi Posted June 8 Share Posted June 8 I'm new to making workflows using python scripts. I am trying to set som variables inside a python file that runs through the the "run scripts" block. However I can't get it to work, and I don't know what I'm doing wrong. import sys import re import json query = sys.argv[1] data = { "alfredworkflow": { "arg": "", "config": { }, "variables": { "a": "test" } } } json.dump(data, sys.stdout) The python file outputs isn't able to parse the JSON, and instead just outputs it as a string: "{"alfredworkflow": {"arg": "", "config": {}, "variables": {"a": "test"}}}". And when I use {var:a} in a notification block, it's empty. [16:32:12.639] Notion quick add[Keyword] Processing complete [16:32:12.640] Notion quick add[Keyword] Passing output 'input' to Run Script [16:32:12.695] Notion quick add[Run Script] Processing complete [16:32:12.714] Notion quick add[Run Script] Passing output '{"alfredworkflow": {"arg": "", "config": {}, "variables": {"a": "test"}}}input ' to Post Notification Link to comment
giovanni Posted June 8 Share Posted June 8 that last input part doesn't seem valid JSON.... where is input supposed to be? Link to comment
vitor Posted June 9 Share Posted June 9 Welcome @villi, You have unnecessary code your snippet. Unless input is supposed to come into play. But if it is, as @giovanni noted it’s not clear what it’s supposed to refer to. With the given information, this should work: import sys import json data = { "alfredworkflow": { "variables": { "a": "test" } } } json.dump(data, sys.stdout) villi 1 Link to comment
villi Posted June 9 Author Share Posted June 9 9 hours ago, vitor said: Welcome @villi, You have unnecessary code your snippet. Unless input is supposed to come into play. But if it is, as @giovanni noted it’s not clear what it’s supposed to refer to. With the given information, this should work: import sys import json data = { "alfredworkflow": { "variables": { "a": "test" } } } json.dump(data, sys.stdout) @vitor Thanks! Don't know what the difference between your code and mine was, but it somehow works now! 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