APP.alert(MESSAGE) TEMPERATURE.lastrun = datetime.datetime.now() if HEARTBEAT.is_time_to_run(): print("[{0}] sending heartbeat".format(APP.now())) MSG = 'At {0}'.format(APP.now()) #get summary of known miners. name, hash or offline, pool if APP.configuration.is_enabled('temperature'): SENSOR_HUMID, SENSOR_TEMP = APP.readtemperature() if SENSOR_HUMID or SENSOR_TEMP: MSG = MSG + 'Temp={0:0.1f}* Humidity={1:0.1f}%'.format( SENSOR_TEMP.value, SENSOR_HUMID.value) MSG = MSG + '\n{0}'.format(APP.minersummary()) APP.alert(MSG) APP.sendqueueitem(QueueEntry(QueueName.Q_LOG, MSG, 'broadcast')) HEARTBEAT.lastrun = datetime.datetime.now() if UPDATEWEB.is_time_to_run(): print("[{0}] check for web update".format(APP.now())) print('Pushing update web command to {0}.'.format( QueueName.Q_UPDATEWEB)) APP.send(QueueName.Q_UPDATEWEB, 'updateweb') UPDATEWEB.lastrun = datetime.datetime.now() time.sleep(SLEEP_SECONDS) except KeyboardInterrupt: APP.shutdown() except BaseException as ex: print('App Error: ' + APP.exceptionmessage(ex))
APP.cache.tryputcache(key='test', value='value') CACHE_VALUE = utils.safestring(APP.cache.trygetvaluefromcache('test')) if CACHE_VALUE == 'value': print(Fore.GREEN+'cache is working') else: print(Fore.RED+'cache is broken') try: SUCCESS = APP.alert('Full Cycle diagnostics test') if SUCCESS: print(Fore.GREEN+'message bus is working') else: print(Fore.RED+'message bus is broken') except BaseException as ex: print(Fore.RED+'message bus is broken') print(APP.exceptionmessage(ex)) try: LOG = MinerLog() LOG.createdate = datetime.datetime.utcnow() LOG.minerid = 'diag' LOG.minername = 'diagnostics' LOG.action = 'diagnostics' SUCCESS = APP.log_mineractivity(LOG) LOGS = getminerlog(APP.getsession()) #print(log.__dict__) LOG_CNT = 0 for log in LOGS: LOG_CNT += 1