예제 #1
0
            if APP.configuration.get('camera.size') is not None:
                print("[{0}] sending camera".format(APP.now()))
                PHOTO_NAME = APP.camera.take_picture()
                APP.camera.store_picture_cache(PHOTO_NAME)
                if APP.configuration.is_enabled('telegram'):
                    APP.telegram.sendphoto(PHOTO_NAME)
            CAMERA.lastrun = datetime.datetime.now()

        if TEMPERATURE.is_time_to_run():
            if APP.configuration.is_enabled('temperature'):
                print("[{0}] sending temperature".format(APP.now()))
                SENSOR_HUMID, SENSOR_TEMP = APP.readtemperature()
                if SENSOR_HUMID or SENSOR_TEMP:
                    MESSAGE = '{0}: Temp={1:0.1f}*  Humidity={2:0.1f}%'.format(
                        APP.now(), SENSOR_TEMP.value, SENSOR_HUMID.value)
                    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()
예제 #2
0
from domain.loggingrepository import getminerlog
from domain.logging import MinerLog

print('Starting application...')
APP = ApplicationService()
print('started', APP.component)

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)