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