rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
host, port = self._ParseAddress(service.address) print "New Peer ", host, ":", port | address = self._ParseAddress(service.address) print "New Peer ", address | def NewPeer(self, peer, service): try: host, port = self._ParseAddress(service.address) print "New Peer ", host, ":", port except ValueError: pass else: self.ui.AddPeer(peer) self.hosts[peer.id_] = host, port |
self.hosts[peer.id_] = host, port | self.hosts[peer.id_] = address | def NewPeer(self, peer, service): try: host, port = self._ParseAddress(service.address) print "New Peer ", host, ":", port except ValueError: pass else: self.ui.AddPeer(peer) self.hosts[peer.id_] = host, port |
host, port = self._ParseAddress(service.address) | address = self._ParseAddress(service.address) | def ChangedPeer(self, peer, service): try: host, port = self._ParseAddress(service.address) except ValueError: if peer.id_ in self.hosts: del self.hosts[peer.id_] self.ui.RemovePeer(peer.id_) else: self.ui.UpdatePeer(peer) self.hosts[peer.id_] = host, port |
self.hosts[peer.id_] = host, port | self.hosts[peer.id_] = address | def ChangedPeer(self, peer, service): try: host, port = self._ParseAddress(service.address) except ValueError: if peer.id_ in self.hosts: del self.hosts[peer.id_] self.ui.RemovePeer(peer.id_) else: self.ui.UpdatePeer(peer) self.hosts[peer.id_] = host, port |
self.ui.AddPeer(self.service_api.GetNode()) | def Enable(self): # Set up chat GUI window = ChatWindow(self, self.service_api.GetDirectory()) main_window = self.service_api.GetMainWindow() self.ui = UIProxy(window) self.ui.AddPeer(self.service_api.GetNode()) # Set up network connection #~ n = NetworkLauncher(self.reactor, self, self.port) #~ self.network = TwistedP... | |
self._UpdateUI() | wx.CallAfter(self._UpdateUI) | def OnRadioLocal(self, event): # wxGlade: ConnectionTypeDialog.<event_handler> self._UpdateUI() |
self._UpdateUI() | wx.CallAfter(self._UpdateUI) | def OnRadioRemote(self, event): # wxGlade: ConnectionTypeDialog.<event_handler> self._UpdateUI() |
plugin.Init() | try: plugin.Init() except Exception, e: from traceback import print_exc print "Failed to initialize plugin '%s', disabling." % service_id print_exc() del self.plugins[service_id] | def InitService(self, service_id, plugin): """ Initialize a given service. """ # Note: when plugin.Init() is called, everything else should have been # properly initialized for the plugin to interact with it. plugin.Init() |
print "downloaded profile", document.get_pseudo() | def get_profile(self, peer_id): print "downloaded profile", document.get_pseudo() self.network.get_profile(peer_id, self._on_new_profile) | |
return [sys.executable, "'" + prog_path + "'"] | return [sys.executable, prog_path] | def python_args(self): # Find the proper executable in the current dir for f in self.launcher_alternatives: if os.path.isfile(f): prog_name = f break else: return None prog_path = abspath(prog_name) # We try to keep the same Python interpreter as currently if os.path.exists(sys.executable) and re.match(r'.*\.py[cow]?$'... |
return ["'" + prog_path+ "'"] | return [prog_path] | def python_args(self): # Find the proper executable in the current dir for f in self.launcher_alternatives: if os.path.isfile(f): prog_name = f break else: return None prog_path = abspath(prog_name) # We try to keep the same Python interpreter as currently if os.path.exists(sys.executable) and re.match(r'.*\.py[cow]?$'... |
cmdline = " ".join(args) | executable = args[0] cmdline = " ".join([(' ' in arg and '"' + arg + '"' or arg) for arg in args]) | def Launch(self): # First handle the py2app special case methods = [self.py2app_args, self.python_args] for m in methods: args = m() if args: break else: raise BadInstall("No launching method adequate. Could not find any of ('%s') in the main directory" % "', '".join(self.launcher_alternatives)) args += ['-d'] if self.... |
return os.spawnv(os.P_NOWAIT, args[0], args) > 0 | return os.spawnv(os.P_NOWAIT, executable, args) > 0 | def Launch(self): # First handle the py2app special case methods = [self.py2app_args, self.python_args] for m in methods: args = m() if args: break else: raise BadInstall("No launching method adequate. Could not find any of ('%s') in the main directory" % "', '".join(self.launcher_alternatives)) args += ['-d'] if self.... |
self.id_ = id_ | self.id_ = safe_str(id_) | def __init__(self, id_="", type='bidir', address=""): assert type in ('in', 'out', 'bidir'), "Wrong service type" self.id_ = id_ self.type = type self.address = address self.known = True |
x = cx + dist * math.cos(angle) y = cy + dist * math.sin(angle) | x = self.normalize(cx + dist * math.cos(angle)) y = self.normalize(cy + dist * math.sin(angle)) | def SuggestPosition(self, distance): """ Suggest a random position within a given distance. """ cx, cy = self.origin angle = random.uniform(0.0, 2.0 * math.pi) dist = random.uniform(0.0, distance) x = cx + dist * math.cos(angle) y = cy + dist * math.sin(angle) return x, y |
wx.CallAfter(self._UpdateUI) | self.radio_btn_remote.SetValue(False) self._UpdateUI() | def OnRadioLocal(self, event): # wxGlade: ConnectionTypeDialog.<event_handler> wx.CallAfter(self._UpdateUI) |
wx.CallAfter(self._UpdateUI) | self.radio_btn_local.SetValue(False) self._UpdateUI() | def OnRadioRemote(self, event): # wxGlade: ConnectionTypeDialog.<event_handler> wx.CallAfter(self._UpdateUI) |
x = self.normalize(cx + dist * math.cos(angle)) y = self.normalize(cy + dist * math.sin(angle)) | x = self.unnormalize(cx + dist * math.cos(angle)) y = self.unnormalize(cy + dist * math.sin(angle)) | def SuggestPosition(self, distance): """ Suggest a random position within a given distance. """ cx, cy = self.origin angle = random.uniform(0.0, 2.0 * math.pi) dist = random.uniform(0.0, distance) x = self.normalize(cx + dist * math.cos(angle)) y = self.normalize(cy + dist * math.sin(angle)) return x, y |
if not self.locale.Init2(): | if not self.locale.Init2() and wx.Platform != '__WXMSW__': | def InitWx(self): """ Initialize some basic wxWidgets stuff, including localization. """ import locale as system_locale wx.InitAllImageHandlers() self.locale = wx.Locale() if not self.locale.Init2(): print "Error: failed to initialize wx.Locale!" print "If you are under Linux, check the LC_MESSAGES or LANG environment ... |
print "If you are under Linux, check the LC_MESSAGES or LANG environment variable is properly set." | print "If you are under Linux or Un*x, check the LC_MESSAGES or LANG environment variable is properly set." | def InitWx(self): """ Initialize some basic wxWidgets stuff, including localization. """ import locale as system_locale wx.InitAllImageHandlers() self.locale = wx.Locale() if not self.locale.Init2(): print "Error: failed to initialize wx.Locale!" print "If you are under Linux, check the LC_MESSAGES or LANG environment ... |
fx = self.normalize((x * cs - y * sn) / self.ratio) + cx fy = self.normalize((y * cs + x * sn) / self.ratio) + cy | fx = (x * cs - y * sn) / self.ratio + cx fy = (y * cs + x * sn) / self.ratio + cy | def MoveToPixels(self, position, strafe=False): """ Move to a position in physical (pixel) coordinates. """ w, h = self._WindowSize() cx, cy = self.center x = float(position[0]) - w / 2 y = h / 2 - float(position[1]) cs = math.cos(-self.angle) sn = math.sin(-self.angle) fx = self.normalize((x * cs - y * sn) / self.rati... |
self.center = position self.future_center = position, position | x = self.normalize(position[0]) y = self.normalize(position[1]) self.center = x, y self.future_center = (x, y), (x, y) | def _SetCenter(self, position): """ Immediately set the viewport center in logical coordinates. """ self.center = position self.future_center = position, position |
self.future_center = position, self.center self.center_glider.Reset(0.0, 1.0) | epsilon = 2**-15 x, y = position fx, fy = self.future_center[0] if abs(self.normalize(x - fx)) > abs(epsilon * fx) or abs(self.normalize(y - fy)) > abs(epsilon * fy): cx = self.normalize(self.center[0]) cy = self.normalize(self.center[1]) x = self.normalize(x - cx) + cx y = self.normalize(y - cy) + cy self.future_cente... | def _SetFutureCenter(self, position): """ Set the viewport center in logical coordinates. """ self.future_center = position, self.center self.center_glider.Reset(0.0, 1.0) |
self.servers = [(socket.gethostbyname(host), port) for host, port in servers] | self.servers = [(host, port) for host, port in servers] | def __init__(self, servers=DefaultServers, *args, **kwargs): # Potential STUN servers self._potentialStuns = {} # See flowchart ascii art at bottom of file. self._stunState = '1' self._finished = False self._altStunAddress = None self.externalAddress = None self.localAddress = None self.expectedTID = None self.oldTIDs ... |
for repo in files.get_repositories(): | for repo in files: | def fill_shared_files(self, (peer_id, files)): """connect shared files with shared files""" if not isinstance(files, SharedFiles): raise TypeError("data expected as SharedFiles") assert self.has_peer(peer_id), "no profile for %s in %s"\ % (peer_id, self.__class__) peer_desc = self.get_peer(peer_id) # set repositories f... |
package = path.replace('/', '.') | package = path.replace(sep, '.') | def get_dynamic_modules(): """ Returns dynamic modules to be bundled by default. """ print "enumerating dynamic modules" includes = [] service_dir = 'solipsis/services' # 1. Dynamically-loaded service plugins for filename in os.listdir(service_dir): path = os.path.join(service_dir, filename) if os.path.isdir(path) and... |
for dir in extension_dirs: for path in glob.glob(os.path.join(dir, '*.py')): | for dir_ in extension_dirs: dir_ = os.path.normpath(dir_) for path in glob.glob(os.path.join(dir_, '*.py')): | def get_dynamic_modules(): """ Returns dynamic modules to be bundled by default. """ print "enumerating dynamic modules" includes = [] service_dir = 'solipsis/services' # 1. Dynamically-loaded service plugins for filename in os.listdir(service_dir): path = os.path.join(service_dir, filename) if os.path.isdir(path) and... |
module = path.replace('/', '.')[:-3] | module = path.replace(sep, '.')[:-3] | def get_dynamic_modules(): """ Returns dynamic modules to be bundled by default. """ print "enumerating dynamic modules" includes = [] service_dir = 'solipsis/services' # 1. Dynamically-loaded service plugins for filename in os.listdir(service_dir): path = os.path.join(service_dir, filename) if os.path.isdir(path) and... |
if dirpath.startswith('./dist/') or dirpath.startswith('./build/') or '/.svn' in dirpath: | if dirpath.startswith('.' + sep + 'dist' + sep) or \ dirpath.startswith('.' + sep + 'build' + sep) or \ (sep + '.svn') in dirpath: | def get_data_files(): """ Returns all resource files and dirs. """ print "enumerating resources" data_files = [] # Please note: base directories of service plugins will be automatically # included as long as they contain some localization data (.mo files) extensions = [ 'xrc', 'mo', 'png', 'gif', 'jpg', 'jpeg', 'txt',... |
self.locale.Init2() | if not self.locale.Init2(): print "Error: failed to initialize wx.Locale!" print "If you are under Linux, check the LC_MESSAGES or LANG environment variable is properly set." sys.exit(1) | def InitWx(self): """ Initialize some basic wxWidgets stuff, including localization. """ import locale as system_locale wx.InitAllImageHandlers() self.locale = wx.Locale() self.locale.Init2() try: translation_dir = self.params.translation_dir except AttributeError: print "No translation dir specified" pass else: self.l... |
if self._Validate(): self.button_ok.Enable() else: self.button_ok.Disable() | self._ValidateUI() | def _UpdateUI(self): # Pseudo self.text_ctrl_pseudo.SetValue(self.config_data.pseudo) # Display proper textual information about connection type if self.config_data.connection_type == 'local': conntype_text = _("A dedicated Solipsis node will be launched.") else: conntype_text = _("A remote Solipsis node will be contac... |
return os.spawnv(os.P_NOWAIT, prog_name, args) > 0 | return os.spawnv(os.P_NOWAIT, args[0], args) > 0 | def Launch(self): prog_name = os.path.normcase('.' + os.sep + self.launcher_name) # If the program is a Python script, we try to keep the same executable # as currently (useful on MacOS X with py2app) if os.path.exists(sys.executable) and re.match(r'.*\.py[cow]?$', prog_name, re.IGNORECASE): args = [sys.executable, pro... |
keepalive = peer.hold_time / 3.0 | keepalive = self._HoldTime(peer.address) / 3.0 | def msg_send_timeout(): message = protocol.Message('HEARTBEAT') message.args.id_ = self.node.id_ self.SendToPeer(peer, message) |
self.dc_peer_timeout[peer.id_] = self.caller.CallPeriodically(peer.hold_time, msg_receive_timeout) | self.dc_peer_timeout[peer.id_] = self.caller.CallPeriodically(self._HoldTime(peer.address), msg_receive_timeout) | def msg_send_timeout(): message = protocol.Message('HEARTBEAT') message.args.id_ = self.node.id_ self.SendToPeer(peer, message) |
self.language_value = wx.ComboBox(self, -1, choices=["", _("French"), _("English")], style=wx.CB_DROPDOWN|wx.CB_SIMPLE|wx.CB_SORT) | self.language_value = wx.ComboBox(self, -1, choices=["", _("French"), _("English")], style=wx.CB_DROPDOWN|wx.CB_SIMPLE|wx.CB_READONLY) | def __init__(self, *args, **kwds): # begin wxGlade: PersonalPanel.__init__ kwds["style"] = wx.TAB_TRAVERSAL wx.Panel.__init__(self, *args, **kwds) self.address_sizer_staticbox = wx.StaticBox(self, -1, _("Address")) self.description_sizer_staticbox = wx.StaticBox(self, -1, _("Description")) self.identity_sizer_staticbox... |
x, y = evt.GetPositionTuple() changed, id_ = self.viewport.Hover((x, y)) if changed and id_: self.statusbar.SetTemp(self.world.GetPeer(id_).pseudo) elif changed and not id_: self.statusbar.Reset() | self._HandleMouseMovement(evt) | def _HoverViewport(self, evt): """ Called on mouse movement in the viewport. """ if self._CheckNodeProxy(False): x, y = evt.GetPositionTuple() changed, id_ = self.viewport.Hover((x, y)) if changed and id_: self.statusbar.SetTemp(self.world.GetPeer(id_).pseudo) elif changed and not id_: self.statusbar.Reset() evt.Skip() |
if o == ('--maxnodes','-x'): maxnodes = string.atoi(v) if o == ('--maxerror','-e'): maxerror = string.atof(v) if o == ('--factor','-f'): factor = string.atof(v) | if o in ('--maxnodes','-x'): maxnodes = string.atoi(v) if o in ('--maxerror','-e'): maxerror = string.atof(v) if o in ('--factor','-f'): factor = string.atof(v) | def main(): import getopt opts,args = getopt.getopt(sys.argv[1:],'m:x:e:f:hv',['minnodes','maxnodes','maxerror','factor','help','version']) if len(args) > 1: usage() sys.exit(1) minnodes = 50 maxnodes = 600 maxerror = 50.0 factor = 1.0/30.0 infile = None quiet = 0 for o,v in opts: if o in ('--help','-h'): usage() sys.e... |
print "error = %d"%(error) | print " error = %.2f"%(error) | def run_terra(thresh, minnodes, count, factor, objName, pgmName): print command = "terra -e %f -n %d -p %d -h %f -o %s obj %s"%(thresh, minnodes, count, factor, objName, pgmName) print command npts = -1 error = -99999.9 r,w,e = os.popen3(command) for line in e.readlines(): line = line.lstrip() if line.startswith("point... |
maxerror = 5.0 | maxerror = 50.0 | def main(): import getopt opts,args = getopt.getopt(sys.argv[1:],'m:x:e:f:hv',['minnodes','maxnodes','maxerror','factor','help','version']) if len(args) > 1: usage() sys.exit(1) minnodes = 50 maxnodes = 600 maxerror = 5.0 factor = 1.0/30.0 infile = None quiet = 0 for o,v in opts: if o in ('--help','-h'): usage() sys.ex... |
if path.getmtime(gzName) > path.getmtime(fname): | if os.path.getmtime(gzName) > os.path.getmtime(fname): | def terra_fit(fname, thresh=1, count=1000, factor=1.0/30.0, minnodes=50): """ """ from string import atoi print print "Processing %s"%(fname) print "\tmaxerror %f maxnodes %d minnodes %d"%(thresh, count, minnodes) if not os.path.exists(fname): raise IOError, (2, 'No such file or directory: ' + fname) return # need t... |
def main(args=None, options=None, cmdclass=None): | def main(args=None, options=None, cmdclass=ZDCmd): | def main(args=None, options=None, cmdclass=None): if options is None: options = ZDCtlOptions() options.realize(args) c = cmdclass(options) if options.args: c.onecmd(" ".join(options.args)) if options.interactive: try: import readline except ImportError: pass print "program:", " ".join(options.program) c.do_status() c.c... |
shutil.rmtree(tmp) | for fname in os.listdir('.'): try: os.unlink(os.path.join(tmp, fname)) except os.error: pass os.rmdir(tmp) | def testRunIgnoresParentSignals(self): # Spawn a process which will in turn spawn a zdrun process. # We make sure that the zdrun process is still running even if # its parent process receives an interrupt signal (it should # not be passed to zdrun). tmp = tempfile.mkdtemp() zdrun_socket = os.path.join(tmp, 'testsock') ... |
self.add("schemafile", short="S:", default="schema.xml", | self.add("schemafile", short="S:", long="schema=", default="schema.xml", | def __init__(self): RunnerOptions.__init__(self) self.add("schemafile", short="S:", default="schema.xml", handler=self.set_schemafile) |
posix.close(0); sys.stdin = open('/dev/null') posix.close(1); sys.stdout = open('/dev/null','w') posix.close(2); sys.stderr = open('/dev/null','w') posix.setsid() | os.close(0); sys.stdin = open('/dev/null') os.close(1); sys.stdout = open('/dev/null','w') os.close(2); sys.stderr = open('/dev/null','w') os.setsid() | def run(argv, pidfile=''): if os.environ.has_key('ZDAEMON_MANAGED'): # We're the child at this point. return os.environ['ZDAEMON_MANAGED']='TRUE' if not os.environ.has_key('Z_DEBUG_MODE'): # Detach from terminal pid = os.fork() if pid: sys.exit(0) posix.close(0); sys.stdin = open('/dev/null') posix.close(1); sys.std... |
args += self._get_override("-m", "umask", oct(self.options.umask)) | if self.options.umask: args += self._get_override("-m", "umask", oct(self.options.umask)) | def do_start(self, arg): self.get_status() if not self.zd_up: args = [ self.options.python, self.options.zdrun, ] args += self._get_override("-S", "schemafile") args += self._get_override("-C", "configfile") args += self._get_override("-b", "backofflimit") args += self._get_override("-d", "daemon", flag=1) args += self... |
print "umask: ", oct(self.options.umask) | umask = self.options.umask if not umask: umask = os.umask(0777) os.umask(umask) print "umask: ", oct(umask) | def show_options(self): print "zdctl/zdrun options:" print "schemafile: ", repr(self.options.schemafile) print "configfile: ", repr(self.options.configfile) print "interactive: ", repr(self.options.interactive) print "default_to_interactive:", print repr(self.options.default_to_interactive) print "zd... |
else: flag = os.P_NOWAIT | def do_start(self, arg): self.get_status() if not self.zd_up: args = [ self.options.python, self.options.zdrun, ] args += self._get_override("-S", "schemafile") args += self._get_override("-C", "configfile") args += self._get_override("-b", "backofflimit") args += self._get_override("-d", "daemon", flag=1) args += self... | |
self.zdstatus() def zdcommand(self, command): """Send a command to the zdaemon server and return the response. | self.do_status() if self.zd_status: m = re.search("(?m)^args=(.*)$", self.zd_status) if m: s = m.group(1) args = eval(s, {"__builtins__": {}}) if args != self.options.program: print "WARNING! zdaemon is managing a different program!" print "our program =", self.options.program print "daemon's args =", args def send_... | def __init__(self, options): self.options = options cmd.Cmd.__init__(self) self.zdstatus() |
sock.send(command + "\n") | sock.send(action + "\n") | def zdcommand(self, command): """Send a command to the zdaemon server and return the response. |
def zdstatus(self): | def get_status(self): | def zdstatus(self): self.zd_up = 0 self.zd_pid = 0 self.zd_status = None resp = self.zdcommand("status") if not resp: return m = re.search("(?m)^application=(\d+)$", resp) if not m: return self.zd_up = 1 self.zd_pid = int(m.group(1)) self.zd_status = resp |
resp = self.zdcommand("status") | resp = self.send_action("status") | def zdstatus(self): self.zd_up = 0 self.zd_pid = 0 self.zd_status = None resp = self.zdcommand("status") if not resp: return m = re.search("(?m)^application=(\d+)$", resp) if not m: return self.zd_up = 1 self.zd_pid = int(m.group(1)) self.zd_status = resp |
command = [self.options.python, self.options.zdaemon, "-d", "-s", self.options.sockname, self.options.program] + self.options.program_arguments print command os.spawnvp(os.P_WAIT, command[0], command) else: self.zdcommand("start") self.zdstatus() while not self.zd_pid: sys.stdout.write(". ") sys.stdout.flush() time.sle... | args = [ self.options.python, self.options.zdaemon, "-b", str(self.options.backofflimit), "-d", "-s", self.options.sockname, "-x", ",".join(map(str, self.options.exitcodes)), "-z", self.options.zdirectory, ] if self.options.forever: args.append("-f") if self.options.user: argss.extend(["-u", str(self.options.user)]) ar... | def do_start(self, arg): if not self.zd_up: command = [self.options.python, self.options.zdaemon, "-d", "-s", self.options.sockname, self.options.program] + self.options.program_arguments print command os.spawnvp(os.P_WAIT, command[0], command) else: self.zdcommand("start") self.zdstatus() while not self.zd_pid: sys.st... |
self.zdstatus() | self.get_status() | def do_stop(self, arg): self.zdstatus() if not self.zd_up: print "daemon manager not running" elif not self.zd_pid: print "daemon not running" else: self.zdcommand("stop") self.zdstatus() while self.zd_pid: sys.stdout.write(". ") sys.stdout.flush() time.sleep(1) self.zdstatus() print "daemon stopped" |
print "daemon not running" else: self.zdcommand("stop") self.zdstatus() while self.zd_pid: sys.stdout.write(". ") sys.stdout.flush() time.sleep(1) self.zdstatus() print "daemon stopped" | print "program not running" else: self.send_action("stop") self.awhile(lambda: not self.zd_pid, "program stopped") def help_stop(self): print "stop -- Stop the daemon process." print " If it is not running, do nothing." | def do_stop(self, arg): self.zdstatus() if not self.zd_up: print "daemon manager not running" elif not self.zd_pid: print "daemon not running" else: self.zdcommand("stop") self.zdstatus() while self.zd_pid: sys.stdout.write(". ") sys.stdout.flush() time.sleep(1) self.zdstatus() print "daemon stopped" |
self.zdstatus() | self.get_status() | def do_restart(self, arg): self.zdstatus() pid = self.zd_pid if not pid: self.do_start(arg) else: self.zdcommand("restart") self.zdstatus() while self.zd_pid in (0, pid): sys.stdout.write(". ") sys.stdout.flush() time.sleep(1) self.zdstatus() print "daemon restarted, pid=%d" % self.zd_pid |
self.zdcommand("restart") self.zdstatus() while self.zd_pid in (0, pid): sys.stdout.write(". ") sys.stdout.flush() time.sleep(1) self.zdstatus() print "daemon restarted, pid=%d" % self.zd_pid def do_status(self, arg): self.zdstatus() | self.send_action("restart") self.awhile(lambda: self.zd_pid not in (0, pid), "program restarted, pid=%(zd_pid)d") def help_restart(self): print "restart -- Stop and then start the daemon process." def do_kill(self, arg): if not arg: sig = signal.SIGTERM else: try: sig = int(arg) except: print "invalid signal number",... | def do_restart(self, arg): self.zdstatus() pid = self.zd_pid if not pid: self.do_start(arg) else: self.zdcommand("restart") self.zdstatus() while self.zd_pid in (0, pid): sys.stdout.write(". ") sys.stdout.flush() time.sleep(1) self.zdstatus() print "daemon restarted, pid=%d" % self.zd_pid |
print "daemon not running" else: print "daemon running: pid=%d" % self.zd_pid | print "daemon manager running; program not running" else: print "program running; pid=%d" % self.zd_pid if arg == "-l" and self.zd_status: print self.zd_status def help_status(self): print "status [-l] -- Print status for the daemon process." print " With -l, show raw status output as well." | def do_status(self, arg): self.zdstatus() if not self.zd_up: print "daemon manager not running" elif not self.zd_pid: print "daemon not running" else: print "daemon running: pid=%d" % self.zd_pid |
self.zdstatus() | self.get_status() | def do_quit(self, arg): self.zdstatus() if not self.zd_pid: self.zdcommand("exit") self.zdstatus() while self.zd_up: sys.stdout.write(". ") sys.stdout.flush() time.sleep(1) self.zdstatus() print "daemon not running; daemon manager stopped" else: print "daemon and daemon manager still running" return 1 |
self.zdcommand("exit") self.zdstatus() while self.zd_up: sys.stdout.write(". ") sys.stdout.flush() time.sleep(1) self.zdstatus() print "daemon not running; daemon manager stopped" else: print "daemon and daemon manager still running" | print "program not running; stopping daemon manager" self.send_action("exit") self.awhile(lambda: not self.zd_up, "daemon manager stopped") else: print "program and daemon manager still running" | def do_quit(self, arg): self.zdstatus() if not self.zd_pid: self.zdcommand("exit") self.zdstatus() while self.zd_up: sys.stdout.write(". ") sys.stdout.flush() time.sleep(1) self.zdstatus() print "daemon not running; daemon manager stopped" else: print "daemon and daemon manager still running" return 1 |
class ZDOptions: python = sys.executable if __name__ == "__main__": _file = __file__ else: _file = sys.argv[0] _file = os.path.normpath(os.path.abspath(_file)) _dir = os.path.dirname(_file) zdaemon = os.path.join(_dir, "zdaemon.py") backofflimit = 10 isclient = 0 daemon = 0 forever = 0 sockname = "zdsock" exitcodes =... | def help_quit(self): print "quit -- Exit the zdctl shell." print " If the program is not running, stop the daemon manager." | def do_quit(self, arg): self.zdstatus() if not self.zd_pid: self.zdcommand("exit") self.zdstatus() while self.zd_up: sys.stdout.write(". ") sys.stdout.flush() time.sleep(1) self.zdstatus() print "daemon not running; daemon manager stopped" else: print "daemon and daemon manager still running" return 1 |
p,s = wait(pid) | p, s = wait(pid) log_pid(p, s) | def run(argv, pidfile=''): if os.environ.has_key('ZDAEMON_MANAGED'): # We're being run by the child. return os.environ['ZDAEMON_MANAGED']='TRUE' if not os.environ.has_key('Z_DEBUG_MODE'): detach() # detach from the controlling terminal while 1: try: pid = os.fork() if pid: # We're the parent (the daemon process) # p... |
log_pid(p, s) | def run(argv, pidfile=''): if os.environ.has_key('ZDAEMON_MANAGED'): # We're being run by the child. return os.environ['ZDAEMON_MANAGED']='TRUE' if not os.environ.has_key('Z_DEBUG_MODE'): detach() # detach from the controlling terminal while 1: try: pid = os.fork() if pid: # We're the parent (the daemon process) # p... | |
self.governor() | def reportstatus(self): pid, sts = self.waitstatus self.waitstatus = None if pid == self.appid: self.appid = 0 self.killing = 0 self.delay = 0 self.governor() if os.WIFEXITED(sts): es = os.WEXITSTATUS(sts) msg = "pid %d: exit status %s" % (pid, es) if es in self.exitcodes: msg = msg + "; exiting" self.info(msg) self.ex... | |
iscore = s & 0x80 | iscore = sts & 0x80 | def reportstatus(self): pid, sts = self.waitstatus self.waitstatus = None if pid == self.appid: self.appid = 0 self.killing = 0 self.delay = 0 self.governor() if os.WIFEXITED(sts): es = os.WEXITSTATUS(sts) msg = "pid %d: exit status %s" % (pid, es) if es in self.exitcodes: msg = msg + "; exiting" self.info(msg) self.ex... |
args = [opt] if not flag: | if flag: if value: args = [opt] else: args = [] else: | def _get_override(self, opt, name, svalue=None, flag=0): value = getattr(self.options, name) if value is None: return [] configroot = self.options.configroot if configroot is not None: for n, cn in self.options.names_list: if n == name and cn: v = configroot for p in cn.split("."): v = getattr(v, p, None) if v is None:... |
args.append(svalue) | args = [opt, svalue] | def _get_override(self, opt, name, svalue=None, flag=0): value = getattr(self.options, name) if value is None: return [] configroot = self.options.configroot if configroot is not None: for n, cn in self.options.names_list: if n == name and cn: v = configroot for p in cn.split("."): v = getattr(v, p, None) if v is None:... |
self.add("schemafile", short="S:", default="schema.xml", | self.add("schemafile", short="S:", long="schema=", default="schema.xml", | def __init__(self): RunnerOptions.__init__(self) self.add("schemafile", short="S:", default="schema.xml", handler=self.set_schemafile) self.add("interactive", None, "i", "interactive", flag=1) self.add("default_to_interactive", "runner.default_to_interactive", default=1) self.add("program", "runner.program", "p:", "pro... |
print "program:", " ".join(options.program) | def __init__(self, options): print "program:", " ".join(options.program) self.options = options cmd.Cmd.__init__(self) self.do_status() if self.zd_status: m = re.search("(?m)^args=(.*)$", self.zd_status) if m: s = m.group(1) args = eval(s, {"__builtins__": {}}) if args != self.options.program: print "WARNING! zdaemon i... | |
self.do_status() | self.get_status() | def __init__(self, options): print "program:", " ".join(options.program) self.options = options cmd.Cmd.__init__(self) self.do_status() if self.zd_status: m = re.search("(?m)^args=(.*)$", self.zd_status) if m: s = m.group(1) args = eval(s, {"__builtins__": {}}) if args != self.options.program: print "WARNING! zdaemon i... |
print "response =", `response` | def send_action(self, action): """Send an action to the zdaemon server and return the response. | |
print args | def do_start(self, arg): if not self.zd_up: args = [ self.options.python, self.options.zdaemon, "-b", str(self.options.backofflimit), "-d", "-s", self.options.sockname, "-x", ",".join(map(str, self.options.exitcodes)), "-z", self.options.zdirectory, ] if self.options.forever: args.append("-f") if self.options.user: arg... | |
if not self.zd_pid: | if not self.zd_up: print "daemon manager not running" elif not self.zd_pid: | def do_quit(self, arg): self.get_status() if not self.zd_pid: print "daemon process not running; stopping daemon manager" self.send_action("exit") self.awhile(lambda: not self.zd_up, "daemon manager stopped") else: print "daemon process and daemon manager still running" return 1 |
print "\t--xinclude : do XInclude processing on document intput" | print "\t--xinclude : do XInclude processing on document input" | def usage(name = 'pyxsltproc'): print "Usage: %s [options] stylesheet file [file ...]" % (name) print "a reimplementation of xsltproc(1) on top of libxslt-python" print " Options:" print "\t--version or -V: show the version of libxml and libxslt used" print "\t--verbose or -v: show logs of what's happening" print "\t... |
if debug: print "=> ", token | def token(self): global ignored_words | |
import libxml2 | def insertComment(name, title, value, id): global nbcomments ids[name] = id indexString(name, value) if functions.has_key(name): functions[name][2] = value return "function" elif typedefs.has_key(name): typedefs[name] = value return "typedef" elif macros.has_key(name): macros[name][1] = value return "macro" elif varia... | |
import xmllib try: import sgmlop except ImportError: sgmlop = None debug = 0 if sgmlop: class FastParser: """sgmlop based XML parser. this is typically 15x faster than SlowParser...""" def __init__(self, target): self.finish_starttag = target.start self.finish_endtag = target.end self.handle_data = target.data ... | def analyzeXMLDescriptionRow(doc, desc, id, row): if doc == None or desc == None or id == None or row == None: return ctxt = doc.xpathNewContext() ctxt.setContextNode(row) param = ctxt.xpathEval("entry[1]/parameter") entries = ctxt.xpathEval("entry") if param == []: is_param = 0 name = None else: name = param[0].conten... | def insertComment(name, title, value, id): global nbcomments ids[name] = id indexString(name, value) if functions.has_key(name): functions[name][2] = value return "function" elif typedefs.has_key(name): typedefs[name] = value return "typedef" elif macros.has_key(name): macros[name][1] = value return "macro" elif varia... |
f = open("xml/" + filename, 'r') except IOError, msg: print file, ":", msg | doc = libxml2.parseFile("xml/" + filename) analyzeXMLDoc(doc) doc.freeDoc() xmlfiles = xmlfiles + 1 except: print "failed to parse XML description %s" % ("xml/" + filename) | def end(self, tag): if debug: print "end %s" % tag |
data = f.read() (parser, target) = getparser() parser.feed(data) parser.close() xmlfiles = xmlfiles + 1 | def end(self, tag): if debug: print "end %s" % tag | |
ids = dict.functions.keys() + dict.variables.keys() + \ | ids = uniq(dict.functions.keys() + dict.variables.keys() + \ | def serialize_xrefs_files(self, output): headers = self.headers.keys() headers.sort() for file in headers: module = self.modulename_file(file) output.write(" <file name='%s'>\n" % (module)) dict = self.headers[file] ids = dict.functions.keys() + dict.variables.keys() + \ |
dict.structs.keys() + dict.enums.keys() | dict.structs.keys() + dict.enums.keys()) | def serialize_xrefs_files(self, output): headers = self.headers.keys() headers.sort() for file in headers: module = self.modulename_file(file) output.write(" <file name='%s'>\n" % (module)) dict = self.headers[file] ids = dict.functions.keys() + dict.variables.keys() + \ |
for id in uniq(ids): | for id in ids: | def serialize_xrefs_files(self, output): headers = self.headers.keys() headers.sort() for file in headers: module = self.modulename_file(file) output.write(" <file name='%s'>\n" % (module)) dict = self.headers[file] ids = dict.functions.keys() + dict.variables.keys() + \ |
output.write(" <ref name='%s'/>\n" % (id)) | if id != pid: output.write(" <ref name='%s'/>\n" % (id)) pid = id | def serialize_xrefs_functions(self, output): funcs = {} |
for token in index[id]: | for token in tokens: | def serialize_xrefs_index(self, output): index = self.xref |
c_call = "\n %s->%s = %s;\n" % (args[0][0], args[1][0], args[1][0]) | if args[1][1] == "char *" or args[1][1] == "xmlChar *": c_call = "\n if (%s->%s != NULL) xmlFree(%s->%s);\n" % ( args[0][0], args[1][0], args[0][0], args[1][0]) c_call = c_call + " %s->%s = xmlStrdup((const xmlChar *)%s);\n" % (args[0][0], args[1][0], args[1][0]) else: c_call = "\n %s->%s = %s;\n" % (args[0][0... | def print_function_wrapper(name, output, export, include): global py_types global unknown_types global functions global skipped_modules try: (desc, ret, args, file) = functions[name] except: print "failed to get function %s infos" return if skipped_modules.has_key(file): return 0 if skip_function(name) == 1: return 0... |
c_call = "\n c_retval = %s(%s);\n" % (name, c_call); | if file == "python_accessor" and ret[2] != None: c_call = "\n c_retval = %s->%s;\n" % (args[0][0], ret[2]) else: c_call = "\n c_retval = %s(%s);\n" % (name, c_call); | def print_function_wrapper(name, output, export, include): global py_types global unknown_types global functions global skipped_modules try: (desc, ret, args, file) = functions[name] except: print "failed to get function %s infos" return if skipped_modules.has_key(file): return 0 if skip_function(name) == 1: return 0... |
export.write(" { \"%s\", libxslt_%s, METH_VARARGS, NULL },\n" % (name, name)) | export.write(" { (char *)\"%s\", libxslt_%s, METH_VARARGS, NULL },\n" % (name, name)) | def print_function_wrapper(name, output, export, include): global py_types global unknown_types global functions global skipped_modules try: (desc, ret, args, file) = functions[name] except: print "failed to get function %s infos" return if skipped_modules.has_key(file): return 0 if skip_function(name) == 1: return 0... |
output.write("libxslt_%s(PyObject *self, PyObject *args) {\n" % (name)) | output.write("libxslt_%s(ATTRIBUTE_UNUSED PyObject *self," % (name)) if format == "": output.write("ATTRIBUTE_UNUSED ") output.write(" PyObject *args) {\n") | def print_function_wrapper(name, output, export, include): global py_types global unknown_types global functions global skipped_modules try: (desc, ret, args, file) = functions[name] except: print "failed to get function %s infos" return if skipped_modules.has_key(file): return 0 if skip_function(name) == 1: return 0... |
output.write("\n if (!PyArg_ParseTuple(args, \"%s\"%s))\n" % | output.write("\n if (!PyArg_ParseTuple(args, (char *)\"%s\"%s))\n" % | def print_function_wrapper(name, output, export, include): global py_types global unknown_types global functions global skipped_modules try: (desc, ret, args, file) = functions[name] except: print "failed to get function %s infos" return if skipped_modules.has_key(file): return 0 if skip_function(name) == 1: return 0... |
if token[0] == "sep" and token[1] == "{": | elif token[0] == "sep" and token[1] == "{": | def parseGlobal(self, token): static = 0 if token[1] == 'extern': token = self.token() if token == None: return token if token[0] == 'string': if token[1] == 'C': token = self.token() if token == None: |
def escape(raw): raw = string.replace(raw, '&', '&') raw = string.replace(raw, '<', '<') raw = string.replace(raw, '>', '>') raw = string.replace(raw, "'", ''') raw = string.replace(raw, '"', '"') return raw class identifier: def __init__(self, name, module=None, type=None, info=None, extra=None): ... | def escape(raw): raw = string.replace(raw, '&', '&') raw = string.replace(raw, '<', '<') raw = string.replace(raw, '>', '>') raw = string.replace(raw, "'", ''') raw = string.replace(raw, '"', '"') return raw | |
def __init__(self, filename, idx = None): self.filename = filename if len(filename) > 2 and filename[-2:] == '.h': self.is_header = 1 else: self.is_header = 0 self.input = open(filename) self.lexer = CLexer(self.input) if idx == None: self.index = index() else: self.index = idx self.top_comment = "" self.last_comment =... | def __init__(self, filename, idx = None): self.filename = filename if len(filename) > 2 and filename[-2:] == '.h': self.is_header = 1 else: self.is_header = 0 self.input = open(filename) self.lexer = CLexer(self.input) if idx == None: self.index = index() else: self.index = idx self.top_comment = "" self.last_comment =... | def token(self): while self.tokens == []: if self.line == "": |
def mergeFunctionComment(self, name, description, quiet = 0): if name == 'main': quiet = 1 if name[0:2] == '__': quiet = 1 (ret, args) = description desc = "" retdesc = "" if self.comment == None: if not quiet: print "Missing comment for function %s" % (name) return(((ret[0], retdesc), args, desc)) if self.comment[0]... | def mergeFunctionComment(self, name, description, quiet = 0): if name == 'main': quiet = 1 if name[0:2] == '__': quiet = 1 (ret, args) = description desc = "" retdesc = "" if self.comment == None: if not quiet: print "Missing comment for function %s" % (name) return(((ret[0], retdesc), args, desc)) if self.comment[0]... | def mergeFunctionComment(self, name, description, quiet = 0): if name == 'main': quiet = 1 if name[0:2] == '__': quiet = 1 |
i = 0 while i < nbargs: if args[i][2] == None and args[i][0] != "void" and args[i][1] != None: print "Function comment for %s lack description of arg %s" % (name, args[i][1]) i = i + 1 if retdesc == "" and ret[0] != "void": print "Function comment for %s lack description of return value" % (name) if desc == "": print "... | i = 0 while i < nbargs: if args[i][2] == None and args[i][0] != "void" and args[i][1] != None: print "Function comment for %s lack description of arg %s" % (name, args[i][1]) i = i + 1 if retdesc == "" and ret[0] != "void": print "Function comment for %s lack description of return value" % (name) if desc == "": print "... | def mergeFunctionComment(self, name, description, quiet = 0): if name == 'main': quiet = 1 if name[0:2] == '__': quiet = 1 |
name = token[1] lst = [] token = self.lexer.token() while token != None and token[0] == 'preproc' and \ token[1][0] != ' lst.append(token[1]) token = self.lexer.token() try: name = string.split(name, '(') [0] except: pass info = self.parseMacroComment(name, not self.is_header) self.index.add(name, self.filename, not se... | name = token[1] lst = [] token = self.lexer.token() while token != None and token[0] == 'preproc' and \ token[1][0] != ' lst.append(token[1]) token = self.lexer.token() try: name = string.split(name, '(') [0] except: pass info = self.parseMacroComment(name, not self.is_header) self.index_add(name, self.filename, not se... | def parsePreproc(self, token): name = token[1] |
while token != None: if token[0] == "name": name = token[1] signature = self.signature if signature != None: type = string.split(type, '(')[0] d = self.mergeFunctionComment(name, ((type, None), signature), 1) self.index.add(name, self.filename, not self.is_header, | while token != None: if token[0] == "name": name = token[1] signature = self.signature if signature != None: type = string.split(type, '(')[0] d = self.mergeFunctionComment(name, ((type, None), signature), 1) self.index_add(name, self.filename, not self.is_header, | #self.debug("end typedef type", token) |
else: if base_type == "struct": self.index.add(name, self.filename, not self.is_header, | else: if base_type == "struct": self.index_add(name, self.filename, not self.is_header, | #self.debug("end typedef type", token) |
base_type = "struct " + name else: self.index.add(name, self.filename, not self.is_header, | base_type = "struct " + name else: self.index_add(name, self.filename, not self.is_header, | #self.debug("end typedef type", token) |
def parseBlock(self, token): while token != None: if token[0] == "sep" and token[1] == "{": token = self.token() token = self.parseBlock(token) elif token[0] == "sep" and token[1] == "}": self.comment = None token = self.token() return token else: token = self.token() return token | def parseBlock(self, token): while token != None: if token[0] == "sep" and token[1] == "{": token = self.token() token = self.parseBlock(token) elif token[0] == "sep" and token[1] == "}": self.comment = None token = self.token() return token else: if self.collect_ref == 1: oldtok = token token = self.token() if oldtok[... | def parseBlock(self, token): while token != None: if token[0] == "sep" and token[1] == "{": token = self.token() |
elif token[0] == "name" and token[1] == "struct": if self.type == "": self.type = token[1] else: self.type = self.type + " " + token[1] token = self.token() nametok = None if token[0] == "name": nametok = token token = self.token() if token != None and token[0] == "sep" and token[1] == "{": token = self.token() token =... | elif token[0] == "name" and token[1] == "struct": if self.type == "": self.type = token[1] else: self.type = self.type + " " + token[1] token = self.token() nametok = None if token[0] == "name": nametok = token token = self.token() if token != None and token[0] == "sep" and token[1] == "{": token = self.token() token =... | def parseType(self, token): self.type = "" |
token = self.token() if token[0] == 'sep' and token[1] == '{': token = self.token() token = self.parseBlock(token) else: self.comment = None while token != None and (token[0] != "sep" or \ (token[1] != ';' and token[1] != ',')): token = self.token() self.comment = None if token == None or token[0] != "sep" or (token[1]... | token = self.token() if token[0] == 'sep' and token[1] == '{': token = self.token() token = self.parseBlock(token) else: self.comment = None while token != None and (token[0] != "sep" or \ (token[1] != ';' and token[1] != ',')): token = self.token() self.comment = None if token == None or token[0] != "sep" or (token[1]... | def parseGlobal(self, token): static = 0 if token[1] == 'extern': token = self.token() if token == None: return token if token[0] == 'string': if token[1] == 'C': token = self.token() if token == None: |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.