Esempio n. 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')
Esempio n. 2
0
def Watcher():
    config.watchstarttime = time.time()
    config.watchlist = ['init']
    debugprint(config.dbgdaemon, "Watcher: ", config.watchstarttime,
               os.getpid())
    server = ISYEvent()
    server.subscribe(addr=config.ISYaddr,
                     userl=config.ISYuser,
                     userp=config.ISYpassword)
    server.set_process_func(event_feed, "")

    server.events_loop()
Esempio n. 3
0
def main() :
    server = ISYEvent()

    # you can subscribe to multiple devices
    # server.subscribe('10.1.1.25')

    server.subscribe( os.getenv('ISY_ADDR', '10.1.1.36'))
    server.set_process_func(ISYEvent.print_event, "")

    try:
	print('Use Control-C to exit')
	server.events_loop()   #no return
    #    for d in  server.event_iter( ignorelist=["_0", "_11"] ):
    #	server.print_event(d, "")
    except KeyboardInterrupt:
	print('Exiting')
Esempio n. 4
0
def main():
    server = ISYEvent(debug=0x0000)

    # you can subscribe to multiple devices
    # server.subscribe('10.1.1.25')

    server.subscribe(addr=os.getenv('ISY_ADDR', '10.1.1.36'),
                     userl=os.getenv('ISY_USER', "admin"),
                     userp=os.getenv('ISY_PASS', "admin"))

    server.set_process_func(_print_event, "")

    try:
        print('Use Control-C to exit')
        server.events_loop()  #no return
    #    for d in  server.event_iter( ignorelist=["_0", "_11"] ):
    #   server._print_event(d, "")
    except KeyboardInterrupt:
        print('Exiting')
Esempio n. 5
0
def main():
    server = ISYEvent(debug=0x0000)

    # you can subscribe to multiple devices
    # server.subscribe('10.1.1.25')

    server.subscribe(
        addr=os.getenv('ISY_ADDR', '10.1.1.36'),
        userl=os.getenv('ISY_USER', "admin"),
        userp=os.getenv('ISY_PASS', "admin")
    )

    server.set_process_func(_print_event, "")

    try:
        print('Use Control-C to exit')
        server.events_loop()   #no return
    #    for d in  server.event_iter( ignorelist=["_0", "_11"] ):
    #   server._print_event(d, "")
    except KeyboardInterrupt:
        print('Exiting')
Esempio n. 6
0
def main() :

    config = ConfigParser.ConfigParser()
    config.read(os.path.expanduser('~/home.cfg'))

    server = ISYEvent()

    isy_addr = config.get('isy', 'addr')
    isy_user = config.get('isy', 'user')
    isy_pass = config.get('isy', 'pass')

    server.subscribe(
            addr=isy_addr,
            userl=isy_user,
            userp=isy_pass )

    server.set_process_func(ISYEvent.print_event, "")

    try:
        print('Use Control-C to exit')
        server.events_loop()   #no return
    except KeyboardInterrupt:
        print('Exiting')
Esempio n. 7
0
    try:
        server.subscribe(addr=app.config.get('isy', 'isy_addr'),
                         userl=app.config.get('isy', 'isy_user'),
                         userp=app.config.get('isy', 'isy_pass'))
        break
    except Exception as e:
        retries += 1

        app.log.warn(e)
        app.log.warn('Cannot connect to ISY. Attempt %n of %n',
                     retries, app.config.retries)

        if retries >= app.config.retries:
            app.log.Fatal('Unable to connect to ISY. Exiting...')
            app.close(1)

        # Wait for the next poll intervall until we retry
        # also allows for configuration to get updated
        handler.sleep()
        continue


server.set_process_func(eventFeed, "")

try:
    server.events_loop()   # no return
except KeyboardInterrupt:
    app.log.info('Exiting...')

app.close()
Esempio n. 8
0
    try:
        server.subscribe(addr=isy_addr,
                         userl=isy_user,
                         userp=isy_pass)
        break
    except Exception as e:
        retries += 1

        app.log.warn(e)
        app.log.warn('Cannot connect to ISY. Attempt %n of %n',
                     retries, app.config.retries)

        if retries >= app.config.retries:
            app.log.Fatal('Unable to connect to ISY. Exiting...')
            app.close(1)

        # Wait for the next poll intervall until we retry
        # also allows for configuration to get updated
        handler.sleep()
        continue


server.set_process_func(eventFeed, "")

try:
    server.events_loop()   # no return
except KeyboardInterrupt:
    app.log.info('Exiting...')

app.close()