def doswitch(miner, command: MinerCommand): '''switch miner pool''' if command.command: txtalert = "{0} {1}".format(miner.name, command.command) print(Fore.YELLOW + txtalert) #check if privileged mode, raise alert if not in privileged mode! access = COMPONENTACTION.app.antminer.getaccesslevel(miner) if access == MinerAccessLevel.Restricted: miner.set_ftp_port( COMPONENTACTION.app.configuration('discover.sshport')) access = COMPONENTACTION.app.antminer.setminertoprivileged(miner) if access == MinerAccessLevel.Restricted: raise Exception( 'Could not set miner {0} to priviledged'.format( miner.name)) antminerhelper.switch(miner, command.parameter) COMPONENTACTION.app.alert(txtalert) log = MinerLog() log.createdate = datetime.datetime.utcnow() log.minerid = miner.key() log.minername = miner.name log.action = txtalert COMPONENTACTION.app.log_mineractivity(log) COMPONENTACTION.app.send(QueueName.Q_MONITORMINER, COMPONENTACTION.app.messageencode(miner))
def switchtopool(miner, pooltoswitch): '''switch pool''' minerpool = antminerhelper.pools(miner) if minerpool is not None: #find pool number of default pool and switch to it switchtopoolnumber = minerpool.findpoolnumberforpool(pooltoswitch.url, pooltoswitch.user) if switchtopoolnumber is not None and switchtopoolnumber > 0: antminerhelper.switch(miner, switchtopoolnumber) print(Fore.YELLOW + PROVISION.app.now(), miner.name, 'switched to {0}({1})'.format(pooltoswitch.name, pooltoswitch.url))
str(minerstats.currenthash), str(minerstats.minercount), 'temp=' + str(minerstats.tempboardmax()), savedminer.uptime(minerstats.elapsed), '{0:0f}ms'.format(savedminer.monitorresponsetime() * 1000)) #switches miner to default pool if miner.defaultpool: founddefault = next( (p for p in POOLS if p.Name == miner.defaultpool), None) if founddefault is not None: minerpool = antminerhelper.pools(miner) if minerpool is not None: #find pool number of default pool and switch to it switchtopoolnumber = minerpool.findpoolnumberforpool( founddefault.url, founddefault.user) if switchtopoolnumber is not None and switchtopoolnumber > 0: antminerhelper.switch(miner, switchtopoolnumber) print(Fore.YELLOW + str(APP.now()), miner.name, 'switched to', miner.defaultpool) APP.putminerandstats(savedminer, minerstats, minerpool) APP.updateknownminer(savedminer) except Exception as ex: print(Fore.RED + 'Error on {0}'.format(miner.name)) APP.logexception(ex) APP.shutdown() WHATISAID = input('done')