Jump to content

Python workflow first steps


Recommended Posts

So I'm following this tutorial to make my first python workflow.

Right now I only want to type a keyword, invoke a python script, and get anything in the Alfred results.

So I have created my workflow, created an input script filter with /bin/bash code

python my_file.py

In my_file.py (which is in the workflow directory) I have this

# encoding: utf-8

import sys
from workflow import Workflow, ICON_WEB, web

def main(wf):
    wf.add_item(title = 'something')
    wf.send_feedback()

(I have indented the code with spaces)
 

Then I write my keyword on Alfred but I get nothing, just the default search options.

Is there something very obvious I'm missing?

Edit: I forgot to say that I downloaded the latest workflow module from deanishe and copied it in my workflow folder too

Edited by pier
Link to comment

Hi pier, it looks like you've created your function but haven't actually called it as part of your script.

 

You may wish to add the below to the bottom of your script.

if __name__ == '__main__':
    wf = Workflow()
    log = wf.logger
    sys.exit(wf.run(main))

Also, you might not know that Alfred has a debug tool which is really handy to check what is/isn't working in your code. If you click the debug icon in the top right corner of your Workflow, you get a neat popout which gives you the same thing you'd expect in Terminal or cmd. Let us know how you get on :)

Edited by dsfcraig
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...