Jump to content

Workflow XML does not accept arg ?


Recommended Posts

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 by spuder
Link to comment

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 by Tyler Eich
Link to comment

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

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