startracker.py
def main(args):
    """It is a main.

    arguments are passed in via env vars currently;
        WATCHDOG_USEC = 3000000
    """
    server = setup(args.CONFIGFILE, args.YEAR)
    rgb = StarCamera(args.CAM)
    ir = science_camera(args.CAM)

    CONNECTIONS = {}

    epoll = select.epoll()
    epoll.register(server.fileno(), select.EPOLLIN)

    try:
        connection(sys.stdin, epoll)
    except IOError:
        pass

    daemon.notify("WATCHDOG=1")
    last_ping = time()
    while True:
        # systemd watchdog
        events = epoll.poll(float(os.environ['WATCHDOG_USEC']) /
                            2.0e6 - (time() - last_ping))
        if (len(events) == 0 or time() >=
                (last_ping + float(os.environ['WATCHDOG_USEC']) / 2.0e6)):
            daemon.notify("WATCHDOG=1")
            last_ping = time()
        # events = epoll.poll()
        for fd, event_type in events:
            # Activity on the master socket means a new connection.
            if fd == server.fileno():
                conn, addr = server.accept()
                connection(conn, epoll)
            elif fd in CONNECTIONS:
                w = CONNECTIONS[fd]
                data = w.read()
                print(data.decode(encoding='UTF-8'), file=sys.stderr)
                if len(data) > 0:
                    if sys.version_info[0] > 2:
                        stdout_redir = StringIO()
                    else:
                        stdout_redir = BytesIO()
                    stdout_old = sys.stdout
                    sys.stdout = stdout_redir
                    try:
                        exec(data)
                    except SystemExit:
                        w.close()
                        raise
                    except:
                        traceback.print_exc(file=sys.stdout)
                    sys.stdout = stdout_old
                    data_out = stdout_redir.getvalue()
                    print(data_out, file=sys.stderr)
                    w.write(data_out)
                else:
                    w.close()
It is a main.

    arguments are passed in via env vars currently;
        WATCHDOG_USEC = 3000000
    
It is a main.
arguments are passed in via env vars currently;
WATCHDOG_USEC = 3000000
It is a main . arguments are passed in via env vars currently ; WATCHDOG_USEC = 3000000
def main(args):
    server = setup(args.CONFIGFILE, args.YEAR)
    rgb = StarCamera(args.CAM)
    ir = science_camera(args.CAM)
    CONNECTIONS = {}
    epoll = select.epoll()
    epoll.register(server.fileno(), select.EPOLLIN)
    try:
        connection(sys.stdin, epoll)
    except IOError:
        pass
    daemon.notify("WATCHDOG=1")
    last_ping = time()
    while True:
        events = epoll.poll(float(os.environ['WATCHDOG_USEC']) /
                            2.0e6 - (time() - last_ping))
        if (len(events) == 0 or time() >=
                (last_ping + float(os.environ['WATCHDOG_USEC']) / 2.0e6)):
            daemon.notify("WATCHDOG=1")
            last_ping = time()
        for fd, event_type in events:
            if fd == server.fileno():
                conn, addr = server.accept()
                connection(conn, epoll)
            elif fd in CONNECTIONS:
                w = CONNECTIONS[fd]
                data = w.read()
                print(data.decode(encoding='UTF-8'), file=sys.stderr)
                if len(data) > 0:
                    if sys.version_info[0] > 2:
                        stdout_redir = StringIO()
                    else:
                        stdout_redir = BytesIO()
                    stdout_old = sys.stdout
                    sys.stdout = stdout_redir
                    try:
                        exec(data)
                    except SystemExit:
                        w.close()
                        raise
                    except:
                        traceback.print_exc(file=sys.stdout)
                    sys.stdout = stdout_old
                    data_out = stdout_redir.getvalue()
                    print(data_out, file=sys.stderr)
                    w.write(data_out)
                else:
                    w.close()
def main ( args ) : server = setup ( args . CONFIGFILE , args . YEAR ) rgb = StarCamera ( args . CAM ) ir = science_camera ( args . CAM ) CONNECTIONS = { } epoll = select . epoll ( ) epoll . register ( server . fileno ( ) , select . EPOLLIN ) try : connection ( sys . stdin , epoll ) except IOError : pass daemon . notify ( "WATCHDOG=1" ) last_ping = time ( ) while True : events = epoll . poll ( float ( os . environ [ 'WATCHDOG_USEC' ] ) / 2.0e6 - ( time ( ) - last_ping ) ) if ( len ( events ) == 0 or time ( ) >= ( last_ping + float ( os . environ [ 'WATCHDOG_USEC' ] ) / 2.0e6 ) ) : daemon . notify ( "WATCHDOG=1" ) last_ping = time ( ) for fd , event_type in events : if fd == server . fileno ( ) : conn , addr = server . accept ( ) connection ( conn , epoll ) elif fd in CONNECTIONS : w = CONNECTIONS [ fd ] data = w . read ( ) print ( data . decode ( encoding = 'UTF-8' ) , file = sys . stderr ) if len ( data ) > 0 : if sys . version_info [ 0 ] > 2 : stdout_redir = StringIO ( ) else : stdout_redir = BytesIO ( ) stdout_old = sys . stdout sys . stdout = stdout_redir try : exec ( data ) except SystemExit : w . close ( ) raise except : traceback . print_exc ( file = sys . stdout ) sys . stdout = stdout_old data_out = stdout_redir . getvalue ( ) print ( data_out , file = sys . stderr ) w . write ( data_out ) else : w . close ( )
It is a main.
It is a main .
"""It is a main.

    arguments are passed in via env vars currently;
        WATCHDOG_USEC = 3000000
    """ # systemd watchdog # events = epoll.poll() # Activity on the master socket means a new connection.
args