def create_socket_inet(self, port = CONTROL_SOCKET_PORT): try: controlsocket = RawServer.create_serversocket(port, '127.0.0.1', reuse=True) except socket.error, e: raise BTFailure(_("Could not create control socket: ")+str(e))
def create(self): obtain_mutex = 1 mutex = win32event.CreateMutex(None, obtain_mutex, app_name) # prevent the PyHANDLE from going out of scope, ints are fine self.mutex = int(mutex) mutex.Detach() lasterror = win32api.GetLastError() if lasterror == winerror.ERROR_ALREADY_EXISTS: takeover = 0 try: # if the mutex already exists, discover which port to connect to. # if something goes wrong with that, tell us to take over the # role of master takeover = self.discover_sic_socket() except: pass if not takeover: raise BTFailure(_("Global mutex already created.")) self.master = 1 # lazy free port code port_limit = 50000 while self.port < port_limit: try: controlsocket = RawServer.create_serversocket(self.port, "127.0.0.1", reuse=True) self.controlsocket = controlsocket break except socket.error, e: self.port += 1
def create(self): obtain_mutex = 1 mutex = win32event.CreateMutex(None, obtain_mutex, app_name) # prevent the PyHANDLE from going out of scope, ints are fine self.mutex = int(mutex) mutex.Detach() lasterror = win32api.GetLastError() if lasterror == winerror.ERROR_ALREADY_EXISTS: takeover = 0 try: # if the mutex already exists, discover which port to connect to. # if something goes wrong with that, tell us to take over the # role of master takeover = self.discover_sic_socket() except: pass if not takeover: raise BTFailure(_("Global mutex already created.")) self.master = 1 # lazy free port code port_limit = 50000 while self.port < port_limit: try: controlsocket = RawServer.create_serversocket(self.port, '127.0.0.1', reuse=True) self.controlsocket = controlsocket break except socket.error, e: self.port += 1
def track(args): if len(args) == 0: print formatDefinitions(defaults, 80) return try: config, files = parseargs(args, defaults, 0, 0) except ValueError, e: print _("error: ") + str(e) print _("run with no arguments for parameter explanations") return #file(config['pid'], 'w').write(str(os.getpid())) r = RawServer(Event(), config) t = Tracker(config, r) s = r.create_serversocket(config['port'], config['bind'], True) r.start_listening( s, HTTPHandler(t.get, config['min_time_between_log_flushes'])) r.listen_forever() t.save_dfile() print _("# Shutting down: ") + isotime() def size_format(s): if (s < 1024): r = str(s) + 'B' elif (s < 1048576): r = str(int(s / 1024)) + 'KiB' elif (s < 1073741824): r = str(int(s / 1048576)) + 'MiB' elif (s < 1099511627776):
self.rawserver.add_task(self.expire_downloaders, self.timeout_downloaders_interval) def track(args): if len(args) == 0: print formatDefinitions(defaults, 80) return try: config, files = parseargs(args, defaults, 0, 0) except ValueError, e: print _("error: ") + str(e) print _("run with no arguments for parameter explanations") return file(config['pid'], 'w').write(str(os.getpid())) r = RawServer(Event(), config) t = Tracker(config, r) s = r.create_serversocket(config['port'], config['bind'], True) r.start_listening(s, HTTPHandler(t.get, config['min_time_between_log_flushes'])) r.listen_forever() t.save_dfile() print _("# Shutting down: ") + isotime() def size_format(s): if (s < 1024): r = str(s) + 'B' elif (s < 1048576): r = str(int(s/1024)) + 'KiB' elif (s < 1073741824): r = str(int(s/1048576)) + 'MiB' elif (s < 1099511627776): r = str(int((s/1073741824.0)*100.0)/100.0) + 'GiB' else:
def track(args): if len(args) == 0: print formatDefinitions(defaults, 80) return try: config, files = parseargs(args, defaults, 0, 0) except ValueError, e: print _("error: ") + str(e) print _("run with no arguments for parameter explanations") return file(config["pid"], "w").write(str(os.getpid())) r = RawServer(Event(), config) t = Tracker(config, r) s = r.create_serversocket(config["port"], config["bind"], True) r.start_listening(s, HTTPHandler(t.get, config["min_time_between_log_flushes"])) r.listen_forever() t.save_dfile() print _("# Shutting down: ") + isotime() def size_format(s): if s < 1024: r = str(s) + "B" elif s < 1048576: r = str(int(s / 1024)) + "KiB" elif s < 1073741824: r = str(int(s / 1048576)) + "MiB" elif s < 1099511627776: r = str(int((s / 1073741824.0) * 100.0) / 100.0) + "GiB"