Jump to content

"Run script" not working for workflow


Recommended Posts

Hi there -

 

I'm not sure this is the right place for this, since I'm not 100% certain it's a bug in Alfred itself (could be the Ruby framework I'm using, but it doesn't seem like it).  Anyway, hopefully someone can point me in the right direction.

 

I have written a workflow with the Ruby Alfred workflow framework here.  The workflow uses a Script Filter to generate a list of objects from my home automation device, which I can then action to perform commands against.  The problem is that sometimes the workflow doesn't seem to trigger the "Run Script" action.

 

I've verified this by watching the Alfred workflow debug output:

[INFO: alfred.workflow.input.scriptfilter] <items><item autocomplete='Stereo - Volume Up 5:' valid='yes'><title>Stereo - Volume Up 5</title><arg>Stereo - Volume Up 5:53078:0:</arg><subtitle>address: 53078</subtitle><icon>icon.png</icon></item><item autocomplete='Stereo - Volume Down 5:' valid='yes'><title>Stereo - Volume Down 5</title><arg>Stereo - Volume Down 5:57003:0:</arg><subtitle>address: 57003</subtitle><icon>icon.png</icon></item><item autocomplete='Stereo - Power:' valid='yes'><title>Stereo - Power</title><arg>Stereo - Power:37005:0:</arg><subtitle>address: 37005</subtitle><icon>icon.png</icon></item><item autocomplete='Stereo - Line In:' valid='yes'><title>Stereo - Line In</title><arg>Stereo - Line In:54836:0:</arg><subtitle>address: 54836</subtitle><icon>icon.png</icon></item><item autocomplete='Stereo - KPLU:' valid='yes'><title>Stereo - KPLU</title><arg>Stereo - KPLU:32963:0:</arg><subtitle>address: 32963</subtitle><icon>icon.png</icon></item><item autocomplete='Stereo - KEXP:' valid='yes'><title>Stereo - KEXP</title><arg>Stereo - KEXP:39911:0:</arg><subtitle>address: 39911</subtitle><icon>icon.png</icon></item></items>
[INFO: alfred.workflow.input.scriptfilter] Processing output 'alfred.workflow.action.script' with arg 'Stereo - KEXP:39911:0:'

Note that the last INFO line is "processing output", but there is nothing from the Run Script whatsoever.  I've even added gibberish to the very beginning of my Run Script and it never displays any errors, so it really seems it's just not being run.

 

Anyone have ideas for what to look at here, or how to enable even more verbose logging from Alfred workflows?

 

*UPDATE*:  I neglected to mention I'm running the latest Alfred (v2.8 (414)) w/Powerpack on Yosemite 10.10.5

 

Cheers -

elliott

Edited by ebarrere
Link to comment

So after some more investigation I think this may be related to a timeout somewhere.  Does Alfred have a timeout for Run Script commands to complete, after which it silently fails (remember, no output from Run Script whatsoever)?

 

There aren't timeouts (if you haven't set a script filter to terminate on subsequent input).

 

I'm going to move this into the Workflow help to get more eyes on the issue, and see if somebody can work out what might be going on!

 

Cheers,

Andrew

Link to comment

Hard to say, as I can't actually run the code. I fed the XML you posted above into the Run Script and it didn't hang. (It threw an error because I don't have an account to connect it to).

 

From what I can tell, you won't see anything in the debugger: all STDERR output is redirected to the log file.

 
Your use of {query} is a bit odd. Why aren't you using the defaults (i.e. "{query}" without Spaces, Brackets and Semicolons escaped)?
 
You could try adding echo "{query}" > /dev/stderr to the top of the Script box. That will show up in Alfred's debugger. If you see it, the problem is with your script.
 
Also, the install instructions in the README are incorrect. You can't run this in terminal: 

echo "$isy_config = {:hostname => 'https://isy.domain.com', :username => 'my_username', :password => 'my_password' }" > /path/to/folder/workflow/isy_config.rb

Because you used double quotes, bash will expand $isy_config to an empty string.

 

And, as best I can tell, your Gemfile is incomplete. The workflow also wants something called "color".

Link to comment

 

 

Your use of {query} is a bit odd. Why aren't you using the defaults (i.e. "{query}" without Spaces, Brackets and Semicolons escaped)?

 

I honestly don't remember.  It's probably something I saw somewhere and copied, or maybe I was messing with it while testing?  It's been a while :)

 

You are recommending double-quotes surrounding {query} and unchecking Spaces, Brackets and Semicolons from both the Script Filter and Run Script setups instead?

 

 

 

You could try adding echo "{query}" > /dev/stderr to the top of the Script box. That will show up in Alfred's debugger. If you see it, the problem is with your script.

 

Yeah, I wish I'd thought of this last time it was happening, but I plan to next time I see it :)

 

 

 

Also, the install instructions in the README are incorrect. You can't run this in terminal

 

Good point; I wrote that in like 10 minutes last night :)  Thanks for catching it; I've updated to use a HEREDOC instead.

 

 

 

And, as best I can tell, your Gemfile is incomplete. The workflow also wants something called "color".

 

Ah, yeah.  That's something I was playing with to control Philips Hue devices.  I don't think there's any code actually in use in there, but I should comment out the "require" for consistency.

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