Пример #1
0
def main():
    global isy, programs, syslogUse, syslogFacility, logfile

    # Setup syslog if requested
    if syslogUse:
        syslog.openlog(logoption=syslog.LOG_PID, facility=syslogFacilities[syslogFacility])

    # Open logfile if requested
    if logfile:
        try:
            logfile = open(logfile, 'ab+')
        except IOError:
            usage('ERROR: Failed to open logfile! %s' % sys.exc_info()[1])

    # Dump status on sigusr1
    signal.signal(signal.SIGUSR1,status_dump)

    # Connect to ISY
    try:
        isy = Isy(addr=isyHost, userl=isyUser, userp=isyPass, debug=isyDebug)
    except:
        print "ERROR: Connection to ISY failed!"
        sys.exit(1)

    programs = get_proginfo(isy) # Get info about programs for trigger logging

    server = ISYEvent()
    server.subscribe(addr=isyHost, userl=isyUser, userp=isyPass, debug=isyDebug)
    server.set_process_func(parse_event, "")

    try:
	#print('Use Control-C to exit')
	server.events_loop()   #no return
    except KeyboardInterrupt:
	print('Exiting')
Пример #2
0
def extend_app(app):

    isy_addr = app.config.get('isy', 'isy_addr')
    isy_user = app.config.get('isy', 'isy_user')
    isy_pass = app.config.get('isy', 'isy_pass')

    app.log.debug('Connecting to ISY controller @%s' % isy_addr, __name__)

    try:
        isy = Isy(addr=isy_addr, userl=isy_user, userp=isy_pass)
    except Exception as e:
        app.log.error('Unable to connect to ISY controller @%s' % isy_addr,
                      __name__)
        app.log.error(e)
        return

    # extend the event engine app object with an ``isy`` member
    app.extend('isy', isy)

    # Make sure we pre populate all internal isy structures
    isy.load_nodes()
Пример #3
0
def extend_app(app):

    isy_addr = app.config.get('isy', 'isy_addr')
    isy_user = app.config.get('isy', 'isy_user')
    isy_pass = app.config.get('isy', 'isy_pass')

    app.log.debug('Connecting to ISY controller @%s' % isy_addr, __name__)

    try:
        isy = Isy(addr=isy_addr, userl=isy_user, userp=isy_pass)
    except Exception as e:
        app.log.error('Unable to connect to ISY controller @%s' % isy_addr,
                      __name__)
        app.log.error(e)
        return

    # extend the event engine app object with an ``isy`` member
    app.extend('isy', isy)

    # Make sure we pre populate all internal isy structures
    isy.load_nodes()
Пример #4
0
            opt_addr = arg
        elif opt in ('-u', '--user'):
            opt_user = arg
        elif opt in ('-p', '--password'):
            opt_passwd = arg
        elif opt in ('-e', '--error'):
            opt_errorlog = 1
        elif opt in ('-d', '--debug'):
            opt_debug = arg
        elif opt in ('-t', '--tab'):
            opt_tab = 1
        elif opt in ('-s', '--nosec'):
            opt_nosec = 1


def usage(code, msg=''):
    print >> sys.stderr, __doc__ % globals()
    if msg:
        print >> sys.stderr, msg
    sys.exit(code)


if __name__ == '__main__':
    parseargs()
    myisy = Isy(addr=opt_addr,
                userl=opt_user,
                userp=opt_passwd,
                debug=opt_debug)
    main(myisy)
    exit(0)
Пример #5
0
    for opt, arg in opts:
        if opt in ('-h', '--help'):
            usage(0)
        elif opt in ('-n', '--names'):
            opt_names = 1
        elif opt in ('-a', '--addr'):
            opt_addr = arg
        elif opt in ('-e', '--error'):
            opt_errorlog = 1
        elif opt in ('-d', '--debug'):
            opt_debug = arg
        elif opt in ('-t', '--tab'):
            opt_tab = 1
        elif opt in ('-s', '--nosec'):
            opt_nosec = 1


def usage(code, msg=''):
    print >> sys.stderr, __doc__ % globals()
    if msg:
        print >> sys.stderr, msg
    sys.exit(code)

if __name__ == '__main__' :
    parseargs()
    myisy = Isy( addr=opt_addr, debug=opt_debug )
    main(myisy)
    exit(0)

Пример #6
0
            unit = str(int(a[2], 16))
            node = house + unit
            addr_known.add(node)
            known_housecodes.add(house)

    print("addr_known : ", str(", ").join(sorted(addr_known)))

    for log_line in isy.log_iter():
        col = str(log_line).split("\t")

        if col[0] == "X10":
            #print col[1]
            if int(col[4]) == 0:
                addr_received.add(col[1])
            else:
                addr_used.add(col[1])

    print("addr_received = ", str(", ").join(sorted(addr_received)))
    print("addr_used = ", str(", ").join(sorted(addr_used)))

    addr_unknown = addr_received.union(addr_used) - addr_known
    addr_unknown -= known_housecodes

    print("addr_unknown = ", str(", ").join(sorted(addr_unknown)))


if __name__ == '__main__':
    myisy = Isy(parsearg=1)
    main(myisy)
    exit(0)
Пример #7
0
    exit(1)

app = shApp('isy')
app.setup()
app.run()

handler = shEventHandler(app)

isy_addr = app.config.get('isy', 'isy_addr')
isy_user = app.config.get('isy', 'isy_user')
isy_pass = app.config.get('isy', 'isy_pass')

app.log.debug('Connecting to ISY controller @%s' % isy_addr, __name__)

try:
    isy = Isy(addr=isy_addr, userl=isy_user, userp=isy_pass)
except Exception as e:
    app.log.error('Unable to connect to ISY controller @%s' % isy_addr,
                  __name__)
    app.log.error(e)
    app.close()
    exit(1)

# Make sure we pre populate all internal isy structures
try:
    isy.load_nodes()
except Exception as e:
    app.log.error('Unable to load ISY nodes.', __name__)
    app.log.error(e)
    app.close()
    # Wait a few seconds to recover in case process restarts under supervisord