spuder Posted April 27, 2013 Share Posted April 27, 2013 (edited) I've got a workflow that pulls down the latest exchange rate of bitcoins. Everything works great as long as I pass an "arg" which is a string. If I attempt to pass a variable, the workflow fails. See the python script here: https://gist.github.com/spudstud/5473927 Basically: this works: currentValue = 42 print ("<items><item uid='foo' arg='42' valid='yes'..... But this doesn't: currentValue=42 print ("<items><item uid='foo' arg="+currentValue+" valid='yes'..... Update: 2013-04-27 Thanks for the solution Tyler. I ended up using built in python libraries to make the code easier to maintain. This works perfectly now. from xml.etree.ElementTree import Element, SubElement, Comment, tostring currentValue = 42 items = Element('items') item = SubElement(items, 'item') item.set('uid', 'mtgoxprice') item.set('arg', str(currentValue)) item.set('valid', 'yes') title = SubElement(item, 'title') title.text = "MtGox Current Rate" subtitle = SubElement(item, 'subtitle') subtitle.text = str(currentValue) icon = SubElement(item, 'icon') icon.text = "MtGox.png" print tostring(items) The finished product is here: https://github.com/spudstud/alfred-bitcoin-workflow Edited April 27, 2013 by spuder Link to comment
Tyler Eich Posted April 27, 2013 Share Posted April 27, 2013 (edited) I've got a workflow that pulls down the latest exchange rate of bitcoins. Everything works great as long as I pass an "arg" which is a string. If I attempt to pass a variable, the workflow fails. See the python script here: https://gist.github.com/spudstud/5473927 Basically: this works: currentValue = 42 print ("<items><item uid='foo' arg='42' valid='yes'..... But this doesn't: currentValue=42 print ("<items><item uid='foo' arg="+currentValue+" valid='yes'..... Looks like you're missing the quotes around the arg value; it should be: currentValue = 42; print("<items><item uid='foo' arg='" + currentValue + "' valid='yes'... (Notice the extra single quotes before and after the double quotes) Cheers Edited April 27, 2013 by Tyler Eich spuder and jdfwarrior 2 Link to comment
jdfwarrior Posted April 27, 2013 Share Posted April 27, 2013 Looks like you're missing the quotes around the arg value; it should be: currentValue = 42; print("<items><item uid='foo' arg='" + currentValue + "' valid='yes'... (Notice the extra single quotes before and after the double quotes) Cheers I've got a workflow that pulls down the latest exchange rate of bitcoins. Everything works great as long as I pass an "arg" which is a string. If I attempt to pass a variable, the workflow fails. See the python script here: https://gist.github.com/spudstud/5473927 Basically: this works: currentValue = 42 print ("<items><item uid='foo' arg='42' valid='yes'..... But this doesn't: currentValue=42 print ("<items><item uid='foo' arg="+currentValue+" valid='yes'..... Well spotted Tyler, you beat me to it Thanks for helping Tyler Eich 1 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