Jump to content

spuder

Member
  • Posts

    16
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by spuder

  1. Thanks for the information @Vitor. 

     

    This 'feature' is great when a websites api is fully developed (youtube, github, ect..) It is a pain trying to use the puppet forge api because searching for 1 letter returns too many results. 

     

    As a work around I've made my script exit if the argument is less than 4 characters. 

     

    https://github.com/spuder/alfred-puppet-forge/blob/master/test/forge.py

     

    if len(args[1]) <4:
    sys.exit("module name must have at least 3 characters")

    https://ask.puppetlabs.com/question/4557/limit-results-from-forge-api/

     

    It looks like this might be the best I can do until alfred allows me to block partial word searches, or the puppet forge API allows limits on the number of results. I'm open to any other ideas. 

  2. I've completed a python script to query the puppet forge api. 

     

    http://projects.puppetlabs.com/projects/module-site/wiki/Server-api

     

     

    When I call the python script from the command line, it successfully returns all puppet modules desired

     

    $ python myscript.py foo

     

     

    When I place the same python script into an alfred workflow, and set it to require 1 argument, alfred 'gives up' the search before I've fully entered what I am looking for. 

     

     

    Anyone have any ideas why Alfred doesn't wait for me to enter the entire string before searching? 

     

    Here is a video showing the problem

     

     

     

    *Update*

     

    My code is now on github

     

    https://github.com/spuder/alfred-puppet-forge

     

    It turns out that if I wait long enough, the script does eventually return. The problem is that alfred is calling the script every time a new letter is entered. 

     

    Searching the api gets faster each letter that is entered

     

    For example: 

     

    a = 1000 results

    ab = 100 results

    abc = 3 results

    abcd = 1 result

     

    So In practice, I have to wait for the results of a, ab, abc, before I can get the results of abcd. This is a 10 to 30 second delay for the data I am querying, which is far too long. 

     

    How can I make alfred wait until I have finished entering abcd before executing? 

  3. @jdkram

    Pardon my delay in responding to you, I did not see your post.

     

    This worflow queries  the json datastream located on mtgox's website

     

    http://data.mtgox.com/api/2/BTCUSD/money/ticker

     

    You'll have to find the mtgox datastream that has EURO's. and modify the perl script with that url. 

     

    Update:

     

    I found the Euro data stream.

     

    You'll need to change:

    data.mtgox.com/api/2/BTCUSD/money/ticker 

    to

    data.mtgox.com/api/2/BTCEUR/money/ticker

     

    Screen%20Shot%202013-06-21%20at%204.04.5

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

  5. Bitcoin workflow allows you to quickly lookup the real time bitcoin exchange rate. 

    Also can be configured to open links to your bitcoin pool website and bitcoin wallet app

     

    alfred-bitcoin-shortcut-screenshot.png

     

    alfred-bitcoin-shortcut-screenshot2.png

     

     

     

    Github: https://github.com/spudstud/alfred-bitcoin-workflow

     

     

    2013-4-27

    Update:

    - Adds query the mtgox api for current values

    - Rewrote to use python xml library instead of xml string

     

    2013-4-27

    Update 2

    Commit: 1bd7683c4ab1c3c051256bc2523226f474c59558

     

    Fixes:
    - Bug where high value was shown instead of last value
    - Typos in Comments

    Adds:
    - Code comments to make maintenance easier
    - spencer.py file which mirrors the actual workflow file
    - Bundle Id
    - Opens btcmine.com by default (instead of mining.bitcoin.cz)

    Changes:
    - Bundle Id now identifies workflow
    - Website now links to alfred forums post http://www.alfredforum.com/topic/2219-bitcoin-exchange-rate/
    - Alfred readme gives clearer instructions
    - Opens btcmine.com instead of slush (because I switched off of slush)

×
×
  • Create New...