Example #1
0
            except OSError:
                sys.stderr.write("OSError: removing %s\n" % lock)

    if hasattr(os, 'getpid'):
        try:
            pidfile = os.path.join(config.docroot, config.pid)
            file(pidfile, 'w').write('%d' % os.getpid())
        except (IOError, OSError), err:
            sys.stderr.write('IOError/OSError: %s\n' % err)

    global router
    global mupnpc
    if config.use_upnp:
        if not miniupnpc:
            sys.stderr.write("finding router\n")
            router = findrouter(config.upnp_timeout)
            if router:
                sys.stderr.write("found router: %s\n" % router)
            else:
                sys.stderr.write("Error: faild to find router\n")
        else:
            mupnpc = miniupnpc.UPnP()
            mupnpc.discoverdelay = config.upnp_timeout
            sys.stderr.write("finding router with MiniUPnPc\n")
            try:
                rcout = mupnpc.discover()
            except Exception, e:
                mupnpc = None
            if rcout >= 1:
                try:
                    raddr = mupnpc.selectigd()
Example #2
0
 def test(self):
     self.router = findrouter()
     return self.router
Example #3
0
            except OSError:
                sys.stderr.write("OSError: removing %s\n" % lock)

    if hasattr(os, 'getpid'):
        try:
            pidfile = os.path.join(config.docroot, config.pid)
            file(pidfile, 'w').write('%d' % os.getpid())
        except (IOError, OSError), err:
            sys.stderr.write('IOError/OSError: %s\n' % err)

    global router
    global mupnpc
    if config.use_upnp:
        if not miniupnpc:
            sys.stderr.write("finding router\n")
            router = findrouter(config.upnp_timeout)
            if router:
                sys.stderr.write("found router: %s\n" % router)
            else:
                sys.stderr.write("Error: faild to find router\n")
        else:
            mupnpc = miniupnpc.UPnP()
            mupnpc.discoverdelay = config.upnp_timeout
            sys.stderr.write("finding router with MiniUPnPc\n")
            try:
                rcout = mupnpc.discover()
            except Exception, e:
                mupnpc = None
            if rcout >= 1:
                try:
                    raddr = mupnpc.selectigd()