Ejemplo n.º 1
0
from time import sleep
import BaseHTTPServer
import hydraulics_drv
import hydraulics_playback
import hydraulics_frontend

PORT = 9000

if __name__ == '__main__':

    print "Hydraulics Test program"
    print "Press CTRL C to exit"

    try:
        # setup driver
        hydraulics_drv.init()

        # setup playback
        hydraulics_playback.init()

        # initialize httpserver
        httpd = BaseHTTPServer.HTTPServer(
            ("", PORT), hydraulics_frontend.HydraulicsHandler)
        httpd.serve_forever()
    except KeyboardInterrupt:
        print "Keyboard interrupt detected, terminating"
    except Exception as e:
        print "Unexpected exception:", e

    try:
        httpd.server_close()
Ejemplo n.º 2
0
    try:
        configParser = ConfigParser.ConfigParser()
        configParser.read(configFile)
        HTTP_PORT = configParser.get("main", "httpPort", HTTP_PORT)
        POSITION_PORT = configParser.get("main", "streamPort", POSITION_PORT)
        HYDRAULICS_POLL_INTERVAL = configParser.get("main", "pollInterval",
                                                    HYDRAULICS_POLL_INTERVAL)
    except:
        logging.error(
            "Problem reading config file {}, defaulting configuration".format(
                configFile))

    try:
        # setup driver  - XXX own process?
        hydraulics_drv.init(HYDRAULICS_POLL_INTERVAL)

        # setup playback - NB - this is a set of utility functions, not own thread
        hydraulics_playback.init()

        # setup position streamer - XXX should be in own process
        hydraulics_stream.init(POSITION_PORT)

        # initialize httpserver
        httpd = BaseHTTPServer.HTTPServer(
            ("", HTTP_PORT), hydraulics_frontend.HydraulicsHandler)
        httpd.serve_forever()
    except KeyboardInterrupt:
        print "Keyboard interrupt detected, terminating"
    except Exception as e:
        logging.exception("Unexpected exception:")
Ejemplo n.º 3
0
if __name__ == "__main__":
    import requests
    import sys
    from threading import Thread
    import event_manager
    import hydraulics_playback

    logging.basicConfig(
        format=
        '%(asctime)-15s %(levelname)s %(module)s %(lineno)d: %(message)s',
        level=logging.DEBUG)
    try:
        event_manager.init()
        hydraulics_playback.init("playback_tests2")
        hydraulics_drv.init(500, True)
        httpd = BaseHTTPServer.HTTPServer(("", 9000), HydraulicsHandler)
        httpProcess = Thread(target=httpd.serve_forever)
        httpProcess.start()

        setState("nomove")

        time.sleep(1)

        unittest.main()
        print "TIMEOUT"

    except KeyboardInterrupt:
        pass
    except Exception:
        logger.warning("Unexpected exception in test code")