def getMinerPoolStatusURL(): poolURL = "" firstPool = [] minprio = 9999 result = CgminerRPCClient.command('pools', host, port) if result: for items in result: # iterate over entire result to find POOLS collection if items == "POOLS": for i in result[items]: # found POOLS collection - remember best Alive #print json.dumps(i, sort_keys=True, indent=4, separators=(',', ': ')) if i['Status'] == 'Alive': prio = int(i['Priority']) if prio < minprio: minprio = prio firstPool = i if minprio < 9999: if firstPool['Stratum Active'] == True: poolURL = firstPool['Stratum URL'] else: poolURL = firstPool['URL'] return poolURL
def getMinerStats(): result = CgminerRPCClient.command('stats', host, port) if result: #print json.dumps(result, sort_keys=True, indent=4, separators=(',', ': ')) return result else: print "No stats data found" raise Exception("No stats data found") # let the exception handler display error screen
def getMinerPoolStatusURL(): poolURL = "" allPools = [] result = CgminerRPCClient.command('pools', host, port) if result: for items in result: # iterate over entire result to find POOLS collection if items == "POOLS": for i in result[items]: # found POOLS collection - build list of all pools #print json.dumps(i, sort_keys=True, indent=4, separators=(',', ': ')) allPools.append(i) # iterate over list of pools till we find the active one, then get the URL for thisPool in allPools: if thisPool['Stratum Active'] == True and thisPool['Status'] == 'Alive': poolURL = thisPool['Stratum URL'] return poolURL