Jump to content

Alleyoop: Update Alfred Workflows


Recommended Posts

Posted (edited)

Note from Andrew: While this is a convenient method for updating workflows, I cannot endorse the use of it unless you are fully aware of the security implications of blanket updating all of your workflows. I'm currently working on a built in workflow auto-updater, for a future Alfred 2 release, that performs the standard verification checks that Alfred currently does on manual import, along with migrating your hotkey/keyword settings on upgrading. I'll also be adding 3rd party workflow developer signatures to keep you safe.

 

Hey all,

I've just completed a workflow designed to make it easier for workflow developers to push updates to their work. (And to their flows.) It's called Alleyoop, it's based very heavily on the concept behind David's old extension updater, and it works a little something like this:

  1. When you enter the query oop, it searches through the workflow folders for files named update.json. update.json indicates what version of the workflow is currently installed and where to check for an update. (The format is below.)
  2. Alleyoop downloads a remote json file, indicated in update.json, and if that file indicates a higher version, it downloads the workflow at the address given by the remote file.
  3. The user finds the workflow in his or her ~/Downloads directory and opens it.
  4. There is no step 4.

Workflow developers can start implementing this workflow immediately. All you need is a static place to host a json file and an alfredworkflow file—so Github will do, failing all else, but Droplr won't. Place an update.json file in your workflow, with the following keys defined:

 

{
    "version": 1.0,
    "remote_json": "http://alfred.daniel.sh/Updates/Things.json"
}

 

version should be a float, meaning that 1.0 and 1.1 and 3.14159 are all valid, but 3.1.4 is not, and remote_json should point to a json file on a remote server that's defined like this:

{
    "version": 1.5,
    "download_url": "http://alfred.daniel.sh/Workflows/Things.alfredworkflow",
    "description": "Brief description of the update."
}

 

If the version on the remote server is greater than the version on the user's computer, s/he'll see something like this:

alley_screen.jpg

 

Selecting a workflow from the list will download it. No fuss, no muss.

 

And that's it! Enjoy implementing this, until we get a good package manager running again, and let me know if you run into any difficulties.

 

Download Here

Edited by phyllisstein
Posted

Thank you. Nice idea and let's hope, many of our dev's will implement this!

Posted

I've made a minor change to the workflow, and to the remote JSON template—hopefully the last, barring any compelling feature requests. If developers could include a key named description in the remote file that—well—describes what the update changes, that'd be terrific. The user workflow will expect that key, and skip your update if it—or any of the other expected JSON data—is absent. With the update description, the workflow now looks like this:

 

alley_2.jpg

Posted (edited)

Very nice! I’ll start to make some tests.

 

If there is a way it would be nice to open the forum topic as well (e.g. hitting an action modifier key).

 

 

Question: the workflow download link can be shortened (e.g. with bitly)?

Edited by Carlos-Sz
Posted

Good Idea. 

 

 

I begin to add to my workflow too.  I encountered the following error message.

Jaemok-ui-Mac-Pro:user.workflow.3070F65C-8B64-42DB-BD0F-B69A2EB95612 jmjeong$ python feedback.py
Traceback (most recent call last):
  File "feedback.py", line 107, in <module>
    do_feedback()
  File "feedback.py", line 32, in do_feedback
    local = json.load(f, encoding="utf-8")
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 278, in load
    **kw)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 339, in loads
    return cls(encoding=encoding, **kw).decode(s)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 366, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 382, in raw_decode
    obj, end = self.scan_once(s, idx)
ValueError: Expecting , delimiter: line 4 column 5 (char 163)
 
Posted

Very nice! I’ll start to make some tests.

 

If there is a way it would be nice to open the forum topic as well (e.g. hitting an action modifier key).

 

 

Question: the workflow download link can be shortened (e.g. with bitly)?

No, the link should be a URL that points directly to a .alfredworkflow file. Otherwise the data pulled will be form bitly's redirect page, not the file itself. I'll look into adding a modifier key that opens the workflow's website (as defined in Alfred), which could theoretically point to the forum.

 

 

Good Idea. 

 

 

I begin to add to my workflow too.  I encountered the following error message.

Jaemok-ui-Mac-Pro:user.workflow.3070F65C-8B64-42DB-BD0F-B69A2EB95612 jmjeong$ python feedback.py
Traceback (most recent call last):
  File "feedback.py", line 107, in <module>
    do_feedback()
  File "feedback.py", line 32, in do_feedback
    local = json.load(f, encoding="utf-8")
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 278, in load
    **kw)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 339, in loads
    return cls(encoding=encoding, **kw).decode(s)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 366, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 382, in raw_decode
    obj, end = self.scan_once(s, idx)
ValueError: Expecting , delimiter: line 4 column 5 (char 163)
 

This means that you're missing a comma in your JSON. Look more carefully at the syntax that's given in the first post: keys and values are separated with colons, key-value pairs are separated with commas.

Posted

No, the link should be a URL that points directly to a .alfredworkflow file. Otherwise the data pulled will be form bitly's redirect page, not the file itself. I'll look into adding a modifier key that opens the workflow's website (as defined in Alfred), which could theoretically point to the forum.

 

Before your reply I made a test with a bitly shortened URL and it worked.

 

The interesting thing is that my hotkeys were not reseted after the updating.

 

So far so good.

Posted

Before your reply I made a test with a bitly shortened URL and it worked.

 

The interesting thing is that my hotkeys were not reseted after the updating.

 

So far so good.

 

Oh, neat; that's a freebie.

 

Thanks for all the positive feedback, y'all. If you want to send me lists of your workflows that support this, I'll add them to the first post and my Alfred site.

Posted

Hey, when trying to run the workflow, it's getting stuck here, with nothing further happening:

screenshot20130329at100.png

Interestingly, it seems to be exactly the same problem as I had earlier today with this workflow, which was also Python-based, and it also traversed the Alfred workflow folder, so it's quite possibly same issue. Maybe take a look at how he fixed it?

 

(Or is just because it's not finding any workflow with update info? :unsure: In which case, it should probably show "No updates found" or something, right?)

Posted

Hey, when trying to run the workflow, it's getting stuck here, with nothing further happening:

screenshot20130329at100.png

Interestingly, it seems to be exactly the same problem as I had earlier today with this workflow, which was also Python-based, and it also traversed the Alfred workflow folder, so it's quite possibly same issue. Maybe take a look at how he fixed it?

 

(Or is just because it's not finding any workflow with update info? :unsure: In which case, it should probably show "No updates found" or something, right?)

Could you do the standard thing where you change the script filter command to python feedback.py {query} 2>&1 | tee feedback.log for me and see if the log yields any clues? It does indeed say that there's nothing to update when there's nothing to update—or at least it ought to.

Posted

Could you do the standard thing where you change the script filter command to python feedback.py {query} 2>&1 | tee feedback.log for me and see if the log yields any clues? It does indeed say that there's nothing to update when there's nothing to update—or at least it ought to.

 

Righto. Here you go:

Traceback (most recent call last):
  File "feedback.py", line 96, in <module>
    do_feedback()
  File "feedback.py", line 33, in do_feedback
    remote_uri = local["remote_json"]
KeyError: 'remote_json'

Hope that helps. ;)

Posted

Thanks, it does indeed. What that means is that you've created an "update.json" file somewhere in one of your workflow folders, but haven't set the key "remote_json," which is required. I believe the updated version currently at the link above should, instead of crashing there, quietly ignore the bad data and move on.

Posted

Thanks, it does indeed. What that means is that you've created an "update.json" file somewhere in one of your workflow folders, but haven't set the key "remote_json," which is required. I believe the updated version currently at the link above should, instead of crashing there, quietly ignore the bad data and move on.

Hmm, pretty sure I hadn't actually created an "update.json" file yet. But whatever, it works now. Cheers. :)

 

One question regarding setup for workflows: I like to put the version number in the filename (makes it way easier to keep track of IMHO), so I'm assuming this will still be okay, as long as the static "remote.json" is updated with the new filename at the same time as I update the version no.?

{
    "version": 1.5,
    "download_uri": "http://webhost.com/Workflows/MyWorkflowv1.5.alfredworkflow",
    "description": "Points to a new file now. Okay?"
}
Posted

Hmm, pretty sure I hadn't actually created an "update.json" file yet. But whatever, it works now. Cheers. :)

 

One question regarding setup for workflows: I like to put the version number in the filename (makes it way easier to keep track of IMHO), so I'm assuming this will still be okay, as long as the static "remote.json" is updated with the new filename at the same time as I update the version no.?

{
    "version": 1.5,
    "download_uri": "http://webhost.com/Workflows/MyWorkflowv1.5.alfredworkflow",
    "description": "Points to a new file now. Okay?"
}

 

Huh. That's awfully strange. I'll have to poke around a bit more.

 

Changing the value for "download_uri" with each new version should be fine. Nothing is cached on the user's computer, so it'll grab the new one each time it tries to update.

Posted

That is awesome, will include it into mine asap. One neat thing would be to have another command "ooplist" or so, to see which workflows are oop-enabled.

Thanks! I've updated the original workflow so that entering "oop?" will list all compatible workflows. I've also made it compatible with itself, after a fashion: you should now be able to download updates to Alleyoop from within Alleyoop, but they'll show up in your Downloads folder and have to be installed manually, since the script's files can't be overwritten while the script is running.

Posted

Thanks! I've updated the original workflow so that entering "oop?" will list all compatible workflows. I've also made it compatible with itself, after a fashion: you should now be able to download updates to Alleyoop from within Alleyoop, but they'll show up in your Downloads folder and have to be installed manually, since the script's files can't be overwritten while the script is running.

 

Great featue. I was about to ask for something like this.

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...