luckman212 Posted February 15, 2022 Share Posted February 15, 2022 (edited) Hi, Alfred 4.6.3 [1285] macOS 12.2.1 I'm working on a Python workflow and am making use of the rerun parameter. So far so good. BUT, sometimes depending on the workflow inputs or outputs, I do NOT want it to rerun. I've tried the following variations, but using None or False results in the workflow never displaying any output (even though the JSON looks correct in the debug console) a) json.dump(dict(rerun=False, items=items, sys.stdout, indent=2) b) json.dump(dict(rerun=None, items=items, sys.stdout, indent=2) c) json.dump(dict(rerun=0, items=items, sys.stdout, indent=2) The only flavor that "works" is rerun=0, although that results in an orange WARNING from Alfred that WARNING: Foo[Script Filter] Script rerun of 0.00 is out of range (0.1s to 5s), rerun will be ignored —so that seems like a bad solution. I realize I could make some extra code paths in my script to account for these edge cases when I don't want the rerun to happen, but I'd love it if I could just keep it DRY and use the same json.dump() for everything. Is this a bug or a feature request? Edited February 15, 2022 by luckman212 Link to comment
luckman212 Posted February 16, 2022 Author Share Posted February 16, 2022 For now I ended up using a small helper function, this allows passing rt=None,False,0 etc... without causing an issue def json_out(d, rt=None): d_out = dict(items=d) if isinstance(rt, (float,int)): if 0.1 < rt <= 5.0: d_out["rerun"] = rt else: print(f'rerun ({rt}) is OUT OF RANGE 0.1-5.0', file=sys.stderr) json.dump(d_out, sys.stdout, indent=2) Link to comment
deanishe Posted February 17, 2022 Share Posted February 17, 2022 Don’t set rerun if there’s no value. rerun = None ... ... if rerun: feedback['rerun'] = rerun ... ... 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