コード例 #1
0
    argparser.add_argument("-i", "--init", action='store_true', dest="init",
                    help="Init hardware")

    args = argparser.parse_args()

    if args.logfile is not None:
        if sys.version_info < (3, 0):
            console_log = open(args.logfile, 'a', 1)
        else:
            console_log = open(args.logfile, 'a', 1, encoding='utf-8')
        sys.stdout = console_log
        sys.stderr = console_log

    # Setup logging.
    logging.basicConfig(level = args.loglevel, datefmt='%H:%M:%S', format='%(asctime)s %(levelname)s:%(name)s:%(funcName)s:%(message)s')
    logger = logging.getLogger(__name__)

    logger.debug('Used options: {0}'.format(args))

    # The hardware need to be init one time after boot. To do this, run this 
    # programm at boot with -i
    if args.init is not None:
        init = True
    else:
        init = False

    heizung = HeizungControl(init_board=init, logger=logger)
    heizung.heizung_all_off()


コード例 #2
0
                    help="Init hardware")

    args = argparser.parse_args()

    if args.logfile is not None:
        if sys.version_info < (3, 0):
            console_log = open(args.logfile, 'a', 1)
        else:
            console_log = open(args.logfile, 'a', 1, encoding='utf-8')
        sys.stdout = console_log
        sys.stderr = console_log

    # The hardware need to be init one time after boot. To do this, run this.
    # programm at boot with -i 1
    if args.init is not None:
        init = True
    else:
        init = False

    # Setup logging.
    logging.basicConfig(level = args.loglevel, datefmt='%H:%M:%S', format='%(asctime)s %(levelname)s:%(name)s:%(funcName)s:%(message)s')
    logger = logging.getLogger(__name__)

    logger.debug('Used options: {0}'.format(args))

    logger.info("Heizung channel: {0}, duration {1}".format(args.channel,args.duration))

    heizung = HeizungControl(init_board=init, logger=logger)
    heizung.heizung_1ch(args.channel,args.duration)

コード例 #3
0
                                          second=int(row[re - 1]))

            t1 = int(row[0])

            logprint('Found: Timestamp {0} Channel: {1}'.format(timestamp, t1))

            # Timestamp > 1h in future should not happen
            if timestamp - datetime.timedelta(seconds=3600) > now:
                logprint("Event more than 1h in future - cleanup")
                cleanup = True

            # Old timestamp left
            elif timestamp < now:
                logprint("Old event detected - cleanup")
                cleanup = True

            # Timestamp between now and 1h away - let it run
            else:
                logprint("Found running event - no cleanup")
                cleanup = False

else:
    logprint("Token file does not exist")

logprint("State cleanup: {0}".format(cleanup))

if cleanup:
    heizung = HeizungControl()
    heizung.heizung_all_off()
    clean_tokenfile()