Esempio n. 1
0
def blink(dev, reps, red, green, blue):
    """ Implements a --blink command, as found in blink1-tool.c """
    print "Blink {0} times rgb: {1},{2},{3}\n".format(reps, red, green, blue)
    for i in range(reps):
        blink1.fadeToRGB(dev, millis, red, green, blue)
        blink1.sleep(delay)
        sleep(1)
        blink1.fadeToRGB(dev, millis, 0, 0, 0)
        blink1.sleep(delay)
        sleep(1)
import time
import jb_http_getter

host="api.steampowered.com:80"
#url="/ISteamUser/GetPlayerSummaries/v0002/?key=2D23CE3CDE0849FCB5A7F2EA10100BD1&steamids=76561197970715856"
url="/ISteamUser/GetPlayerSummaries/v0002/?key=2D23CE3CDE0849FCB5A7F2EA10100BD1&steamids=STEAMID"

while 1:
    dev = blink1.open()
    f = open('steamids.txt', 'r')
    while 1:
        l = f.readline()
        if l == None or len(l) <= 0:
            break
        if not l.startswith('#'):
            blink1.fadeToRGB(dev, 900, 0x00, 0x00, 0x00)
            time.sleep(1)
            l = l.replace('\n', '')
            color={'red':0, 'green':0, 'blue':0x00}
            try:
                body = jb_http_getter.get_url(host, url.replace("STEAMID",l))
            except:
                body = ''
            print body
            ###offline
	    if body.find('personastate": 0') >= 0:
                color['red'] = 0xff
		color['blue'] = color['green'] = 0
            ###online
            elif body.find('personastate": 1') >= 0 and body.find('gameextrainfo":') < 0:
                color['blue'] = 0xff