def main():
    define("frontcam",
           default="http://10.14.18.2:5800",
           help="URL for the front camera",
           type=str)
    define("backcam",
           default="http://10.14.18.2:5801",
           help="URL for the back camera",
           type=str)
    define("host", default='127.0.0.1', help="Hostname of robot", type=str)
    define("port", default=8888, help="run on the given port", type=int)

    parse_command_line()

    init_networktables(options.host)

    app = tornado.web.Application(get_handlers() + [
        (r"/config.js", ConfigHandler),
        (r"/()", NonCachingStaticFileHandler, {
            "path": join(dirname(__file__), 'UI_MainPage.html')
        }),
        (r"/(.*)", NonCachingStaticFileHandler, {
            "path": dirname(__file__)
        }),
    ])

    logger.info("Listening on http://localhost:%s/" % options.port)

    app.listen(options.port)
    IOLoop.instance().start()
Example #2
0
def main():

    # Setup options here
    parser = OptionParser()

    parser.add_option('-p', '--port', type=int, default=80,
                      help='Port to run web server on')

    parser.add_option('-v', '--verbose', default=False, action='store_true',
                      help='Enable verbose logging')

    parser.add_option('--robot', default='127.0.0.1',
                      help="Robot's IP address")

    parser.add_option('--team', type=int, help='Team number of robot to connect to')

    parser.add_option('--dashboard', default=False, action='store_true',
                      help='Use this instead of --robot to receive the IP from the driver station. WARNING: It will not work if you are not on the same host as the DS!')

    parser.add_option('--identity', default='pynetworktables2js',
                      help='Identity to send to NT server')

    options, args = parser.parse_args()

    # Setup logging
    logging.basicConfig(datefmt=log_datefmt,
                        format=log_format,
                        level=logging.DEBUG if options.verbose else logging.INFO)

    if options.team and options.robot != '127.0.0.1':
        parser.error("--robot and --team are mutually exclusive")

    # Setup NetworkTables
    init_networktables(options)

    # setup tornado application with static handler + networktables support
    www_dir = abspath(join(dirname(__file__), 'www'))
    index_html = join(www_dir, 'index.html')

    if not exists(www_dir):
        logger.error("Directory '%s' does not exist!", www_dir)
        exit(1)

    if not exists(index_html):
        logger.warn("%s not found", index_html)

    app = tornado.web.Application(
        get_handlers() + [
            (r"/()", NonCachingStaticFileHandler, {"path": index_html}),
            (r"/(.*)", NonCachingStaticFileHandler, {"path": www_dir})
        ]
    )

    # Start the app
    logger.info("Listening on http://localhost:%s/", options.port)

    app.listen(options.port)
    IOLoop.current().start()
Example #3
0
def main():
    define("webcam", default="http://raspberrypi.local:5806/?action=stream", help="URL for the webcam", type=str)
    define("webcam2", default="http://raspberrypi2.local:5803/?action=stream", help="URL for the webcam", type=str)
    define("host", default='10.33.22.2', help="Hostname of robot", type=str)
    define("port", default=3322, help="run on the given port", type=int)

    parse_command_line()
    
    

    init_networktables(options.host)
    
    app = tornado.web.Application(
        get_handlers() + [
            (r"/config.js", ConfigHandler),
            (r"/()", NonCachingStaticFileHandler, {"path": join(dirname(__file__), 'UI_MainPage.html')}),
            (r"/(.*)", NonCachingStaticFileHandler, {"path": dirname(__file__)}),
        ]
    )
    
    #logger.info("Listening on http://localhost:%s/" % options.port)

    app.listen(options.port)
    IOLoop.instance().start()
Example #4
0
def main():
    define("frontcam", default="http://10.14.18.2:5800", help="URL for the front camera", type=str)
    define("backcam", default="http://10.14.18.2:5801", help="URL for the back camera", type=str)
    define("host", default='127.0.0.1', help="Hostname of robot", type=str)
    define("port", default=8888, help="run on the given port", type=int)

    parse_command_line()
    
    

    init_networktables(options.host)
    
    app = tornado.web.Application(
        get_handlers() + [
            (r"/config.js", ConfigHandler),
            (r"/()", NonCachingStaticFileHandler, {"path": join(dirname(__file__), 'UI_MainPage.html')}),
            (r"/(.*)", NonCachingStaticFileHandler, {"path": dirname(__file__)}),
        ]
    )
    
    logger.info("Listening on http://localhost:%s/" % options.port)

    app.listen(options.port)
    IOLoop.instance().start()
Example #5
0
    if not exists(www_dir):
        logger.error("Directory '%s' does not exist!" % www_dir)
        exit(1)

    if not exists(index_html):
        logger.warn("%s not found" % index_html)

    class PiUrlHandler(tornado.web.RequestHandler):
        def get(self):
            self.write(
                json.dumps({
                    "pi": "http://" + pi_url,
                    "rio": "http://" + rio_url
                }))

    app = tornado.web.Application(get_handlers() +
                                  [(r"/piurl", PiUrlHandler),
                                   (r"/()", NonCachingStaticFileHandler, {
                                       "path": index_html
                                   }),
                                   (r"/(.*)", NonCachingStaticFileHandler, {
                                       "path": www_dir
                                   })])

    # Start the app
    logger.info("Listening on http://localhost:%s/" % options.port)

    app.listen(options.port)
    IOLoop.current().start()
    initNetworktables(options)
    robotlog = Robotlog.Robotlog()

    # setup tornado application with static handler + networktables support
    www_dir = abspath(join(dirname(__file__), 'www'))
    index_html = join(www_dir, 'index.html')

    if not exists(www_dir):
        logger.error("Directory '%s' does not exist!", www_dir)
        exit(1)

    if not exists(index_html):
        logger.warn("%s not found" % index_html)

    app = tornado.web.Application(
        pynetworktables2js.get_handlers() + robotlog.getHandlers() +
        [(r"/()", pynetworktables2js.NonCachingStaticFileHandler, {
            "path": index_html
        }),
         (r"/(.*)", pynetworktables2js.NonCachingStaticFileHandler, {
             "path": www_dir
         })])

    # Start the app
    logger.info("Listening on http://localhost:%s/", options.port)

    app.listen(options.port)
    ioLoop = tornado.ioloop.IOLoop.current()
    sock = robotlog.getUDPSocket()
    callback = functools.partial(robotlog.handleMsg, sock)
    ioLoop.add_handler(sock.fileno(), callback, ioLoop.READ)
Example #7
0
        datefmt=log_datefmt,
        format=log_format,
        level=logging.DEBUG if options.verbose else logging.INFO)

    # Setup NetworkTables
    init_networktables(options.robot)

    # setup tornado application with static handler + networktables support
    www_dir = abspath(join(dirname(__file__), 'www'))
    index_html = join(www_dir, 'index.html')

    if not exists(www_dir):
        logger.error("Directory '%s' does not exist!" % www_dir)
        exit(1)

    if not exists(index_html):
        logger.warn("%s not found" % index_html)

    app = tornado.web.Application(
        get_handlers() + [(r"/()", NonCachingStaticFileHandler, {
            "path": index_html
        }), (r"/(.*)", NonCachingStaticFileHandler, {
            "path": www_dir
        })])

    # Start the app
    logger.info("Listening on http://localhost:%s/" % options.port)

    app.listen(options.port)
    IOLoop.current().start()
    options, args = parser.parse_args()

    logging.basicConfig(
        datefmt=log_datefmt, format=log_format, level=logging.DEBUG if options.verbose else logging.INFO
    )
    init_networktables(options.robot)

    www_dir = abspath(join(__file__, "../"))
    index_html = join(www_dir, "index.html")

    if not exists(www_dir):
        logger.error("Directory '%s' does not exist!" % www_dir)
        exit(1)

    if not exists(index_html):
        logger.warn("%s not found" % index_html)

    app = tornado.web.Application(
        get_handlers()
        + [
            (r"/()", NonCachingStaticFileHandler, {"path": index_html}),
            (r"/(.*)", NonCachingStaticFileHandler, {"path": www_dir}),
        ]
    )

    logger.info("Listening on http://localhost:%s/" % options.port)

    app.listen(options.port)
    IOLoop.current().start()
Example #9
0
    # Setup NetworkTables
    init_networktables(options)

    # setup tornado application with static handler + networktables support
    www_dir = abspath(dirname(__file__))
    index_html = join(www_dir, 'index.html')

    if not exists(www_dir):
        logger.error('Directory \'%s\' does not exist!', www_dir)
        exit(1)

    if not exists(index_html):
        logger.warn('%s not found' % index_html)

    app = tornado.web.Application(
        get_handlers() + [(r'/()', NonCachingStaticFileHandler, {
            'path': index_html
        }), (r'/(.*)', NonCachingStaticFileHandler, {
            'path': www_dir
        })])

    # Start the app
    logger.info('Listening on http://localhost:%s/', options.port)

    app.listen(options.port)
    try:
        IOLoop.current().start()
    except:
        IOLoop.current().stop()
Example #10
0
    if not exists(www_dir):
        logger.error("Directory '%s' does not exist!", www_dir)
        exit(1)

    if not exists(index_html):
        logger.warn("%s not found" % index_html)
    
    class My404Handler(RequestHandler):
        # Override prepare() instead of get() to cover all possible HTTP methods.
        def prepare(self):
            self.set_status(404)
            self.render("404.html")

    app = tornado.web.Application(
        pynetworktables2js.get_handlers() +
        robotlog.getHandlers() +
        ApiHandler.getHandlers() +
        WebAPI.getHandlers() +
        [
            (r"/()", pynetworktables2js.NonCachingStaticFileHandler,
                {"path": index_html}),
            (r"/(.*)", pynetworktables2js.NonCachingStaticFileHandler,
                {"path": www_dir})
        ],
        default_handler_class=My404Handler
    )

    # Start the app
    logger.info("Listening on http://localhost:%s/", options.port)
Example #11
0
        parser.error("Cannot specify --robot and --dashboard")

    # Setup NetworkTables
    init_networktables(options)

    # setup tornado application with static handler + networktables support
    www_dir = abspath(join(dirname(__file__), 'www'))
    index_html = join(www_dir, 'index.html')

    if not exists(www_dir):
        logger.error("Directory '%s' does not exist!", www_dir)
        exit(1)

    if not exists(index_html):
        logger.warn("%s not found" % index_html)

    app = tornado.web.Application(
        get_handlers() +
        [(r"/start-jar", startJar), (r"/restart-jar", restartJar),
         (r"/()", NonCachingStaticFileHandler, {
             "path": index_html
         }), (r"/(.*)", NonCachingStaticFileHandler, {
             "path": www_dir
         })])

    # Start the app
    logger.info("Listening on http://localhost:%s/", options.port)

    app.listen(options.port)
    IOLoop.current().start()
Example #12
0
def main():

    #Setup options here
    parser = OptionParser()

    parser.add_option("-p",
                      "--port",
                      type=int,
                      default=8888,
                      help="Port to run webserver on")

    parser.add_option("-v",
                      "--verbose",
                      default=False,
                      action="store_true",
                      help="Enable verbose logging")

    parser.add_option("--robot",
                      default="127.0.0.1",
                      help="Robot's IP address")

    parser.add_option("--team",
                      type=int,
                      help="Team number of robot to connect to")

    parser.add_option(
        "--dashboard",
        default=False,
        action="store_true",
        help=
        "Use this instead of --robot to receive the IP from the driver station. WARNING: It will not work if you are not on the same host as the DS!"
    )

    parser.add_option("--identity",
                      default="pynetworktables2js",
                      help="Identity to send to NT server")

    options, args = parser.parser_args()

    #Setup Logging
    logging.basicConfig(
        datefmt=log_datefmt,
        format=log_format,
        level=logging.DEBUG if options.verbose else logging.INFO)

    #Setup Networktables
    init_networktables(options)

    #Setup tornado application with static handler + networktables support
    www_dir = abspath(join(dirname(__file__), "www"))
    index_html = join(www_dir, "index.html")

    if not exists(www_dir):
        logger.error("Directory '%s' does not exist!", www_dir)
        exit(1)

    if not exists(index_html):
        logger.warn("%s not found", index_html)

    app = tornado.web.Application(get_handlers() + [
        (r"/()", NonCachingStaticFileHandle, {
            "path": index_html
        }),
        (r"/(.*)", NonCachingStaticFileHandle, {
            "path": www_dir
        }),
    ])

    #Start the app
    logger.info("listening on http://localhost:%s/", options.port)

    app.listen(options.port)
    IOLoop.current().start()