rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
class sorted_dict(_sorted_dict): __slots__ = () def __setitem__(self, key, value): super(sorted_dict, self).__setitem__(key, value) if key not in self._list: self._list.append(key) | def itervalues(self): for i in iter(self._list): yield self[i] | |
print entry_real | def _get_config(self, config, default, *entry_name): entry_real = ('image',) + entry_name print entry_real entry = config.get(entry_real, None) if entry is None: return default print entry configs = entry.get('configs', None) if configs is None: return default print configs return configs | |
print entry | def _get_config(self, config, default, *entry_name): entry_real = ('image',) + entry_name print entry_real entry = config.get(entry_real, None) if entry is None: return default print entry configs = entry.get('configs', None) if configs is None: return default print configs return configs | |
print configs | def _get_config(self, config, default, *entry_name): entry_real = ('image',) + entry_name print entry_real entry = config.get(entry_real, None) if entry is None: return default print entry configs = entry.get('configs', None) if configs is None: return default print configs return configs | |
"[general]\nanon-access = write\n"); | "[general]\nauth-access=write\npassword-db = passwd\n"); | def create_repos(path): """Create a brand-new SVN repository at PATH. If PATH does not yet exist, create it.""" if not(os.path.exists(path)): os.makedirs(path) # this creates all the intermediate dirs, if neccessary opts = ("--bdb-txn-nosync",) if fs_type is not None: opts += ("--fs-type=" + fs_type,) stdout, stderr... |
infile.close() | def run_command(command, error_expected, binary_mode=0, *varargs): """Run COMMAND with VARARGS; return stdout, stderr as lists of lines. If ERROR_EXPECTED is None, any stderr also will be printed.""" args = '' for arg in varargs: # build the command string args = args + ' "' + str(arg) + '"' # Log t... | |
stdout/stderr, you might want to use actions.run_and_verify_svn() or actions.run_and_verify_svn_error().""" | stdout/stderr, you might want to use actions.run_and_verify_svn().""" | def run_svn(error_expected, *varargs): """Run svn with VARARGS; return stdout, stderr as lists of lines. If ERROR_EXPECTED is None, any stderr also will be printed. If you're just checking that something does/doesn't come out of stdout/stderr, you might want to use actions.run_and_verify_svn() or actions.run_and_verif... |
stdout, stderr = run_command(svnadmin_binary, 1, 0, "create", path, "--bdb-txn-nosync", "--fs-type="+fs_type) | opts = ("--bdb-txn-nosync",) if fs_type is not None: opts += ("--fs-type=" + fs_type,) stdout, stderr = run_command(svnadmin_binary, 1, 0, "create", path, *opts) | def create_repos(path): """Create a brand-new SVN repository at PATH. If PATH does not yet exist, create it.""" if not(os.path.exists(path)): os.makedirs(path) # this creates all the intermediate dirs, if neccessary stdout, stderr = run_command(svnadmin_binary, 1, 0, "create", path, "--bdb-txn-nosync", "--fs-type="+... |
file_append(os.path.join(path, "conf", "passwd"), "[users]\njrandom = rayjandom\njconstant = rayjandom\n"); | def create_repos(path): """Create a brand-new SVN repository at PATH. If PATH does not yet exist, create it.""" if not(os.path.exists(path)): os.makedirs(path) # this creates all the intermediate dirs, if neccessary stdout, stderr = run_command(svnadmin_binary, 1, 0, "create", path, "--bdb-txn-nosync", "--fs-type="+... | |
dump_re = re.compile(r'^\* Dumped revision (\d+)\.$') | dump_re = re.compile(r'^\* Dumped revision (\d+)\.\r?$') | def copy_repos(src_path, dst_path, head_revision, ignore_uuid = 0): "Copy the repository SRC_PATH, with head revision HEAD_REVISION, to DST_PATH" # A BDB hot-backup procedure would be more efficient, but that would # require access to the BDB tools, and this doesn't. Print a fake # pipe command so that the displayed ... |
load_re = re.compile(r'^------- Committed revision (\d+) >>>$') | load_re = re.compile(r'^------- Committed revision (\d+) >>>\r?$') | def copy_repos(src_path, dst_path, head_revision, ignore_uuid = 0): "Copy the repository SRC_PATH, with head revision HEAD_REVISION, to DST_PATH" # A BDB hot-backup procedure would be more efficient, but that would # require access to the BDB tools, and this doesn't. Print a fake # pipe command so that the displayed ... |
if run_one_test(n, test_list): | if run_one_test(n, test_list) == 1: | def _internal_run_tests(test_list, testnum=None): exit_code = 0 if testnum is None: for n in range(1, len(test_list)): if run_one_test(n, test_list): exit_code = 1 else: exit_code = run_one_test(testnum, test_list) _cleanup_deferred_test_paths() return exit_code |
opts, args = getopt.getopt(sys.argv[1:], 'v', ['url=', 'fs-type=', 'verbose', 'cleanup']) | opts, args = my_getopt(sys.argv[1:], 'v', ['url=', 'fs-type=', 'verbose', 'cleanup']) | def run_tests(test_list): """Main routine to run all tests in TEST_LIST. NOTE: this function does not return. It does a sys.exit() with the appropriate exit code. """ global test_area_url global fs_type global verbose_mode global cleanup_mode testnum = None # Explicitly set this so that commands that commit but don'... |
stdout/stderr, you might want to use actions.run_and_verify_svn().""" | stdout/stderr, you might want to use actions.run_and_verify_svn() or actions.run_and_verify_svn_error().""" | def run_svn(error_expected, *varargs): """Run svn with VARARGS; return stdout, stderr as lists of lines. If ERROR_EXPECTED is None, any stderr also will be printed. If you're just checking that something does/doesn't come out of stdout/stderr, you might want to use actions.run_and_verify_svn().""" global config_dir re... |
opts = ("--bdb-txn-nosync",) if fs_type is not None: opts += ("--fs-type=" + fs_type,) stdout, stderr = run_command(svnadmin_binary, 1, 0, "create", path, *opts) | stdout, stderr = run_command(svnadmin_binary, 1, 0, "create", path, "--bdb-txn-nosync", "--fs-type="+fs_type) | def create_repos(path): """Create a brand-new SVN repository at PATH. If PATH does not yet exist, create it.""" if not(os.path.exists(path)): os.makedirs(path) # this creates all the intermediate dirs, if neccessary opts = ("--bdb-txn-nosync",) if fs_type is not None: opts += ("--fs-type=" + fs_type,) stdout, stderr... |
def canonize_url(input): "Canonize the url, if the schema is unknown, returns intact input" m = re.match(r"^((file://)|((svn|svn\+ssh|http|https)(://)))", input) if m: schema = m.group(1) return schema + re.sub(r'//*', '/', input[len(schema):]) else: return input | def canonize_url(input): "Canonize the url, if the schema is unknown, returns intact input" m = re.match(r"^((file://)|((svn|svn\+ssh|http|https)(://)))", input) if m: schema = m.group(1) return schema + re.sub(r'//*', '/', input[len(schema):]) else: return input | |
if run_one_test(n, test_list) == 1: | if run_one_test(n, test_list): | def _internal_run_tests(test_list, testnum=None): exit_code = 0 if testnum is None: for n in range(1, len(test_list)): # 1 is the only return code that indicates actual test failure. if run_one_test(n, test_list) == 1: exit_code = 1 else: exit_code = run_one_test(testnum, test_list) _cleanup_deferred_test_paths() ret... |
'6 Dec 04, 02:15 pm' ) | '6 Dec 2004, 02:15 pm' ) | def testAsHumanly(self): self.assertEquals( self._createReference().asHumanly(now=extime.Time.fromStructTime((2004, 12, 6, 14, 15, 16, 0, 0, 0))), '02:15 pm' ) self.assertEquals( self._createReference().asHumanly(tzinfo=self.MST(), now=extime.Time.fromStructTime((2004, 12, 6, 14, 15, 16, 0, 0, 0))), '07:15 am' ) self.a... |
'6 Dec 04, 07:15 am' ) | '6 Dec 2004, 07:15 am' ) | def testAsHumanly(self): self.assertEquals( self._createReference().asHumanly(now=extime.Time.fromStructTime((2004, 12, 6, 14, 15, 16, 0, 0, 0))), '02:15 pm' ) self.assertEquals( self._createReference().asHumanly(tzinfo=self.MST(), now=extime.Time.fromStructTime((2004, 12, 6, 14, 15, 16, 0, 0, 0))), '07:15 am' ) self.a... |
'6 Dec 04, 03:15 pm' ) | '6 Dec 2004, 03:15 pm' ) | def testAsHumanly(self): self.assertEquals( self._createReference().asHumanly(now=extime.Time.fromStructTime((2004, 12, 6, 14, 15, 16, 0, 0, 0))), '02:15 pm' ) self.assertEquals( self._createReference().asHumanly(tzinfo=self.MST(), now=extime.Time.fromStructTime((2004, 12, 6, 14, 15, 16, 0, 0, 0))), '07:15 am' ) self.a... |
for stuff in (None, defer.Deferred()): | def testwith(stuff): | def testStoppedRejectsNewTasks(self): """Test that Cooperators refuse new tasks when they have been stopped. """ for stuff in (None, defer.Deferred()): c = cooperator.Cooperator() c.stop() d = c.coiterate(iter(()), stuff) d.addCallback(self.cbIter) d.addErrback(self.ebIter) self.assertEquals(util.wait(d), self.RESULT) |
self.assertEquals(util.wait(d), self.RESULT) | return d.addCallback(lambda result: self.assertEquals(result, self.RESULT)) return testwith(None).addCallback(lambda ign: testwith(defer.Deferred())) | def testStoppedRejectsNewTasks(self): """Test that Cooperators refuse new tasks when they have been stopped. """ for stuff in (None, defer.Deferred()): c = cooperator.Cooperator() c.stop() d = c.coiterate(iter(()), stuff) d.addCallback(self.cbIter) d.addErrback(self.ebIter) self.assertEquals(util.wait(d), self.RESULT) |
self.assertEquals(util.wait(d), self.RESULT) self.assertEquals(myiter.value, -1) | def doasserts(result): self.assertEquals(result, self.RESULT) self.assertEquals(myiter.value, -1) d.addCallback(doasserts) return d | def myiter(): for myiter.value in range(3): yield myiter.value |
self.assertEquals(util.wait(d), self.RESULT) | return d.addCallback(lambda result: self.assertEquals(result, self.RESULT)) | def stopAndGo(ign): c.stop() outstandingD.callback('arglebargle') |
self.assertRaises(RuntimeError, util.wait, d) | return self.assertFailure(d, RuntimeError) | def myiter(): if 0: yield None else: raise RuntimeError() |
self.assertRaises(RuntimeError, util.wait, d) | return self.assertFailure(d, RuntimeError) | def myiter(): D = defer.Deferred() reactor.callLater(0, D.errback, RuntimeError()) yield D |
self.assertRaises(RuntimeError, util.wait, d) | return self.assertFailure(d, RuntimeError) | def myiter(): yield defer.fail(RuntimeError()) |
util.wait(defer.DeferredList(tasks)) self.assertEquals(tuple(L), sum(zip(*groupsOfThings), ())) | return defer.DeferredList(tasks).addCallback( lambda ign: self.assertEquals(tuple(L), sum(zip(*groupsOfThings), ()))) | def myiter(things): for th in things: L.append(th) yield None |
pass | self.pop_prefix() | def end_component(self): pass |
return s[:i+1], None, s[i+2:] | return s[:i+1], None, None, s[i+2:] | def _split(s): # Return a triple: prefix, name, suffix # - prefix is text that can be used literally in the result (may be '') # - name is a referenced name, or None # - suffix is trailling text that may contain additional references # (may be '' or None) if "$" in s: i = s.find("$") c = s[i+1:i+2] if c == "": raise... |
return s, None, None | return s, None, None, None | def _split(s): # Return a triple: prefix, name, suffix # - prefix is text that can be used literally in the result (may be '') # - name is a referenced name, or None # - suffix is trailling text that may contain additional references # (may be '' or None) if "$" in s: i = s.find("$") c = s[i+1:i+2] if c == "": raise... |
class StartupHandler(Handler): | class StartupHandler(BufferingHandler): """Handler which stores messages in a buffer until later. This is useful at startup before we can know that we can safely write to a configuration-specified handler. | def handle(self, record): pass |
A handler which outputs messages to a stream but also buffers them until they can be flushed to a target handler. Useful at startup before we can know that we can safely write to a config-specified handler. """ def __init__(self, stream=None): Handler.__init__(self) if not stream: stream = sys.stderr self.stream = str... | def handle(self, record): pass | |
def emit(self, record): try: self.buffer.append(record) msg = self.format(record) self.stream.write("%s\n" % msg) self.flush() except: self.handleError(record) | def __init__(self): BufferingHandler.__init__(self, sys.maxint) | def emit(self, record): try: self.buffer.append(record) msg = self.format(record) self.stream.write("%s\n" % msg) self.flush() except: self.handleError(record) |
def flush(self): self.stream.flush() | def shouldFlush(self, record): return False | def flush(self): self.stream.flush() |
s = "section type " + `ci.typename` | s = "section type " + `ci.sectiontype.name` | def finish(self): """Check the constraints of the section and convert to an application object.""" length = len(self.type) values = self._values attrnames = [None] * length for i in range(length): key, ci = self.type[i] attrnames[i] = ci.attribute or key v = values[i] if v is None and ci.name == '+' and not ci.issectio... |
parts = urlparse.urlsplit(url) if not parts[0]: path = os.path.abspath(url) if os.sep != "/": path = path.replace(os.sep, "/") url = "file://" + path | if os.path.exists(url): url = "file://" + urllib.pathname2url(os.path.abspath(url)) | def load(self, url): """Load a resource from a URL or pathname.""" parts = urlparse.urlsplit(url) if not parts[0]: # must be a filename path = os.path.abspath(url) if os.sep != "/": path = path.replace(os.sep, "/") url = "file://" + path top = self.createToplevelSection(url) self._imports = [top] self._parse_url(url, t... |
L.append(sect) | def test_simple_sections(self): conf = self.load("simplesections.conf") self.assertEqual(conf.get("var"), "foo") # check each interleaved position between sections for c in "0123456": self.assertEqual(conf.get("var-" + c), "foo-" + c) self.assert_(conf.get("var-7") is None) sect = conf.getSection("section", "name") for... | |
return loghandler.StreamHandler(sys.stderr) if path == "STDOUT": return loghandler.StreamHandler(sys.stdout) return loghandler.FileHandler(path) | handler = loghandler.StreamHandler(sys.stderr) elif path == "STDOUT": handler = loghandler.StreamHandler(sys.stdout) else: handler = loghandler.FileHandler(path) return handler | def create_loghandler(self): from ZConfig.components.logger import loghandler path = self.section.path if path == "STDERR": return loghandler.StreamHandler(sys.stderr) if path == "STDOUT": return loghandler.StreamHandler(sys.stdout) return loghandler.FileHandler(path) |
self._old_logger.handlers[:] = [loghandler.NullHandler()] | self._old_logger.handlers[:] = [] | def setUp(self): self._old_logger = logging.getLogger() self._old_level = self._old_logger.level self._old_handlers = self._old_logger.handlers[:] self._old_logger.handlers[:] = [loghandler.NullHandler()] self._old_logger.setLevel(logging.WARN) |
details = 'Missing section, type: %s' % type | details = 'Missing section (type: %s' % type | def __init__(self, type, name=None): self.type = type self.name = name details = 'Missing section, type: %s' % type if name is not None: details += ', name: %s' % name ConfigurationError.__init__(self, details + ')') |
details = 'Conflicting sections, (type: %s' % type | details = 'Conflicting sections (type: %s' % type | def __init__(self, type, name=None): self.type = type self.name = name details = 'Conflicting sections, (type: %s' % type if name is not None: details += ', name: %s' % name ConfigurationError.__init__(self, details + ')') |
raise NotImpementedError( | raise NotImplementedError( | def loadResource(self, resource): raise NotImpementedError( "BaseLoader.loadResource() must be overridden by a subclass") |
raise NotImpementedError( | raise NotImplementedError( | def startSection(self, parent, type, name, delegatename): if delegatename: raise NotImpementedError( "section delegation is not yet supported") t = self.schema.gettype(type) if t.isabstract(): raise ZConfig.ConfigurationError( "concrete sections cannot match abstract section types;" " found abstract type " + `type`) re... |
check("$1") | def check(s): self.assertRaises(InterpolationSyntaxError, interpolate, s, d) | |
def check(s, value): self.assertEqual(interpolate(s, {}), value) check("$", "$") check("$ stuff", "$ stuff") | def check(s): self.assertEqual(interpolate(s, {}), s) check("$1") check("$") check("$ stuff") | def check(s, value): self.assertEqual(interpolate(s, {}), value) |
"splat": "$foo", "foo": "$"} self.assertRaises(InterpolationSyntaxError, get, d, "name") d = {"name": "$splat", | def test_nesting_errors(self): d = {"name": "$splat", "splat": "$foo", "foo": "$"} self.assertRaises(InterpolationSyntaxError, get, d, "name") d = {"name": "$splat", "splat": "$name"} self.assertRaises(InterpolationRecursionError, get, d, "name") d = {"name": "$splat", "splat": "$splat"} self.assertRaises(Interpolation... | |
"unclosed sections no allowed", resource.url, lineno + 1) | "unclosed sections not allowed", resource.url, lineno + 1) | def Parse(resource, context, section): lineno = 0 stack = [] while 1: line = resource.file.readline() if not line: break lineno += 1 line = line.strip() if not line: # blank line continue if line[0] == "#": # comment continue if line[:2] == "</": # section end if line[-1] != ">": raise ConfigurationSyntaxError( "malfo... |
L2 = conf.getChildSections("trivial") | L2 = conf.getChildSections("TRIVIAL") | def test_simple_sections(self): conf = self.load("simplesections.conf") self.assertEqual(conf.get("var"), "foo") # check each interleaved position between sections for c in "0123456": self.assertEqual(conf.get("var-" + c), "foo-" + c) self.assert_(conf.get("var-7") is None) sect = conf.getSection("section", "name") for... |
raise ValeuError("'type' must be specified") | raise ValueError("'type' must be specified") | def addChildSection(self, section): """Add a section that is a child of this one.""" if section.name: self.addNamedSection(section) elif not section.type: raise ValeuError("'type' must be specified") self._sections.append(section) |
raise ValeuError("'type' must be specified") | raise ValueError("'type' must be specified") | def addNamedSection(self, section): """Add a named section that may""" name = section.name type = section.type if not type: raise ValeuError("'type' must be specified") key = type, name child = self._sections_by_name.get(key) if child is None or child.url != self.url: self._sections_by_name[key] = section else: raise C... |
" <abstracttype name='group'/>" | " <abstracttype name='group'>" " <description>This is an abstract section type.</description>" " </abstracttype>" | def test_load_abstracttype(self): schema = self.load_schema_text( "<schema>" " <abstracttype name='group'/>" " <sectiontype name='t1' implements='group'>" " <key name='k1' default='default1'/>" " </sectiontype>" " <sectiontype name='t2' implements='group'>" " <key name='k2' default='default2'/>" " </sectiont... |
q.newTextChild(q.ns(),"version","0.1") | q.newTextChild(q.ns(),"version","0.2.2") | def get_version(self,iq): iq=iq.make_result_response() q=iq.new_query("jabber:iq:version") q.newTextChild(q.ns(),"name","Jajcus' Jabber-IRC Gateway") q.newTextChild(q.ns(),"version","0.1") self.stream.send(iq) return 1 |
print "%r:%r,%r:%r vs %r:%r,%r:%r" % ( localip,localport,remoteip,remoteport, locip,locport,remip,remport) | def lookup(self,localport,localip,remoteport,remoteip): try: f=file("/proc/net/tcp","r") except IOError: print >>sys.stderr,"Couldn't open /proc/net/tcp" return None f.readline() li=[long(i) for i in localip.split(".")] localip=(li[0]<<24)+(li[1]<<16)+(li[2]<<8)+li[3] ri=[long(i) for i in remoteip.split(".")] remoteip=... | |
print `r` | def input_thread(sock,addr): print >>sys.stderr,"Connection from: %r" % (addr,) localip=sock.getsockname()[0] remoteip=addr[0] buf="" while 1: try: r=sock.recv(1024) except socket.error,e: if e.args[0]==errno.EINTR: continue if not r: print >>sys.stderr,"No query" sock.close() return buf+=r if len(buf)>1024: print >>sy... | |
elif r.startswith("ERROR:"): | if mapping and not r.startswith("ERROR:"): oldr=r r=mapping.lookup(r) print "%r -> %r" % (oldr,r) if r.startswith("ERROR:"): | def input_thread(sock,addr): print >>sys.stderr,"Connection from: %r" % (addr,) localip=sock.getsockname()[0] remoteip=addr[0] buf="" while 1: try: r=sock.recv(1024) except socket.error,e: if e.args[0]==errno.EINTR: continue if not r: print >>sys.stderr,"No query" sock.close() return buf+=r if len(buf)>1024: print >>sy... |
print " -p USER --user=USER when started with uid=0, switch " | print " -u USER --user=USER when started with uid=0, switch " | def usage(): print "Simple Programmable Ident (RFC1413) Daemon" print "(c) 2004 Jacek Konieczny" print print "Usage:" print " %s [options] [driver...]" print print "Options:" print " -h --help display this help and exit." print " -i ADDR --ip=ADDR bind to IP address ADDR." print " -p PORT ... |
print " --real reply with real connection user name (currently Linux only)." | print " --real reply with real connection user name (currently Linux" print " only)." print " --map=FILE user mapping file FILE for results of the following " print " drivers" | def usage(): print "Simple Programmable Ident (RFC1413) Daemon" print "(c) 2004 Jacek Konieczny" print print "Usage:" print " %s [options] [driver...]" print print "Options:" print " -h --help display this help and exit." print " -i ADDR --ip=ADDR bind to IP address ADDR." print " -p PORT ... |
opts,args=getopt.getopt(sys.argv[1:], "hi:p:u:g:", ["help","ip=","port=","user=","group=", | opts,args=getopt.getopt(sys.argv[1:], "hi:p:u:g:", ["help","ip=","port=","user=","group=","map=","socketmode=","socketgroup=", | def usage(): print "Simple Programmable Ident (RFC1413) Daemon" print "(c) 2004 Jacek Konieczny" print print "Usage:" print " %s [options] [driver...]" print print "Options:" print " -h --help display this help and exit." print " -i ADDR --ip=ADDR bind to IP address ADDR." print " -p PORT ... |
except: | except Exception,e: print e | def usage(): print "Simple Programmable Ident (RFC1413) Daemon" print "(c) 2004 Jacek Konieczny" print print "Usage:" print " %s [options] [driver...]" print print "Options:" print " -h --help display this help and exit." print " -i ADDR --ip=ADDR bind to IP address ADDR." print " -p PORT ... |
if sys.argv[1]=='--profile': | if '--profile' in sys.argv: | def main(profile=False): config_dir,data_dir=".","." try: try: config=Config(config_dir,data_dir) except: print >>sys.stderr,"Couldn't load config file:",str(sys.exc_value) sys.exit(1) print "creating component..." c=Component(config,profile=profile) print "starting..." c.run(1) except JJIGWFatalError,e: print e pri... |
sys.argv[1:]=sys.argv[2:] | sys.argv.remove('--profile') | def main(profile=False): config_dir,data_dir=".","." try: try: config=Config(config_dir,data_dir) except: print >>sys.stderr,"Couldn't load config file:",str(sys.exc_value) sys.exit(1) print "creating component..." c=Component(config,profile=profile) print "starting..." c.run(1) except JJIGWFatalError,e: print e pri... |
def __repr__(self): return "<IRCUser %r>" % (self.nick,) | def jid(self): | |
def get_user_presence(self,user): | def get_user_presence(self,user,nick=None,actor=None,reason=None,status=None): | def get_user_presence(self,user): |
ui=p.make_muc_userinfo() it=MucItem("none","participant",user.jid(),unicode(user.nick,self.encoding,"replace")) | if user in self.modes.get("o",[]): aff="admin" role="moderator" elif user in self.modes.get("v",[]): aff="member" role="participant" elif self.modes.get("m"): aff="none" role="visitor" else: aff="none" role="participant" ui=p.make_muc_userinfo(status=status) if nick: nick=unicode(user.nick,self.encoding,"replace") it=M... | def get_user_presence(self,user): |
p_aval=self.get_user_presence(user) p_unaval=p_aval.copy() | p_unaval=self.get_user_presence(user,nick=user.nick,status=303) | def nick_changed(self,oldnick,user): |
command,stanza=self.requests.get(requests) if command: m=stanza.make_error_response(condition) | r=self.requests.get(requests) if r: m=r.stanza.make_error_response(condition) | def irc_error_response(self,prefix,command,params,requests,condition): |
r=self.requests.get("MODE",(params[1],normalize(params[2]))) | r=self.requests.get("MODE",string.join(params[1:]," ")) | def irc_cmd_MODE(self,prefix,command,params): |
self.session.send("MODE %s +o %s" % (self.name,nick)) self.requests.add("MODE",stanza,("+o",normalize(nick))) | if user in self.modes.get("v",[]): change="-v+o %s %s" % (nick,nick) else: change="+o "+nick self.session.send("MODE %s %s" % (self.name,change)) self.requests.add("MODE",stanza,change) def voice_user(self,nick,stanza): nick=nick.encode(self.encoding,"strict") user=self.session.users.get(normalize(nick)) if not user i... | def op_user(self,nick,stanza): |
iuser="(%s)" % (user,) | iuser="(%s)" % (iuser,) | def irc_cmd_MODE(self,prefix,command,params): |
self.send_notice_message(u"Mode chage: [%s%s] by %s%s" | self.send_notice_message(u"Mode change: [%s%s] by %s%s" | def irc_cmd_MODE(self,prefix,command,params): |
nick_re=re.compile(r"^[a-zA-Z\x5b-\x60\x7b-\x7d\[\]\\`_^{|}][a-zA-Z\x5b-\x60\x7b-\x7d\[\]\\`_^{|}0-9-]{0,8}$") nick8_re=re.compile(r"^[a-zA-Z\x5b-\x60\x7b-\x7d\[\]\\`_^{|}\x80-\xff][a-zA-Z\x5b-\x60\x7b-\x7d\[\]\\`_^{|}0-9\x80-\xff-]{0,8}$") | nick_re=re.compile(r"^[a-zA-Z\x5b-\x60\x7b-\x7d\[\]\\`_^{|}][a-zA-Z\x5b-\x60\x7b-\x7d\[\]\\`_^{|}0-9-]*$") nick8_re=re.compile(r"^[a-zA-Z\x5b-\x60\x7b-\x7d\[\]\\`_^{|}\x80-\xff][a-zA-Z\x5b-\x60\x7b-\x7d\[\]\\`_^{|}0-9\x80-\xff-]*$") | def strip_colors(s): return color_re.sub("",s) |
(dest, random.uniform(0, 2**64), self.input, self.input)) | (dest, id, self.input, self.input)) | def send(self, dest, node): try: if dest == flags["landmark"]: os.system("cpp -P -DLANDMARK=\\\"--\\\" -DIPADDRESS=\\\"%s\\\" -DNODEID=%s %s %s.processed" % \ (dest, random.uniform(0, 2**64), self.input, self.input)) else: os.system("cpp -P -DLANDMARK=\\\"%s\\\" -DIPADDRESS=\\\"%s\\\" -DNODEID=%s %s %s.processed" % \ (... |
(flags["landmark"], dest, random.uniform(0, 2**64), self.input, self.input)) | (flags["landmark"], dest, id, self.input, self.input)) | def send(self, dest, node): try: if dest == flags["landmark"]: os.system("cpp -P -DLANDMARK=\\\"--\\\" -DIPADDRESS=\\\"%s\\\" -DNODEID=%s %s %s.processed" % \ (dest, random.uniform(0, 2**64), self.input, self.input)) else: os.system("cpp -P -DLANDMARK=\\\"%s\\\" -DIPADDRESS=\\\"%s\\\" -DNODEID=%s %s %s.processed" % \ (... |
print print "Usage: loadManyChords.py [-d <sec_delay>] -f <input_file> -n <nodes> -a <ip_address> -p <start_port> -l <landmark>\n" print | print r""" Usage: loadManyChords.py [-d <sec_delay>=20] \ -f <input_file> -n <nodes> \ -a <ip_address> -p <start_port> -l <landmark>""" | def print_usage(): print print "Usage: loadManyChords.py [-d <sec_delay>] -f <input_file> -n <nodes> -a <ip_address> -p <start_port> -l <landmark>\n" print |
srcAddr = conf.addElement(libp2python.PelTransform("SRC: " + src, "\""+src+"\""+" pop swallow pop")) destAddr = conf.addElement(libp2python.PelTransform("DEST: " + dest, "\""+dest+"\""+" pop swallow pop")) | box = conf.addElement(libp2python.PelTransform("box", "$0 pop swallow pop")) | def UdpCC_source(udp, src, dest, drop): conf = libp2python.Plumber.Dataflow("source") udp = conf.addElement(udp) data = conf.addElement(libp2python.TimedPushSource("source", .01)) dqueue = conf.addElement(libp2python.Queue("Source Data Q", 1000)) seq = conf.addElement(libp2python.Sequence("Sequence", 1... |
conf.hookUp(seq, 0, retry, 0) | conf.hookUp(seq, 0, srcAddr, 0) conf.hookUp(srcAddr, 0, destAddr, 0) conf.hookUp(destAddr, 0, retry, 0) | def UdpCC_source(udp, src, dest, drop): conf = libp2python.Plumber.Dataflow("source") udp = conf.addElement(udp) data = conf.addElement(libp2python.TimedPushSource("source", .01)) dqueue = conf.addElement(libp2python.Queue("Source Data Q", 1000)) seq = conf.addElement(libp2python.Sequence("Sequence", 1... |
conf.hookUp(cct, 0, srcAddr, 0) conf.hookUp(srcAddr, 0, destAddr, 0) conf.hookUp(destAddr, 0, printer, 0) | conf.hookUp(cct, 0, box, 0) conf.hookUp(box, 0, printer, 0) | def UdpCC_source(udp, src, dest, drop): conf = libp2python.Plumber.Dataflow("source") udp = conf.addElement(udp) data = conf.addElement(libp2python.TimedPushSource("source", .01)) dqueue = conf.addElement(libp2python.Queue("Source Data Q", 1000)) seq = conf.addElement(libp2python.Sequence("Sequence", 1... |
("ifstop",2, "IFSTOP", "If first arg, then stop execution"), | ("ifstop",1, "IFSTOP", "If first arg, then stop execution"), ("dumpStack",1,"DUMPSTACK", "Dump the contents of the stack prefixed by the string arg"), | def emit_opcode( op, ar, va, desc ): global curop decls.append((curop, op, ar, va, desc)) curop += 1 |
def processing(self): return "/l" def flow_code(self): return "/-" | def processing(self): return "h/h" def flow_code(self): return "-/-" | def processing(self): return "/l" |
Sequence("output", 1, 1) -> Frag("fragment", 1) -> PelTransform("package", "$0 pop swallow pop") -> | Slot("output") -> | def get_stub(port): stub = r"""dataflow %s { let udp = Udp2("udp", %s); TimedPushSource("dummy_source", 0) -> Sequence("output", 1, 1) -> Frag("fragment", 1) -> PelTransform("package", "$0 pop swallow pop") -> MarshalField("marshal", 1) -> St... |
StrToSockaddr("addr_conv", 0) -> udp -> UnmarshalField("unmarshal", 1) -> PelTransform("unpackage", "$1 unboxPop") -> Defrag("defragment", 1) -> PelTransform("get_payload", "$2 unboxPop") -> TimedPullPush("input", 0) -> Sequence("input", 1, 1) -> | Print("four") -> StrToSockaddr("addr_conv", 0) -> Print("five") -> udp -> Sequence("input", 1, 1) -> | def get_stub(port): stub = r"""dataflow %s { let udp = Udp2("udp", %s); TimedPushSource("dummy_source", 0) -> Sequence("output", 1, 1) -> Frag("fragment", 1) -> PelTransform("package", "$0 pop swallow pop") -> MarshalField("marshal", 1) -> St... |
def callback(self, port): | def callback(self): | def callback(self, port): self.set_delay(0, self.delay_callback) |
line = raw_input("P2 Terminal >> ") | program = r""" /* * Copyright (c) 2005 Intel Corporation * This file is distributed under the terms in the attached INTEL-LICENSE file. * If you do not find this file, copies can be found by writing to: * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, * Berkeley, CA, 94704. Attention: Intel License Inquir... | def delay_callback(self): # Read string from terminal and send it in a tuple line = raw_input("P2 Terminal >> ") t = Tuple.mk() t.append(Val_Str.mk("overlog")) t.append(Val_Str.mk(address)) t.append(Val_Str.mk(line)) t.freeze() if self.py_push(0, t, self.callback) > 0: self.set_delay(1, self.delay_callback) |
t.append(Val_Str.mk(line)) | t.append(Val_Str.mk(program)) | def delay_callback(self): # Read string from terminal and send it in a tuple line = raw_input("P2 Terminal >> ") t = Tuple.mk() t.append(Val_Str.mk("overlog")) t.append(Val_Str.mk(address)) t.append(Val_Str.mk(line)) t.freeze() if self.py_push(0, t, self.callback) > 0: self.set_delay(1, self.delay_callback) |
print "Usage: terminal.py -d <address> <port>\n" | print "Usage: terminal.py [-d] <dataflow_edit_name> <node_address> <port>\n" | def print_usage(): print print "Usage: terminal.py -d <address> <port>\n" print |
shortopts = "d" | shortopts = "df:" | def parse_cmdline(argv): shortopts = "d" flags = {"debug" : False} opts, args = getopt.getopt(argv[1:], shortopts) for o, v in opts: if o == "-d": flags["debug"] = True else: print_usage() exit(3) return flags, args |
print "COMPILING: ", stub | def gen_stub(plumber, address, port): stub = get_test_stub() print "COMPILING: ", stub dfparser.compile(plumber, stub) if dfparser.dataflows.has_key(DATAFLOW_NAME): m = dfparser.dataflows[DATAFLOW_NAME] m.eval_dataflow() return m.conf print "DATAFLOW COMPILATION PROBLEM" return None | |
address = args[0] port = int(args[1]) | dataflow = args[0] address = args[1] port = int(args[2]) | def gen_stub(plumber, address, port): stub = get_test_stub() print "COMPILING: ", stub dfparser.compile(plumber, stub) if dfparser.dataflows.has_key(DATAFLOW_NAME): m = dfparser.dataflows[DATAFLOW_NAME] m.eval_dataflow() return m.conf print "DATAFLOW COMPILATION PROBLEM" return None |
print "INSTALL THE DATAFLOW" if plumber.install(stub) == 0: print "Stub Correctly initialized.\n" else: | if plumber.install(stub) != 0: | def gen_stub(plumber, address, port): stub = get_test_stub() print "COMPILING: ", stub dfparser.compile(plumber, stub) if dfparser.dataflows.has_key(DATAFLOW_NAME): m = dfparser.dataflows[DATAFLOW_NAME] m.eval_dataflow() return m.conf print "DATAFLOW COMPILATION PROBLEM" return None |
term = edit.addElement(Terminal("terminal", address+":"+str(port))) | term = edit.addElement(Terminal(dataflow, address+":"+str(port))) | def gen_stub(plumber, address, port): stub = get_test_stub() print "COMPILING: ", stub dfparser.compile(plumber, stub) if dfparser.dataflows.has_key(DATAFLOW_NAME): m = dfparser.dataflows[DATAFLOW_NAME] m.eval_dataflow() return m.conf print "DATAFLOW COMPILATION PROBLEM" return None |
print "INSTALL THE EDIT" if plumber.install(edit) == 0: | if plumber.install(edit) != 0: | def gen_stub(plumber, address, port): stub = get_test_stub() print "COMPILING: ", stub dfparser.compile(plumber, stub) if dfparser.dataflows.has_key(DATAFLOW_NAME): m = dfparser.dataflows[DATAFLOW_NAME] m.eval_dataflow() return m.conf print "DATAFLOW COMPILATION PROBLEM" return None |
else: print "** Edit Failed to initialize correct spec\n" | def gen_stub(plumber, address, port): stub = get_test_stub() print "COMPILING: ", stub dfparser.compile(plumber, stub) if dfparser.dataflows.has_key(DATAFLOW_NAME): m = dfparser.dataflows[DATAFLOW_NAME] m.eval_dataflow() return m.conf print "DATAFLOW COMPILATION PROBLEM" return None | |
("dup",2, "DUP", "Duplicate the top stack value"), | ("dup",1, "DUP", "Duplicate the top stack value"), | def emit_opcode( op, ar, va, desc ): global curop decls.append((curop, op, ar, va, desc)) curop += 1 |
for i in [ "i32", "u32", "i64", "u64", "dbl", "str" ]: | for i in [ "i32", "u32", "i64", "u64", "dbl", "str", "time" ]: | def emit_opcode( op, ar, va, desc ): global curop decls.append((curop, op, ar, va, desc)) curop += 1 |
dfparser.compile(p, libp2python, s) | dfparser.compile(p, s) | def install(f): try: s = open(f + ".df", 'r').read() except EOFError: print "FILE READ ERROR" dfparser.dataflows = {} dfparser.compile(p, libp2python, s) if dfparser.dataflows.has_key("Main"): m = dfparser.dataflows["Main"] m.eval_dataflow() install_config(m.conf) else: for d in dfparser.dataflows.values(): d.eval_dat... |
self.OurNode = os.uname()[1] | self.OurNode = lower(os.uname()[1]) | def signon(self, service=None): |
choice = findpossible(text) | choice = findpossible(text, None, False) | def help_(text): if text == "short": utl.log_info("cluster.py [global options] [topic [topic...]] [command]") return if text: choice = findpossible(text) for key in choice.keys(): alias, e = choice[key] if e: sub_cmd="" if len(e) > 4: utl.log_info("\n"+e[4]+"\n") possible = findpossible("", alias[0]).keys() possible.re... |
possible = findpossible("", alias[0]).keys() possible.remove("up") possible.remove("help") possible.remove("exit") if possible: | possible = findpossible("", alias[0]).keys() utl.log_dev("Possible sub-commands: "+repr(possible)) possible.remove("up") possible.remove("help") possible.remove("exit") if possible: | def help_(text): if text == "short": utl.log_info("cluster.py [global options] [topic [topic...]] [command]") return if text: choice = findpossible(text) for key in choice.keys(): alias, e = choice[key] if e: sub_cmd="" if len(e) > 4: utl.log_info("\n"+e[4]+"\n") possible = findpossible("", alias[0]).keys() possible.re... |
def findpossible(cmd, topic=None): | def findpossible(cmd, topic=None, filter=True): | def findpossible(cmd, topic=None): """ Return cmd -> (aliases, command table entry) for each matching command. Return debug commands (or their aliases) only if no normal command matches. """ if not topic: topic = utl.crm_topic #utl.log_debug("Looking for completions in %s" % topic) choice = {} debugchoice = {} for e i... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.