Ejemplo n.º 1
0
def main():
    import socket
    from wsgiref import simple_server

    class WSGIRequestHandler(simple_server.WSGIRequestHandler):
        """A WSGIRequestHandler who log to a logger"""

        def log_message(self, format, *args):
            log.debug(format % args)

    player.stop()
    player.start()
    if player.debug:
        debug(True)
    try:
        httpd = simple_server.make_server(
                    '', 8080, app,
                    handler_class=WSGIRequestHandler)
        print "Serving on port 8080... Hit CTRL+C to stop"
        httpd.serve_forever()
    except KeyboardInterrupt:
        player.stop()
    except socket.error, e:
        print e
Ejemplo n.º 2
0
def main():
    import socket
    from wsgiref import simple_server

    class WSGIRequestHandler(simple_server.WSGIRequestHandler):
        """A WSGIRequestHandler who log to a logger"""
        def log_message(self, format, *args):
            log.debug(format % args)

    player.stop()
    player.start()
    if player.debug:
        debug(True)
    try:
        httpd = simple_server.make_server('',
                                          8080,
                                          app,
                                          handler_class=WSGIRequestHandler)
        print "Serving on port 8080... Hit CTRL+C to stop"
        httpd.serve_forever()
    except KeyboardInterrupt:
        player.stop()
    except socket.error, e:
        print e
Ejemplo n.º 3
0
def main():
    parser = OptionParser()
    parser.add_option("-f", "--fullscreen", dest="fullscreen",
                            action='store_true',
                            default=False,
                            help="full screen mode")
    parser.add_option("-l", "--list", dest="list",
                            action='store_true',
                            default=False,
                            help="list channels")
    parser.add_option("-i", "--info", dest="info",
                            action='store_true',
                            default=False,
                            help="list channels")
    parser.add_option("-s", "--stop", dest="stop",
                            action='store_true',
                            default=False,
                            help="stop vlc")
    parser.add_option("-p", "--freeplayer", dest="player",
                            action='store_true',
                            default=False,
                            help="run the freeplayer")
    parser.add_option("-d", "--debug", dest="debug",
                            action='store_true',
                            default=False,
                            help="debug mode")
    options, args = parser.parse_args()
    if options.debug:
        player.debug = True
        if len(args) == 1 and os.path.isdir(args[0]):
            player.params.location = os.path.abspath(args[0])
        logging.basicConfig(level=logging.DEBUG)
        logging.debug('Starting in debug mode')

    if options.player:
        from freeboxtv.app import main
        main()
        return

    if options.stop:
        player.stop()
    elif options.info:
        infos = player.infos
        print('Chan:\t' + infos.name)
        print('State:\t' + infos.state)
        if infos.length:
            print('Pos:\t%smn/%smn' + (infos.time / 60, infos.length / 60))
        print(infos)
    elif options.list:
        channels = player.channels
        for k in sorted(channels):
            v = channels.get(k)
            print '%s: %s' % (k, v.get('name'))
    elif not args:
        player.default(**eval(str(options)))
    else:
        arg = ' '.join(args)
        channels = player.channels
        if arg.isdigit() and int(arg) in channels:
            open(TMP_PLAYLIST, 'w').write(
                channels.get(int(arg)).get('raw'))
            player.open_url(TMP_PLAYLIST, **eval(str(options)))
        else:
            arg = arg.lower()
            for k, v in channels.items():
                name = v.get('name').lower()
                if name.startswith(arg):
                    open(TMP_PLAYLIST, 'w').write(
                        channels.get(k).get('raw'))
                    player.open_url(TMP_PLAYLIST, **eval(str(options)))
                    break