Esempio n. 1
0
def _run_proxy(args, count=None):
    server = SimpleServer(args.host, args.server_port, HTTPScopeInterface, args)
    args.SERVER_ADDR, args.SERVER_PORT = server.socket.getsockname()
    SimpleServer(args.host, args.stp_port, ScopeConnection, args)
    print "server on: http://%s:%s/" % (args.SERVER_NAME, args.SERVER_PORT)
    upnp_device = SimpleUPnPDevice(args.ip, args.server_port, args.stp_port)
    upnp_device.notify_alive()
    args.http_get_handlers["upnp_description"] = upnp_device.get_description
    args.upnp_device = upnp_device
    asyncore.loop(timeout = 0.1, count=count)
Esempio n. 2
0
def main_func():
    args = _parse_args()
    if not args.ip:
        print "failed to get the IP of the machine"
        return
    if not os.path.isdir(args.root):
        parser.error("""Root directory "%s" does not exist""" % args.root)
        return
    if args.message_filter:
        from utils import MessageMap
        MessageMap.set_filter(args.message_filter)
    os.chdir(args.root)
    try:
        _run_proxy(args)
    except KeyboardInterrupt:
        args.upnp_device.notify_byby()
        asyncore.loop(timeout = 0.1, count=6)
        for fd, obj in asyncore.socket_map.items():
            obj.close()
        sys.exit()

    """