Jump to content
spuder

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

Share this post


Link to post

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

Share this post


Link to post

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

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...