Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Get Workflow Name programmatically
-
I am trying to edit some parameters of workflows with python code. i've got the path where the workflows are stored but i don't know how to find the specified workflow because filenames are different than the name given via workflow editor Example: C420F7E7-BB5B-481B-8053-1289FE4E404E.wkflw
how to find the "correct" workflow name?
-
The mapping of workflow titles to filenames is stored in a JSON file called
Commands.edcmd
.Here's a snippet of Python code to print titles and filenames for all workflows:
import editor import os import json with open(os.path.join(editor.get_workflows_path(), 'Commands.edcmd')) as f: wf_infos = json.load(f) for wf in wf_infos: print wf['filename'] + ' -- ' + wf['title']
Note that if you want to modify this file (be careful with that!), you have to call
editor.reload_workflows()
afterwards. -
Oh, Thanks :-)
ok, i will be careful :-) -
I'm not so pratic with json module :-(
i want to edit the customTitle of this workflow:
{"actions":[{"class":"WorkflowActionStoreVariable","pauseBeforeRunning":true,"customTitle":"Lorem Ipsum","parameters":{"name":"variabile","value":{"tokenRanges":{},"type":"advancedText","text":"Some Text"}},"pauseWithoutShowingParameters":false}]}
How to do that?
-
Workflow (
.wkflw
) files are also in JSON format, and it's relatively easy to modify them using thejson
module, if you know your way around lists and dicts.import json workflow_filename = 'someworkflow.wkflw' # change this # Read the workflow data: with open(workflow_filename, 'r') as f: workflow_dict = json.load(f) # Modify it: actions = workflow_dict['actions'] first_action = actions[0] first_action['customTitle'] = 'Foo Bar' # Save the modified workflow data: with open(workflow_filename, 'w') as f: json.dump(workflow_dict)
This will set the custom title of the first action in the workflow to "Foo Bar".
(Note: this won't work if the workflow you're modifying is currently open in the workflow editor)
-
Oh so simply :-)
excuse me, i don't know the json module very well😔 ,but Thanks :-) -
Ok,my work is almost done.
Anyway i'd make a page on documentation with more details on the workflow system -
I'd quite like a workflow that lists my current workflows and creates an Evernote note based on this list. Probably as a table.
The words "quite like" mean it's not likely to bubble up to the top of my fun Development list soon. :-( :-)
-
Really useful info in this thread.
Not sure how I'd use it yet, but some kind of conditional workflow chaining is the first thing that springs to mind.
-
I'd like to know if @omz considers the file formats we're talking about as being stable. If so one could build tooling in other places that might prove useful.
-
I'd like to know if @omz considers the file formats we're talking about as being stable. If so one could build tooling in other places that might prove useful.
It's not very likely that I'll make backwards-incompatible changes, though I'll obviously add things as the workflow system evolves (new action and parameter types etc.).
I'd say the format is relatively easy to understand when you pretty-print the JSON, but I don't really plan to document it properly. The workflow editor isn't really prepared for malformed data, and it's quite possible that you'll see crashes or weird behavior when you change a
.wkflw
file in ways that wouldn't be possible in the UI.If you want to play with "meta" workflows, I'd really recommend making a backup of your workflows first. You can do this with my Backup workflow, which incidentally also demonstrates a practical use case of
editor.reload_workflows
. -
Thanks. That's pretty much what I thought the deal was. I don't, as it happens, have an idea for tooling. I was just very happy this is JSON-based.
-
i was thinking on a self-variable editing workflow
i want to add some things on a list but not with a text file.modifying the variables. So funny :-D anyway i won't publish the workflow -
Modifying the workflow that is currently running won't work. It's loaded from the
.wkflw
file when it's started, but afterwards it's in memory, and won't touch the file again while it's running. -
If one workflow could kick off another then it could kick off a new instance of itself.
-
Is it possible for one workflow to kick off a new instance of itself (or indeed a different workflow)?
-
Would that indeed reload from the .wkflw ?
-
-
@ole it works if the file is not opened in the editor :-)
-
if you start the workflow without editing it it will work
-
Got a sample, @filippocld?
-
Ok...there it is!
http://editorial-app.appspot.com/workflow/5903508918239232/qfH12Las3wo
but,please don't publish the workflow -
.