rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
if self.found_type_hook and self.found_type: gobject.idle_add(self.found_type_hook, self.sound_file, self.found_type) | if self.found_type_hook and self.sound_file.mime_type: gobject.idle_add(self.found_type_hook, self.sound_file, self.sound_file.mime_type) | def finish(self): Pipeline.finish(self) if self.found_type_hook and self.found_type: gobject.idle_add(self.found_type_hook, self.sound_file, self.found_type) |
def markup_escape(str): str = "&".join(str.split("&")) str = "<".join(str.split("<")) str = ">".join(str.split(">")) return str | def markup_escape(message): if not isinstance(message, basestring): print "markup error: '%s'" % message import pdb pdb.set_trace() message = "&".join(message.split("&")) message = "<".join(message.split("<")) message = ">".join(message.split(">")) return message | def markup_escape(str): str = "&".join(str.split("&")) str = "<".join(str.split("<")) str = ">".join(str.split(">")) return str |
self.tasks_number=0 | def __init__(self): BackgroundTask.__init__(self) self.tasks = [] self.running = False self.tasks_number=0 self.tasks_current=0 | |
self.tasks_number += 1 | def add(self, task): self.tasks.append(task) self.tasks_number += 1 | |
log("Mime type skipped: %s (mail us if this is an error)" % mime_type) | log("Mime type skipped: %s" % mime_type) | def have_type(self, typefind, probability, caps): mime_type = caps.to_string() #debug("have_type:", mime_type, self.sound_file.get_filename_for_display()) self.sound_file.mime_type = None for t in mime_whitelist: if t in mime_type: self.sound_file.mime_type = mime_type if not self.sound_file.mime_type: log("Mime type s... |
return cmd | return cmd + " ! id3v2mux " | def add_mp3_encoder(self): cmd = "lame quality=2 " if self.mp3_mode is not None: properties = { "cbr" : (0,"bitrate"), "abr" : (3,"vbr-mean-bitrate"), "vbr" : (4,"vbr-quality") } |
self.total_duration += c.get_duration() | c.got_duration = False | def add(self, sound_file): output_filename = self.window.prefs.generate_filename(sound_file) path = urlparse.urlparse(output_filename) [2] path = unquote_filename(path) exists = True try: gnomevfs.get_file_info(gnomevfs.URI((output_filename))) except gnomevfs.NotFoundError: exists = False except gnomevfs.InvalidURIEr... |
self.progressbar.set_text(_("Converting file %d of %d (%s)") % ( self.converter.tasks_current+1, self.converter.tasks_number, remaining )) | self.progressbar.set_text(_("Converting file %d of %d (%s)") % ( self.converter.tasks_current+1, len(self.converter.tasks), remaining )) | def display_progress(self, remaining): self.progressbar.set_text(_("Converting file %d of %d (%s)") % ( self.converter.tasks_current+1, self.converter.tasks_number, remaining )) |
if not filename: | if filename: self.base_path = base_path self.filename = filename self.uri = os.path.join(base_path, filename) else: | def __init__(self, base_path, filename=None): if not filename: self.uri = base_path self.base_path, self.filename = os.path.split(self.uri) self.base_path += "/" else: self.base_path = base_path self.filename = filename self.uri = os.path.join(base_path, filename) self.tags = {} |
else: self.base_path = base_path self.filename = filename self.uri = os.path.join(base_path, filename) | def __init__(self, base_path, filename=None): if not filename: self.uri = base_path self.base_path, self.filename = os.path.split(self.uri) self.base_path += "/" else: self.base_path = base_path self.filename = filename self.uri = os.path.join(base_path, filename) self.tags = {} | |
self.add_file(SoundFile(f, folder)) | self.add_file(SoundFile(f[:len(folder)], f[len(folder)+1:])) | def add_folder(self, folder): filelist = vfs_walk(gnomevfs.URI(folder)) for f in filelist: self.add_file(SoundFile(f, folder)) |
if not get("quiet"): | if not get_option("quiet"): | def cli_tags_main(input_files): global error error = ErrorPrinter() for input_file in input_files: if not get("quiet"): print input_file.get_uri() t = TagReader(input_file) t.setup() while t.do_work(): pass t.finish() if not get("quiet"): keys = input_file.keys() keys.sort() for key in keys: print " %s: %s" % (key, in... |
print "do_work", self, self.paused | def do_work(self): """Do some work by calling work(). Call finish() if work is done.""" print "do_work", self, self.paused try: if self.paused: return True if self.work(): return True else: self.run_finish_time = time.time() self.finish() return False except SoundConverterException, e: error.show_exception(e) return Fa... | |
generator.set_folder(os.path.dirname(path)) | if "%(.inputname)s" not in self.get_basename_pattern(): generator.set_folder(os.path.dirname(path)) | def generate_filename(self, sound_file, for_display=False): self.gconf.clear_cache() output_type = self.get_string("output-mime-type") output_suffix = { "audio/x-vorbis": ".ogg", "audio/x-flac": ".flac", "audio/x-wav": ".wav", "audio/mpeg": ".mp3", }.get(output_type, None) |
self.convert_setting_from_old_version() self.set_widget_initial_values(glade) | def __init__(self, glade): self.gconf = gconf.client_get_default() self.gconf.add_dir(self.root, gconf.CLIENT_PRELOAD_ONELEVEL) self.dialog = glade.get_widget("prefsdialog") self.into_selected_folder = glade.get_widget("into_selected_folder") self.target_folder_chooser = glade.get_widget("target_folder_chooser") self.e... | |
if hasattr(task,"converting"): bytes = task.get_bytes_progress() self.window.set_progress(self.total_for_processed_files + bytes, self.total_bytes) | bytes = task.get_bytes_progress() self.window.set_progress(self.total_for_processed_files + bytes, self.total_bytes) | def work_hook(self, task): if hasattr(task,"converting"): #TODO bytes = task.get_bytes_progress() #print "work: %s+%s/%s" % (self.total_for_processed_files, bytes, self.total_bytes) self.window.set_progress(self.total_for_processed_files + bytes, self.total_bytes) |
conf = IniFile({'global':{}}) | conf = IniFile({'global':{'autoconnect':[]}}) | def print_section(self,section): print "[%s]" % section for var in self.conf[section]: print "%s = %s" % (var, self.conf[section][var]) |
conf = IniFile({'global':{'autoconnect':[]}}) | conf = IniFile({'global':{'autoconnect':""}}) | def print_section(self,section): print "[%s]" % section for var in self.conf[section]: print "%s = %s" % (var, self.conf[section][var]) |
conf.conf['global']['autoconnect'].append("%s;" % oldnet.name) | conf.conf['global']['autoconnect'] += "%s;" % oldnet.name | def convert_repl_simple(plugin,conf): conf.conf['global']['replication'] = 'simple' |
for srv in oldnet.servers: oldsrv = oldnet.servers[srv] | def convert_repl_simple(plugin,conf): conf.conf['global']['replication'] = 'simple' | |
path = os.path.join(ctrlproxy.get_path("prefix"),"share","ctrlproxy","xml") | path = os.path.join(ctrlproxy.get_path("prefix"),"share","ctrlproxy","help") | def get_xml_module_names(typ = None): """Returns a list of modules for which a Moduleinfo is available""" path = os.path.join(ctrlproxy.get_path("prefix"),"share","ctrlproxy","xml") dl = os.listdir(path) rv = [] for i in dl: if i[-8:] == ".mod.xml": if typ != None: d = libxml2.parseFile(os.path.join(path, i)) #d.dump(1... |
for pl in ['socket','strip','repl_memory']: | for pl in ['socket','strip','repl_memory','linestack_file','repl_none']: | def upgrade(self): # Throw out obsolete modules for pl in ['socket','strip','repl_memory']: if self.plugins.has_key(pl): self.plugins.pop(pl) |
You may need to add Options ExecCGI on "<Directory />" for this to work. | You may need to add Options ExecCGI on "<Directory />" and your cgi-bin directory for this to work. | def createfile(pretend, fname, contents): if pretend: print "cat >%(fname)s <__EOF__\n%(contents)s__EOF__" % vars() else: f = open(fname, "w") f.write(contents) f.close() |
print '\t-d\tdirectory for CGIs, defaults to %s' % cgidir | print '\t-c\tdirectory for CGIs, defaults to %s' % cgidir | def usage(): print 'usage: zope-install [-n] [-p perms] [-u user] [-g group] [-d dir] [-c cgidir] instancename' print print '\t-n\tshow what would be done, but don\'t actually do it' print '\t-p\tmanager permissions, in the form' print '\t\tusername:plaintextpassword[:domain-restrinction]' print '\t\teg: "root:mypass" ... |
optlist, args = getopt.getopt(sys.argv[1:], 'np:u:g:d:') | optlist, args = getopt.getopt(sys.argv[1:], 'np:u:g:d:c:') | def createfile(pretend, fname, contents): if pretend: print "cat >%(fname)s <__EOF__\n%(contents)s__EOF__" % vars() else: f = open(fname, "w") f.write(contents) f.close() |
RewriteRule ^/%(instance)s/(.*) %(cgidir)s/%(instance)s.cgi/$1 [e=HTTP_CGI_AUTHORIZATION:%%1,t=application/x-httpd-cgi,l] | RewriteRule ^/%(instance)s($|/)(.*) %(cgidir)s/%(instance)s.cgi/$2 [e=HTTP_CGI_AUTHORIZATION:%%1,t=application/x-httpd-cgi,l] | def createfile(pretend, fname, contents): if pretend: print "cat >%(fname)s <__EOF__\n%(contents)s__EOF__" % vars() else: f = open(fname, "w") f.write(contents) f.close() |
self.aps = 15 | self.aps = 40 | def __init__(self, distance, callback, is_angle): self.callback = callback #distance in m*10 self.distance = distance self.is_angle = is_angle #meters per second self.mps = 1 #amount of angles turned per second self.aps = 15 |
result = re.search("blx.*0x.*",data) | result = re.search("bl.*0x.*",data) | def callplt(data): resplt = dict(zip(plt.values(),plt.keys())) result = re.search("blx.*0x.*",data) if result : addr = result.group().split("0x")[1] addr = "0x" + addr if addr in resplt: return data[:-1] + " <" + resplt[addr] + ">\n" return data else : return data |
def __init__(self, x, y, width, height, **kwargs): | def __init__(self, x, y, width, height, line_width, **kwargs): | def __init__(self, x, y, width, height, **kwargs): CustomItem.__init__(self, **kwargs) self.x = x self.y = y self.width = width self.height = height |
self.bounds.x1 = float(self.x) self.bounds.y1 = float(self.y) self.bounds.x2 = float(self.x + self.width) self.bounds.y2 = float(self.y + self.height) | half_lw = self.line_width/2 self.bounds.x1 = float(self.x - half_lw) self.bounds.y1 = float(self.y - half_lw) self.bounds.x2 = float(self.x + self.width + half_lw) self.bounds.y2 = float(self.y + self.height + half_lw) | def do_update(self, entire_tree, cr): self.bounds.x1 = float(self.x) self.bounds.y1 = float(self.y) self.bounds.x2 = float(self.x + self.width) self.bounds.y2 = float(self.y + self.height) return self.bounds |
cr.set_line_width(self.width/20) | cr.set_line_width(self.line_width) cr.set_source_rgb(0, 0, 0) | def do_paint(self, cr, bounds, scale): cr.rectangle(self.x, self.y, self.width, self.height) cr.set_line_width(self.width/20) cr.stroke() return self.bounds |
item = CustomRectItem(x=100, y=100, width=400, height=400) | item = CustomRectItem(x=100, y=100, width=400, height=400, line_width=20) | def create_canvas_model(): canvas_model = goocanvas.CanvasModelSimple() root = canvas_model.get_root_item() item = CustomRectItem(x=100, y=100, width=400, height=400) root.add_child(item) item = goocanvas.Text(text="Hello World", x=300, y=300, anchor=gtk.ANCHOR_CENTER, font="Sans 24") root.add_child(item) item.rotate(4... |
info.varlist.add('PyObject', '*py_' + pname) info.add_parselist('O!', ['&PyGooCanvasBounds_Type', '&py_'+pname], [pname]) info.arglist.append("&((PyGooCanvasBounds *) py_%s)->bounds" % (pname,)) | if pdflt: info.varlist.add('PyObject', '*py_' + pname + " = " + pdflt) else: info.varlist.add('PyObject', '*py_' + pname) if pnull: info.add_parselist('O', ['&py_'+pname], [pname]) info.codebefore.append( ' if (!(py_%(name)s == NULL || py_%(name)s == Py_None || \n' ' PyObject_IsInstance(py_%(name)s, (PyObject... | def write_param(self, ptype, pname, pdflt, pnull, info): info.varlist.add('PyObject', '*py_' + pname) info.add_parselist('O!', ['&PyGooCanvasBounds_Type', '&py_'+pname], [pname]) info.arglist.append("&((PyGooCanvasBounds *) py_%s)->bounds" % (pname,)) |
item = gobject.new(goocanvas.CanvasRect, | item = gobject.new(goocanvas.Rect, | def create_canvas_model(): canvas_model = goocanvas.CanvasModelSimple() root = canvas_model.get_root_item() ## Add a few simple items. item = gobject.new(goocanvas.CanvasRect, x=100, y=100, width=400, height=400, line_width=10.0, radius_x=20.0, radius_y=10.0, stroke_color="yellow", fill_color="red") root.add_child(it... |
item = gobject.new(goocanvas.CanvasText, text="Hello World", | item = gobject.new(goocanvas.Text, text="Hello World", | def create_canvas_model(): canvas_model = goocanvas.CanvasModelSimple() root = canvas_model.get_root_item() ## Add a few simple items. item = gobject.new(goocanvas.CanvasRect, x=100, y=100, width=400, height=400, line_width=10.0, radius_x=20.0, radius_y=10.0, stroke_color="yellow", fill_color="red") root.add_child(it... |
if isinstance(item, goocanvas.CanvasRect): | if isinstance(item, goocanvas.Rect): | def on_item_view_created (view, item_view, item): if isinstance(item, goocanvas.CanvasRect): item_view.connect("button_press_event", on_rect_button_press) |
code=('py_%s = PycairoContext_FromContext(%s, NULL, NULL);' % | code=('py_%s = PycairoContext_FromContext(cairo_reference(%s), NULL, NULL);' % | def convert_c2py(self): self.wrapper.add_declaration("PyObject *py_%s;" % self.name) self.wrapper.write_code( code=('py_%s = PycairoContext_FromContext(%s, NULL, NULL);' % (self.name, self.name)), cleanup=("Py_DECREF(py_%s);" % self.name)) self.wrapper.add_pyargv_item("py_%s" % self.name) |
timeout = time() + 2 | timeout = time.time() + 2 | def tearDown(self): self.run_loop = 0 self.thread.join() td.shutdown() self.server.close() # Make sure all sockets get closed by asyncore normally. timeout = time() + 2 while 1: if len(asyncore.socket_map) == self.orig_map_size: # Clean! break if time() >= timeout: self.fail('Leaked a socket: %s' % `asyncore.socket_map... |
if time() >= timeout: | if time.time() >= timeout: | def tearDown(self): self.run_loop = 0 self.thread.join() td.shutdown() self.server.close() # Make sure all sockets get closed by asyncore normally. timeout = time() + 2 while 1: if len(asyncore.socket_map) == self.orig_map_size: # Clean! break if time() >= timeout: self.fail('Leaked a socket: %s' % `asyncore.socket_map... |
return result.split('\r\n')[0] | return result | def execute(self, commands, login=1): ftp = self.getFTPConnection(login) |
self.assertEqual(self.execute('ABOR', 1), | self.assertEqual(self.execute('ABOR', 1).rstrip(), | def testABOR(self): self.assertEqual(self.execute('ABOR', 1), status_messages['TRANSFER_ABORTED']) |
self.assertEqual(self.execute(('CWD test', 'CDUP'), 1), | self.execute('CWD test', 1) self.assertEqual(self.execute('CDUP', 1).rstrip(), | def testCDUP(self): self.assertEqual(self.execute(('CWD test', 'CDUP'), 1), status_messages['SUCCESS_250'] %'CDUP') self.assertEqual(self.execute('CDUP', 1), status_messages['SUCCESS_250'] %'CDUP') |
self.assertEqual(self.execute('CDUP', 1), | self.assertEqual(self.execute('CDUP', 1).rstrip(), | def testCDUP(self): self.assertEqual(self.execute(('CWD test', 'CDUP'), 1), status_messages['SUCCESS_250'] %'CDUP') self.assertEqual(self.execute('CDUP', 1), status_messages['SUCCESS_250'] %'CDUP') |
self.assertEqual(self.execute('CWD test', 1), | self.assertEqual(self.execute('CWD test', 1).rstrip(), | def testCWD(self): self.assertEqual(self.execute('CWD test', 1), status_messages['SUCCESS_250'] %'CWD') self.assertEqual(self.execute('CWD foo', 1), status_messages['ERR_NO_DIR'] %'/foo') |
self.assertEqual(self.execute('CWD foo', 1), | self.assertEqual(self.execute('CWD foo', 1).rstrip(), | def testCWD(self): self.assertEqual(self.execute('CWD test', 1), status_messages['SUCCESS_250'] %'CWD') self.assertEqual(self.execute('CWD foo', 1), status_messages['ERR_NO_DIR'] %'/foo') |
self.assertEqual(self.execute('DELE test/existing', 1), | self.assertEqual(self.execute('DELE test/existing', 1).rstrip(), | def testDELE(self): self.assertEqual(self.execute('DELE test/existing', 1), status_messages['SUCCESS_250'] %'DELE') res = self.execute('DELE bar', 1).split()[0] self.assertEqual(res, '550') self.assertEqual(self.execute('DELE', 1), status_messages['ERR_ARGS']) |
self.assertEqual(self.execute('DELE', 1), | self.assertEqual(self.execute('DELE', 1).rstrip(), | def testDELE(self): self.assertEqual(self.execute('DELE test/existing', 1), status_messages['SUCCESS_250'] %'DELE') res = self.execute('DELE bar', 1).split()[0] self.assertEqual(res, '550') self.assertEqual(self.execute('DELE', 1), status_messages['ERR_ARGS']) |
def XXXtestHELP(self): | def testHELP(self): | def XXXtestHELP(self): # TODO This test doesn't work. I think it is because execute() # doesn't read the whole reply. The execeute() helper # function should be fixed, but that's for another day. result = status_messages['HELP_START'] + '\r\n' result += 'Help goes here somewhen.\r\n' result += status_messag... |
result += status_messages['HELP_END'] | result += status_messages['HELP_END'] + '\r\n' | def XXXtestHELP(self): # TODO This test doesn't work. I think it is because execute() # doesn't read the whole reply. The execeute() helper # function should be fixed, but that's for another day. result = status_messages['HELP_START'] + '\r\n' result += 'Help goes here somewhen.\r\n' result += status_messag... |
self.assertEqual(self.execute('NOOP', 0), | self.assertEqual(self.execute('NOOP', 0).rstrip(), | def testNOOP(self): self.assertEqual(self.execute('NOOP', 0), status_messages['SUCCESS_200'] %'NOOP') self.assertEqual(self.execute('NOOP', 1), status_messages['SUCCESS_200'] %'NOOP') |
self.assertEqual(self.execute('NOOP', 1), | self.assertEqual(self.execute('NOOP', 1).rstrip(), | def testNOOP(self): self.assertEqual(self.execute('NOOP', 0), status_messages['SUCCESS_200'] %'NOOP') self.assertEqual(self.execute('NOOP', 1), status_messages['SUCCESS_200'] %'NOOP') |
self.assertEqual(self.execute('PASS', 0), | self.assertEqual(self.execute('PASS', 0).rstrip(), | def testPASS(self): self.assertEqual(self.execute('PASS', 0), status_messages['LOGIN_MISMATCH']) self.assertEqual(self.execute(('USER blah', 'PASS bar'), 0), status_messages['LOGIN_MISMATCH']) |
self.assertEqual(self.execute(('USER blah', 'PASS bar'), 0), | self.execute('USER blah', 0) self.assertEqual(self.execute('PASS bar', 0).rstrip(), | def testPASS(self): self.assertEqual(self.execute('PASS', 0), status_messages['LOGIN_MISMATCH']) self.assertEqual(self.execute(('USER blah', 'PASS bar'), 0), status_messages['LOGIN_MISMATCH']) |
self.assertEqual(self.execute('QUIT', 0), | self.assertEqual(self.execute('QUIT', 0).rstrip(), | def testQUIT(self): self.assertEqual(self.execute('QUIT', 0), status_messages['GOODBYE']) self.assertEqual(self.execute('QUIT', 1), status_messages['GOODBYE']) |
self.assertEqual(self.execute('QUIT', 1), | self.assertEqual(self.execute('QUIT', 1).rstrip(), | def testQUIT(self): self.assertEqual(self.execute('QUIT', 0), status_messages['GOODBYE']) self.assertEqual(self.execute('QUIT', 1), status_messages['GOODBYE']) |
self.assertEqual(self.execute('USER foo', 0), | self.assertEqual(self.execute('USER foo', 0).rstrip(), | def testUSER(self): self.assertEqual(self.execute('USER foo', 0), status_messages['PASS_REQUIRED']) self.assertEqual(self.execute('USER', 0), status_messages['ERR_ARGS']) |
self.assertEqual(self.execute('USER', 0), | self.assertEqual(self.execute('USER', 0).rstrip(), | def testUSER(self): self.assertEqual(self.execute('USER foo', 0), status_messages['PASS_REQUIRED']) self.assertEqual(self.execute('USER', 0), status_messages['ERR_ARGS']) |
pdb.post_mortem(sys.exc_info()[2]) raise | zope.security.management.restoreInteraction() try: pdb.post_mortem(sys.exc_info()[2]) raise finally: zope.security.management.endInteraction() | def executeRequest(self, task): """Overrides HTTPServer.executeRequest().""" env = task.getCGIEnvironment() instream = task.request_data.getBodyStream() |
print "exception polling in loop(): ", data | nerr += 1 if nerr > 100: for socket in asyncore.socket_map.values(): if not isinstance(socket, trigger): try: socket.close() except: pass break | def loop(self): self.thread_started.set() import select from errno import EBADF while self.run_loop: self.counter = self.counter + 1 # print 'loop', self.counter try: asyncore.poll(0.1) except select.error, data: if data[0] == EBADF: print "exception polling in loop(): ", data else: raise |
opts, args = getopt(args.split(), 'lad') | opts, args = getopt(args.split(), 'Llad') | def cmd_list(self, args, long=1): 'See IFTPCommandHandler' opts = () if args.strip().startswith('-'): try: opts, args = getopt(args.split(), 'lad') except GetoptError: self.reply('ERR_ARGS') return if len(args) > 1: self.reply('ERR_ARGS') return args = args and args[0] or '' |
"""An error occured, but we are still trying to fix it. | """An error occurred, but we are still trying to fix it. | def handle_error(): """An error occured, but we are still trying to fix it. """ |
asyncore.poll(0.1) | poll(0.1) | def setUp(self): td.setThreadCount(4) if len(socket_map) != 1: # Let sockets die off. # XXX tests should be more careful to clear the socket map. asyncore.poll(0.1) self.orig_map_size = len(socket_map) self.hook_asyncore_error() self.server = EchoHTTPServer(LOCALHOST, SERVER_PORT, task_dispatcher=td, adj=my_adj) if CON... |
unittest.deferredResult(factory.deferred) self.assertEquals(factory.status, '200') self.assert_(factory.version.startswith('HTTP/')) self.assertEquals(factory.message, 'OK') self.assertEquals(factory.response_headers['content-length'][0], '10') | return factory.deferred.addCallback(self._cbFactoryInfo, factory) | def testFactoryInfo(self): url = self.getURL('file') scheme, host, port, path = client._parse(url) factory = client.HTTPClientFactory(url) reactor.connectSSL(host, port, factory, ssl.ClientContextFactory()) unittest.deferredResult(factory.deferred) self.assertEquals(factory.status, '200') self.assert_(factory.version.s... |
self.assertEquals(unittest.deferredResult(client.getPage(self.getHTTP("one"))), "FOUND IT!") | return client.getPage(self.getHTTP("one") ).addCallback(self.assertEquals, "FOUND IT!" ) | def testHoppingAround(self): self.assertEquals(unittest.deferredResult(client.getPage(self.getHTTP("one"))), "FOUND IT!") |
self.assertEquals(unittest.deferredResult(client.getPage(self.getHTTP("cookiemirror"))), "[]") | return client.getPage(self.getHTTP("cookiemirror") ).addCallback(self.assertEquals, "[]" ) | def testNoCookies(self): self.assertEquals(unittest.deferredResult(client.getPage(self.getHTTP("cookiemirror"))), "[]") |
self.assertEquals(unittest.deferredResult(client.getPage(self.getHTTP("cookiemirror"), cookies={'foo': 'bar', 'baz': 'quux'})), "[('baz', 'quux'), ('foo', 'bar')]") | cookies = {'foo': 'bar', 'baz': 'quux'} return client.getPage(self.getHTTP("cookiemirror"), cookies=cookies ).addCallback(self.assertEquals, "[('baz', 'quux'), ('foo', 'bar')]" ) | def testSomeCookies(self): self.assertEquals(unittest.deferredResult(client.getPage(self.getHTTP("cookiemirror"), cookies={'foo': 'bar', 'baz': 'quux'})), "[('baz', 'quux'), ('foo', 'bar')]") |
self.assertEquals(unittest.deferredResult(client.getPage(self.getHTTP("rawcookiemirror"))), "None") | return client.getPage(self.getHTTP("rawcookiemirror") ).addCallback(self.assertEquals, "None" ) | def testRawNoCookies(self): self.assertEquals(unittest.deferredResult(client.getPage(self.getHTTP("rawcookiemirror"))), "None") |
self.assertEquals(unittest.deferredResult(client.getPage(self.getHTTP("rawcookiemirror"), cookies={'foo': 'bar', 'baz': 'quux'})), "'foo=bar; baz=quux'") | cookies = {'foo': 'bar', 'baz': 'quux'} return client.getPage(self.getHTTP("rawcookiemirror"), cookies=cookies ).addCallback(self.assertEquals, "'foo=bar; baz=quux'" ) | def testRawSomeCookies(self): self.assertEquals(unittest.deferredResult(client.getPage(self.getHTTP("rawcookiemirror"), cookies={'foo': 'bar', 'baz': 'quux'})), "'foo=bar; baz=quux'") |
x['__class__'] = 'twisted.web.server.Request' | def getStateToCopyFor(self, issuer): # This is for distrib compatibility x = {} | |
try: from twisted.web import distrib except ImportError: pass else: pb.setCopierForClass(OldRequestAdapter, distrib.Request) | def renderHTTP(self, ctx): request = iweb.IOldRequest(ctx) result = defer.maybeDeferred(self.original.render, request).addCallback( self._handle_NOT_DONE_YET, request) return result | |
return static.File(os.path.join(pw_dir, self.userDirName)) | path = os.path.join(pw_dir, self.userDirName) if not os.path.exists(path): return error.NoResource() return static.File(path) | def getChild(self, name, request): if name == '': return self |
protocol.makeConnection(transport, self) | protocol.makeConnection(transport) | def doRead(self): """Called when my socket is ready for reading. |
def getChild(self, path, request): | def getChildWithDefault(self, path, request): | def getChild(self, path, request): res = ResourceScript(self.path, self.registry) return res.getChild(path, request) |
return res.getChild(path, request) | return res.getChildWithDefault(path, request) | def getChild(self, path, request): res = ResourceScript(self.path, self.registry) return res.getChild(path, request) |
self._helo = (None, self.transport.getPeer().host) | peer = self.transport.getPeer() try: host = peer.host except AttributeError: host = str(peer) self._helo = (None, host) | def connectionMade(self): # Ensure user-code always gets something sane for _helo self._helo = (None, self.transport.getPeer().host) self.sendCode(220, self.greeting()) self.setTimeout(self.timeout) |
peer = self.transport.getPeer().host self._helo = (rest, peer) | peer = self.transport.getPeer() try: host = peer.host except AttributeError: host = str(peer) self._helo = (rest, host) | def do_HELO(self, rest): peer = self.transport.getPeer().host self._helo = (rest, peer) self._from = None self._to = [] self.sendCode(250, '%s Hello %s, nice to meet you' % (self.host, peer)) |
for e in log.flushErrors(): | for e in twisted.python.log.flushErrors(): | def _runTearDown(self, ignored=None): cleanupDeferred = 0 try: d = self.tearDown() if d is not None and isinstance(d, defer.Deferred): d.addErrback(self.deferredError) d.addBoth(self.cleanup) cleanupDeferred = 1 except: testResult.addError(self, self._exc_info()) for e in log.flushErrors(): self.testResult.addError(sel... |
return self.errorModelFactory(request.args, outDict, err.value) | mf = self.errorModelFactory(request.args, outDict, err.value) return self.errback(mf) | def _ebModel(err): if err.trap(formmethod.FormException): return self.errorModelFactory(request.args, outDict, err.value) raise err |
return tapestry._ChildJuggler(outObj) | return tapestry._ChildJuggler(outObj).render(request) | def _ebModel(err): if err.trap(formmethod.FormException): return self.errorModelFactory(request.args, outDict, err.value) raise err |
del reapProcessHandlers[pid] | unregisterReapProcessHandler(pid, self) | def reapProcess(self): """Try to reap a process (without blocking) via waitpid. |
del reapProcessHandlers[pid] | unregisterReapProcessHandler(self.pid, self) | def reapProcess(self): """Try to reap a process (without blocking) via waitpid. |
def findAGoodName(x): return getattr(x, 'tapname', getattr(x, 'name', getattr(x, 'module'))) | return tapLookup | def findAGoodName(x): return getattr(x, 'tapname', getattr(x, 'name', getattr(x, 'module'))) |
def getModule(type): | def getModule(tapLookup, type): | def getModule(type): try: mod = tapLookup[type].load() return mod except KeyError: print """Please select one of: %s""" % string.join(tapMods) sys.exit(2) |
print """Please select one of: %s""" % string.join(tapMods) | print """Please select one of: %s""" % string.join(tapLookup.keys()) | def getModule(type): try: mod = tapLookup[type].load() return mod except KeyError: print """Please select one of: %s""" % string.join(tapMods) sys.exit(2) |
optFlags = [['xml', 'x', "DEPRECATED: same as --type=xml"], ['source', 's', "DEPRECATED: same as --type=source"], ['encrypted', 'e', "Encrypt file before writing"]] | optFlags = [['xml', 'x', "DEPRECATED: same as --type=xml"], ['source', 's', "DEPRECATED: same as --type=source"], ['encrypted', 'e', "Encrypt file before writing"], ['progress', 'p', "Show progress of plugin loading"], ['debug', 'd', "Show debug information for plugin loading"]] | def getModule(type): try: mod = tapLookup[type].load() return mod except KeyError: print """Please select one of: %s""" % string.join(tapMods) sys.exit(2) |
subCommands = [ [x, None, (lambda obj = y: obj.load().Options()), getattr(y, 'description', '')] for (x, y) in tapLookup.items() ] subCommands.sort() | def __init__(self, tapLookup): usage.Options.__init__(self) self.subCommands = [] for (x, y) in tapLookup.items(): self.subCommands.append( [x, None, (lambda obj = y: obj.load().Options()), getattr(y, 'description', '')] ) self.subCommands.sort() self['help'] = 0 | def getModule(type): try: mod = tapLookup[type].load() return mod except KeyError: print """Please select one of: %s""" % string.join(tapMods) sys.exit(2) |
def __init__(self): usage.Options.__init__(self) self['help'] = 0 | def __init__(self): usage.Options.__init__(self) self['help'] = 0 # default | |
options = GeneralOptions() | tapLookup = loadPlugins() options = GeneralOptions(tapLookup) | def run(): options = GeneralOptions() if hasattr(os, 'getgid'): options['uid'] = os.getuid() options['gid'] = os.getgid() try: options.parseOptions(sys.argv[1:]) except Exception, e: # XXX: While developing, I find myself frequently disabling # this except block when I want to see what screwed up code # caused my updat... |
mod = getModule(options.subCommand) | mod = getModule(tapLookup, options.subCommand) | def run(): options = GeneralOptions() if hasattr(os, 'getgid'): options['uid'] = os.getuid() options['gid'] = os.getgid() try: options.parseOptions(sys.argv[1:]) except Exception, e: # XXX: While developing, I find myself frequently disabling # this except block when I want to see what screwed up code # caused my updat... |
usage.Options.parseOptions(self, options or sys.argv[1:] or ["--help"]) | if options is None: options = sys.argv[1:] or ["--help"] usage.Options.parseOptions(self, options) | def parseOptions(self, options=None): usage.Options.parseOptions(self, options or sys.argv[1:] or ["--help"]) |
self.reactor.addEvent(self.hProcess, self, self.inConnectionLost) | self.reactor.addEvent(self.hProcess, self, 'inConnectionLost') | def __init__(self, reactor, protocol, command, args, environment, path): self.reactor = reactor self.protocol = protocol |
def install(self): | def install(): | def install(self): threadable.init(1) # change when we redo process stuff - process is probably # borked anyway. process.Process = Process r = Win32Reactor() import main main.installReactor(r) |
addEvent(self.hProcess, self, self.connectionLostNotify) | from twisted.internet import reactor reactor.addEvent(self.hProcess, self, self.connectionLostNotify) | def __init__(self, command, args, environment, path): # security attributes for pipes sAttrs = win32security.SECURITY_ATTRIBUTES() sAttrs.bInheritHandle = 1 |
def install(): reactor = Win32Reactor() reactor.install() __all__ = ["Win32Reactor"] | __all__ = ["Win32Reactor", "install"] | def install(): reactor = Win32Reactor() reactor.install() |
server supports the STARTTLS capability and our transport support | server supports the STARTTLS capability and our transport supports | def login(self, username, password): """Authenticate with the server using a username and password |
pass | def serverGreeting(self, caps): pass | |
channelOpenData = packOpen_direct_tcpip(self.hostport, addr) | addrTuple = (addr.host, addr.port) channelOpenData = packOpen_direct_tcpip(self.hostport, addrTuple) | def buildProtocol(self, addr): channel = self.klass(conn = self.conn) client = SSHForwardingClient(channel) channel.client = client channelOpenData = packOpen_direct_tcpip(self.hostport, addr) self.conn.openChannel(channel, channelOpenData) return client |
self.length = self.length * (10**len(m.group(1))) + int(m.group(1)) | self.length = self.length * (10**len(m.group(1))) + long(m.group(1)) | def doLength(self): m = NUMBER.match(self.__data) if not m.end(): if DEBUG: raise NetstringParseError(repr(self.__data)) else: raise NetstringParseError self.__data = self.__data[m.end():] if m.group(1): self.length = self.length * (10**len(m.group(1))) + int(m.group(1)) if m.group(2): self.__buffer = '' self.mode = DA... |
resp = http.Response(responsecode.UNAUTHORIZED) authHeaders = [] for factory in self.factories.itervalues(): authHeaders.append((factory.scheme, factory.getChallenge(req.remoteAddr))) resp.headers.setHeader('www-authenticate', authHeaders) return resp | return UnauthorizedResponse(self.factories, req.remoteAddr) | def render(self, req): resp = http.Response(responsecode.UNAUTHORIZED) |
self.fail("Incorrect content-type for PROPFIND response (%s != %s)" % (response.code, responsecode.MULTI_STATUS)) | self.fail("Incorrect content-type for PROPFIND response (%r not in %r)" % (content_type, (MimeType("text", "xml"), MimeType("application", "xml")))) | def check_result(response): response = IResponse(response) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.