spuder Posted December 25, 2013 Share Posted December 25, 2013 (edited) I've completed a python script to query the puppet forge api. http://projects.puppetlabs.com/projects/module-site/wiki/Server-api When I call the python script from the command line, it successfully returns all puppet modules desired $ python myscript.py foo When I place the same python script into an alfred workflow, and set it to require 1 argument, alfred 'gives up' the search before I've fully entered what I am looking for. Anyone have any ideas why Alfred doesn't wait for me to enter the entire string before searching? Here is a video showing the problem *Update* My code is now on github https://github.com/spuder/alfred-puppet-forge It turns out that if I wait long enough, the script does eventually return. The problem is that alfred is calling the script every time a new letter is entered. Searching the api gets faster each letter that is entered For example: a = 1000 results ab = 100 results abc = 3 results abcd = 1 result So In practice, I have to wait for the results of a, ab, abc, before I can get the results of abcd. This is a 10 to 30 second delay for the data I am querying, which is far too long. How can I make alfred wait until I have finished entering abcd before executing? Edited December 25, 2013 by spuder Link to comment
vitor Posted December 25, 2013 Share Posted December 25, 2013 Anyone have any ideas why Alfred doesn’t wait for me to enter the entire string before searching? (…) It turns out that if I wait long enough, the script does eventually return. The problem is that alfred is calling the script every time a new letter is entered. That is a feature, not a bug, it was meant to work like this (not saying I like it). So In practice, I have to wait for the results of a, ab, abc, before I can get the results of abcd. This is a 10 to 30 second delay for the data I am querying, which is far too long. No, you do not. If Alfred did not yet get the response from a query and you enter something else, it’ll wait for that one, it does not “trample” itself. I’ll rephrase the question. How can I make alfred wait until I have finished entering abcd before executing? There’s not a good way to achieve this, currently, although there is a discussion somewhere on the forums on this very issue (do not recall which subforum, exactly). Link to comment
spuder Posted December 25, 2013 Author Share Posted December 25, 2013 (edited) Thanks for the information @Vitor. This 'feature' is great when a websites api is fully developed (youtube, github, ect..) It is a pain trying to use the puppet forge api because searching for 1 letter returns too many results. As a work around I've made my script exit if the argument is less than 4 characters. https://github.com/spuder/alfred-puppet-forge/blob/master/test/forge.py if len(args[1]) <4: sys.exit("module name must have at least 3 characters") https://ask.puppetlabs.com/question/4557/limit-results-from-forge-api/ It looks like this might be the best I can do until alfred allows me to block partial word searches, or the puppet forge API allows limits on the number of results. I'm open to any other ideas. Edited December 25, 2013 by spuder Link to comment
vitor Posted December 25, 2013 Share Posted December 25, 2013 I'm open to any other ideas. The idea on the other thread I’ve mentioned (found it) was to delay the script’s execution for 100ms. Link to comment
abbood Posted February 14, 2017 Share Posted February 14, 2017 @spuder i checked your github repo today.. your script don't work.. it exhibits the exact same problem as you described in your original post 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