rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
self.pollInterval = 0.1 | def __init__(self, queue, numThreads): """Starts multiple DownloaderThreads and stores data shared between them.""" self.queue = queue self.queueSem = threading.Semaphore() self.numSleeping = 0 self.threads = [] self.running = 1 | |
try: while self.running: time.sleep(self.pollInterval) except KeyboardInterrupt: self.running = 0 for thread in self.threads: thread.join() raise KeyboardInterrupt | def __init__(self, queue, numThreads): """Starts multiple DownloaderThreads and stores data shared between them.""" self.queue = queue self.queueSem = threading.Semaphore() self.numSleeping = 0 self.threads = [] self.running = 1 | |
time.sleep(0.1) | time.sleep(self.pool.pollInterval) | def run(self): """Thread-safe queue management, to feed items into download() and enqueue children. """ while self.pool.running: self.pool.queueSem.acquire() try: queueItem = self.pool.queue.pop() except IndexError: # Nothing in the queue. If all the threads are in this state, we're done self.pool.queueSem.release() if... |
relativeName = os.sep.join(file.name.split(os.sep)[1:]) | relativeName = os.sep.join(file.name.split("/")[1:]) | def download(self, destination, progress): downloadComplete = 0 try: # Extract the file as we download it urlFile = urllib2.urlopen(self.url) tar = tarfile.TarFile.open(None, "r|%s" % self.compression, urlFile) for file in tar: # Normally we'd just fall tar.extract(file, destination) here, # but we want to strip off th... |
self.xml.write('<target name="%s">%s</target>' % (arg, self.args[arg])) | self.xml.write('<target name="%s">%s</target>' % (arg, arg)) | def __init__(self, parseResults): (self.options, self.args) = parseResults self.xml = StringIO.StringIO() self.xml.write('<pgbuild title="Command Line Options" root="invocation">') for option in self.options.__dict__: value = getattr(self.options, option) if value != None: self.xml.write('<option name="%s">' % option) ... |
def __init__(self, queue, queueSem): self.queue = queue self.queueSem = queueSem | def __init__(self, pool): self.pool = pool | def __init__(self, queue, queueSem): self.queue = queue self.queueSem = queueSem threading.Thread.__init__(self) |
while True: self.queueSem.acquire() if len(self.queue) <= 0: self.queueSem.release() break queueItem = self.queue.pop() self.queueSem.release() | while self.pool.running: self.pool.queueSem.acquire() try: queueItem = self.pool.queue.pop() except IndexError: self.pool.queueSem.release() if self.pool.numSleeping == len(self.pool.threads)-1: break self.pool.numSleeping += 1 time.sleep(0.1) self.pool.numSleeping -= 1 continue self.pool.queueSem.release() | def run(self): """Thread-safe queue management, to feed items into download() and enqueue children. """ while True: self.queueSem.acquire() if len(self.queue) <= 0: self.queueSem.release() break queueItem = self.queue.pop() self.queueSem.release() newItems = self.download(queueItem) if newItems: self.queueSem.acquire()... |
self.queueSem.acquire() | self.pool.queueSem.acquire() | def run(self): """Thread-safe queue management, to feed items into download() and enqueue children. """ while True: self.queueSem.acquire() if len(self.queue) <= 0: self.queueSem.release() break queueItem = self.queue.pop() self.queueSem.release() newItems = self.download(queueItem) if newItems: self.queueSem.acquire()... |
self.queue.append(item) self.queueSem.release() | self.pool.queue.append(item) self.pool.queueSem.release() self.pool.running = False | def run(self): """Thread-safe queue management, to feed items into download() and enqueue children. """ while True: self.queueSem.acquire() if len(self.queue) <= 0: self.queueSem.release() break queueItem = self.queue.pop() self.queueSem.release() newItems = self.download(queueItem) if newItems: self.queueSem.acquire()... |
os.makedirs(destination) | try: os.makedirs(destination) except OSError: pass | def download(self, item): """Download an item from the queue, returning a list of more items to add to the queue. """ (object, destination) = item |
queue = [(self, destination)] queueSem = threading.Semaphore() threads = [] for i in xrange(numThreads): thread = DownloaderThread(queue, queueSem) threads.append(thread) thread.start() for thread in threads: thread.join() | DownloaderPool([(self, destination)], numThreads) | def download(self, destination, numThreads=5): |
f = open(commandLog) | try: f = open(commandLog) except IOError: return [] | def readLatestCommands(n=20): """Read the n latest commands, returning a list of (command, project, message) tuples""" f = open(commandLog) # Go to the end, and read backwards for n+1 newlines f.seek(-1,2) for i in xrange(n+1): while f.read(1) != "\n": f.seek(-2,1) f.seek(-2,1) f.readline() # Parse up some lines resu... |
f.seek(-1,2) for i in xrange(n+1): while f.read(1) != "\n": | try: f.seek(-1,2) for i in xrange(n+1): while f.read(1) != "\n": f.seek(-2,1) | def readLatestCommands(n=20): """Read the n latest commands, returning a list of (command, project, message) tuples""" f = open(commandLog) # Go to the end, and read backwards for n+1 newlines f.seek(-1,2) for i in xrange(n+1): while f.read(1) != "\n": f.seek(-2,1) f.seek(-2,1) f.readline() # Parse up some lines resu... |
f.seek(-2,1) f.readline() | f.readline() except: pass | def readLatestCommands(n=20): """Read the n latest commands, returning a list of (command, project, message) tuples""" f = open(commandLog) # Go to the end, and read backwards for n+1 newlines f.seek(-1,2) for i in xrange(n+1): while f.read(1) != "\n": f.seek(-2,1) f.seek(-2,1) f.readline() # Parse up some lines resu... |
line = f.readline().strip() results.append(line.split(" ", 2)) | line = f.readline() if not line: break line = line.strip() if line: results.append(line.split(" ", 2)) | def readLatestCommands(n=20): """Read the n latest commands, returning a list of (command, project, message) tuples""" f = open(commandLog) # Go to the end, and read backwards for n+1 newlines f.seek(-1,2) for i in xrange(n+1): while f.read(1) != "\n": f.seek(-2,1) f.seek(-2,1) f.readline() # Parse up some lines resu... |
raise TypeError('Connection object doesn\'t support neither read() or recv()') | raise TypeError('Connection object supports neither read() nor recv()') | def get(connection): """Get (and return) the next response in connection """ if hasattr(connection, 'read'): read = connection.read elif hasattr(connection, 'recv'): read = connection.recv else: raise TypeError('Connection object doesn\'t support neither read() or recv()') def safe_read(len, read=read): try: return rea... |
print pdict | def getPropertyDict(self): """Return a dictionary mapping element names of the form namespaceURI:localName to the property's full text. """ pdict = {} for child in self.getPropertiesDOM().childNodes: if child.nodeType == child.ELEMENT_NODE: name = "%s:%s" % (child.namespaceURI, child.localName) pdict[name] = PGBuild.XM... | |
pass | def show(self): pass def hide(self): pass def showMessage(self, text, metadata=None): pass | def lineReceived(self, line): global groups try: (command, project, message) = line.split(" ", 2) except ValueError: (command, project) = line.split(" ", 2) |
if __name__ = '__main__': | if __name__ == '__main__': | def fillRRD(lastTime, revision, time, user, lines): # Fudge the times a little if necessary so we don't have two updates from the same time if time <= lastTime[0]: time = lastTime[0] + 1 os.system('rrdtool update %s %d:%d' % (name, time, revision)) lastTime[0] = time |
log.getUserSummary(open("foo.html",'w')) log.createRRD('test.rrd') os.system("rrdtool graph boing.gif -s now-5year DEF:revs=test.rrd:revs:AVERAGE CDEF:f=revs LINE2:f os.system("ee boing.gif") | print "Saving user summary..." log.getUserSummary(open("user_summary.html",'w')) | def fillRRD(lastTime, revision, time, user, lines): # Fudge the times a little if necessary so we don't have two updates from the same time if time <= lastTime[0]: time = lastTime[0] + 1 os.system('rrdtool update %s %d:%d' % (name, time, revision)) lastTime[0] = time |
if subjectFields[0] in allowedCommands: if not messages: messages = [" "] | if subjectFields[0] in allowedTextCommands: | def connectionMade(self): import sys mailMsg = email.message_from_file(sys.stdin) f = open(logFile, "a") |
0x140A: 'kbd char', 0x140B: 'kbd keyup', 0x140C: 'kbd keydown', 0x1209: 'pntr move', 0x1205: 'pntr up', 0x1204: 'pntr down', 0x120D: 'bgclick', 0x1101: 'pntr raw', 0x1301: 'calib penpos', | 0x1001: 'theme inserted', 0x1002: 'theme removed', 0x1302: 'infilter', | def __init__(self, code): self.args = 'Unknown event parameter type, can\'t handle!', code |
if not self._bitmaps.has_key(text): self._bitmaps[text] = self.mkbitmap(text) return self._bitmaps[text] | if not self._bitmaps.has_key(image): self._bitmaps[image] = self.mkbitmap(image) return self._bitmaps[image] | def getBitmap(self, image): if not self._bitmaps.has_key(text): self._bitmaps[text] = self.mkbitmap(text) return self._bitmaps[text] |
tempPathNew = "temp_new_" + localPath tempPathOld = "temp_old_" + localPath | splitLocalPath = os.path.split(localPath) tempPathNew = os.path.join(splitLocalPath[0], "temp_new_" + splitLocalPath[1]) tempPathOld = os.path.join(splitLocalPath[0], "temp_old_" + splitLocalPath[1]) | def update(self, progress): """Update the package if possible. Return 1 if there was an update available, 0 if not.""" localPath = self.getLocalPath() task = progress.task("Checking for updates in package %s" % self) repo = self.getRepository(progress) |
queued = 1 | queued = self.server.checkevent() | def run(self): self.server.update() while 1: |
tempPathNew = localPath + ".temp-new" tempPathOld = localPath + ".temp-old" | tempPathNew = "temp_new_" + localPath tempPathOld = "temp_old_" + localPath | def update(self, progress): """Update the package if possible. Return 1 if there was an update available, 0 if not.""" localPath = self.getLocalPath() task = progress.task("Checking for updates in package %s" % self) repo = self.getRepository(progress) |
return r | if r[1]: return r else: return r[0], namespace | def resolve_constant(name, namespace=constants): if type(namespace) == type(()): # for cases where the argument is really supposed to be a string, yet there are contstants after this return name, namespace[0] if type(name) in (type(()), type([])): # multiple names are or'ed together; namespace returned is the last one ... |
data += '\0' * (4 - (len(data)%3)) | data += "\0" * (3 - (len(data)%3)) | def request(reqtype, data='', id=None): data = str(data) if id is None: id = reqtype # Pad the data to the next 32-bit boundary if (len(data)%3) != 0: data += '\0' * (4 - (len(data)%3)) return pack('LLHxx', id, len(data), reqtype) + data |
return id, _error_types[errt](args[1]) | return id, _error_types[errt](id, args[1]) | def _error(args): id = args[2] errt = args[0] return id, _error_types[errt](args[1]) |
return collectProgress(openSvn('up "%s"' % destination), progress) != 0 | return collectProgress(openSvn('up "%s"' % destination), progress, destination) != 0 | def update(self, destination, progress): """Update the package if possible. Return 1 if there was an update available, 0 if not.""" if self.isWorkingCopyPresent(destination): return collectProgress(openSvn('up "%s"' % destination), progress) != 0 else: # No working copy- do a complete download self.download(destination... |
def unwrap(self, x): if isinstance(x, PGBuild.XML.dom.Node): if not hasattr(x, 'node'): Element(x) return x.node if type(x)==type([]) or isinstance(x, PGBuild.XML.dom.minidom.NodeList): out = [] for item in x: out.append(self.unwrap(item)) return out return x | def unwrap(self, x): if isinstance(x, PGBuild.XML.dom.Node): if not hasattr(x, 'node'): # Create an Element() class if it hasn't been done Element(x) return x.node if type(x)==type([]) or isinstance(x, PGBuild.XML.dom.minidom.NodeList): out = [] for item in x: out.append(self.unwrap(item)) return out return x | |
return self.unwrap(self.wrapped[pos]) | return _getNode(self.wrapped[pos]) | def __getitem__(self, pos): return self.unwrap(self.wrapped[pos]) |
return self.unwrap(self.wrapped(*args, **kwargs)) | return _getNode(self.wrapped(*args, **kwargs)) | def __call__(self, *args, **kwargs): return self.unwrap(self.wrapped(*args, **kwargs)) |
setattr(self, attr, NodeWrapper(getattr(self.dom, attr))) | if _needsWrapper(getattr(self.dom, attr)): setattr(self, attr, NodeWrapper(getattr(self.dom, attr))) else: setattr(self, attr, _getNode(getattr(self.dom, attr))) | def __init__(self, dom): SCons.Node.Node.__init__(self) self.dom = dom dom.node = self |
print f | def SConscript(*ls, **kw): files, exports = GetSConscriptFilenames(ls, kw) default_fs = SCons.Node.FS.default_fs top = default_fs.Top sd = default_fs.SConstruct_dir.rdir() # evaluate each SConscript file results = [] for fn in files: stack.append(Frame(exports)) old_sys_path = sys.path try: if fn == "-": exec sys.std... | |
main_err = sys.stderr | def close(self, ev): app.server.rmcontext() self.tb = None | |
node.setAttribute("name", option) | node.setAttribute("name", str(option)) | def __init__(self, parseResults): (self.options, self.args) = parseResults xml.dom.minidom.Document.__init__(self) pgbuild = self.createElement("pgbuild") pgbuild.setAttribute("title", "Command Line Options") pgbuild.setAttribute("root", "invocation") self.appendChild(pgbuild) |
node.setAttribute("index", i) | node.setAttribute("index", str(i)) | def __init__(self, parseResults): (self.options, self.args) = parseResults xml.dom.minidom.Document.__init__(self) pgbuild = self.createElement("pgbuild") pgbuild.setAttribute("title", "Command Line Options") pgbuild.setAttribute("root", "invocation") self.appendChild(pgbuild) |
node.setAttribute("index", i) | node.setAttribute("index", str(i)) | def marshall(self, value): """Marshall an option value, return a list of DOM nodes. Initially I tried to use XML-RPC marshalling for this, but besides being far too verbose for this, it didn't fit in with PGBuild.Config's requirements for tag distinctness. """ nodes = [] if type(value) == list or type(value) == tuple: ... |
lastBotNumberOfChannels = 0 | def clientConnectionLost(self, connector, reason): reactor.stop() | |
self.dirMount(bootstrap.confPackage) | self.dirMount(bootstrap.confPackagePath) | def get_contents(self): return """ <pgbuild title="Bootstrap Configuration"> </pgbuild> """ |
str(self.package.getHostPlatform()), | str(self.package.getHostPlatform(ctx)), | def getBinaryPath(self, ctx): """Using the current bootstrap configuration and package build platform, get the binary path for this package.""" return os.path.join(ctx.config.eval('bootstrap/path[@name="bin"]/text()'), str(self.package.getHostPlatform()), self.getPathName()) |
progress.report(status, line[2:].strip()[len(destination)+1:]) | path = line[2:].strip() if path.startswith(destination): path = path[len(destination)+1:] progress.report(status, path) | def collectProgress(file, progress, destination): updatedFiles = 0 allOutput = "" while 1: line = file.readline() if not line: break allOutput += line status = expandStatus(line) if status: progress.report(status, line[2:].strip()[len(destination)+1:]) updatedFiles += 1 if file.close(): raise PGBuild.Errors.Environment... |
replace(string, '\\', '\\\\') replace(string, '\n', '\\n') replace(string, '"', '\\"') | string=replace(string, '\\', '\\\\') string=replace(string, '\n', '\\n') string=replace(string, '"', '\\"') | def quote_string(string): replace(string, '\\', '\\\\') replace(string, '\n', '\\n') replace(string, '"', '\\"') return string |
target_top = None | target_top = SCons.Node.FS.default_fs.Entry("src/hello-dev") print target_top | def run(config, progress): # Code to specify targets would go here targets = None if not targets: targets = SCons.Script.SConscript.default_targets # Convert our list of targets to nodes. The targets may be originally specified # as nodes, filenames, or aliases. target_top = None #target_top = "/home/micah/picogui/pgb... |
nodes = filter(lambda x: x is not None, map(Entry, targets)) | if targets: nodes = filter(lambda x: x is not None, map(Entry, targets)) else: nodes = [] | def Entry(x, top=target_top): if isinstance(x, SCons.Node.Node): node = x else: node = SCons.Node.Alias.default_ans.lookup(x) if node is None: node = SCons.Node.FS.default_fs.Entry(x, directory = top, create = 1) if top and not node.is_under(top): if isinstance(node, SCons.Node.FS.Dir) and top.is_under(node): node = to... |
return self.map.setdefault(widget.handle, {}).setdefault(evname, []) | if widget is None: handle = None else: handle = widget.handle return self.map.setdefault(handle, {}).setdefault(evname, []) | def get(self, widget, evname): return self.map.setdefault(widget.handle, {}).setdefault(evname, []) |
newProgress = StdProgress() | newProgress = Progress() | def task(self, name): self.color.write(" -" * len(self.taskStack)) self.color.write(" - ", ('bold',)) self.color.write("%s..." % name, ('bold', 'cyan')) self.color.write("\n") newProgress = StdProgress() newProgress.taskStack = self.taskStack[:] newProgress.taskStack.append(name) return newProgress |
root.removeChild(old) | print "Before: %s" % default.xpath("/pgbuild/packages") old.dom.parentNode.removeChild(old.dom) print " After: %s" % default.xpath("/pgbuild/packages") | def mergeElements(root): """Merge all identical elements under the given one, as defined in this module's document string. """ # Make a dictionary of signatures to (relatively) efficiently # determine whether any of our children are duplicates. d = {} for child in root.childNodes: sig = getElementSig(child) if d.has_ke... |
if oldNode.nodeType == newNode.nodeType and oldNOde.nodeName == newNode.nodeName: self.removeChild(oldNode) | if oldNode.nodeType == newNode.nodeType and oldNode.nodeName == newNode.nodeName: self.dom.removeChild(oldNode.dom) | def rTag(element, mdoc): element.mdoc = mdoc for child in element.childNodes: rTag(child, mdoc) |
subjectFields[1] = subjectFields[1:] | subjectFields[1] = subjectFields[1][1:] | def connectionMade(self): import sys mailMsg = email.message_from_file(sys.stdin) f = open(logFile, "a") f.write(mailMsg.as_string()) f.close() subjectFields = mailMsg['Subject'].split(" ") # This limits the length of the maximum message, mainly to prevent DOS'ing the bot too badly messages = mailMsg.get_payload().spl... |
return 'PGTH_P_USER+%d'%(value-constants['PGTH_P_USER']) | global userprops for p in userprops: if p[1]==value: return p[0] name='userprop%d'%(value-constants['PGTH_P_USER']) userprops.append((name, value)) return name | def lookup_propname(value): if properties.has_key(value): return properties[value] elif value > constants['PGTH_P_THEMEAUTO']: return 'themeauto%d'%(value-constants['PGTH_P_THEMEAUTO']) elif value > constants['PGTH_P_USER']: # This must be changed once Prop() is implemented in themec # Currently user properties cannot ... |
return '0x%06x'%value[0] | if type(value[0]) == StringType: return value[0] else: return '0x%06x'%value[0] | def formula(self, value, prec=len(operatorprecedence), side='N'): if value[1] in ('int', 'literal', 'xsize', 'ysize', 'var', 'bitmap', 'string', 'font'): return str(value[0]) elif value[1]=='direction': return lookup_constname('PG_DIR_', value[0]) elif value[1]=='lgop': return lookup_constname('PG_LGOP_', value[0]) eli... |
self.stack.append([unpack('!L', bytecode[p:p+4])[0], 'literal']) | self.stack.append([unpack('!l', bytecode[p:p+4])[0], 'literal']) | def __init__(self, bytecode): self.source='' self.stack=[['x','var'], ['y','var'], ['w','var'], ['h','var']] self.localvars=[['x','int'], ['y','int'], ['w','xsize'], ['h','ysize']] p=0 self.currentformula=[] while p<len(bytecode): # Hack to register local variables used by themec # TODO: proper naming of the vars opcod... |
self.transport.write("Announce %s %s\r\n" % (sys.argv[2], " ".join(sys.argv[3:]).split('\n')[0])) | self.transport.write("Announce %s %s\r\n" % (sys.argv[1], " ".join(sys.argv[2:]).split('\n')[0])) | def connectionMade(self): import sys self.transport.write("Announce %s %s\r\n" % (sys.argv[2], " ".join(sys.argv[3:]).split('\n')[0])) self.transport.loseConnection() |
if mutableForm: attributes = [] for key in mutableForm: | attributes = [] for key in mutableForm: value = mutableForm[key] if value is not None: | def linkURL(self, formKeys={}, useExistingForm=True): """Create a link to ourselves, including possibly-modified form values""" # Copy form attributes to a dictionary we can modify mutableForm = {} if useExistingForm: for key in self.form.keys(): mutableForm[key] = self.form[key].value mutableForm.update(formKeys) |
write('<a class="headingTab" href="%s">all sections</a>' % self.linkURL({'sections': ''})) | write('<a class="headingTab" href="%s">all sections</a>' % self.linkURL({'sections': None})) | def section_header(self, write): write("""<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>CIA bot statistics</title> <style type="text/css" media="all"> @import url(%s); </style> """ % self.css) if self.refresh is not None: write('<meta ... |
write('<a class="headingTab" href="%s">refresh off</a>' % self.linkURL({'refresh': 0})) | write('<a class="headingTab" href="%s">refresh off</a>' % self.linkURL({'refresh': None})) | def section_header(self, write): write("""<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>CIA bot statistics</title> <style type="text/css" media="all"> @import url(%s); </style> """ % self.css) if self.refresh is not None: write('<meta ... |
attrs= node.attributes | if hasattr(node, 'dom'): attrs= node.dom.attributes else: attrs= node.attributes | def axisfun_attribute(self,node,nodetest=None): attrs= node.attributes l= [] if attrs is None: return l for a in attrs.values(): if nodetest is None or nodetest(a): |
if end - start < 4: | if (end - start) * math.pi / 180 * img.size[0] < 20: | def drawSlice(start, end, color, shadow): centerAngle = (start + end) / 2 offset =(img.size[0] * relativeOffset * math.cos(centerAngle * math.pi / 180), img.size[1] * relativeOffset * math.sin(centerAngle * math.pi / 180)) if shadow: draw.pieslice((margin[0] + shadowAmount + offset[0], margin[1] + shadowAmount + offset... |
self.update() def update(self): | def __init__(self, rect, attr=None): Window.__init__(self, rect) if not attr: attr = curses.color_pair(070) self.attr = attr self.update() | |
self.addText(((str(Interface.timeStampClass()), self.attr),)) | self.update() def update(self): self.addText(((str(Interface.timeStampClass()), self.attr),), 0, 0) | def update(self): self.clear() self.win.bkgd(' ', self.attr) self.addText(((str(Interface.timeStampClass()), self.attr),)) self.win.refresh() |
self.clockUpdater.start() | self.cursesSem.acquire() | def __init__(self): try: self.clockUpdater = ClockUpdater() self.clockUpdater.start() self.stdscr = curses.initscr() curses.start_color() curses.noecho() curses.cbreak() curses.curs_set(0) self.stdscr.keypad(1) # Initialize all possible color pairs so we can specify # foreground and background colors in octal. for colo... |
self._data[index] = long(getattr(self, name), self._data[index]) | self._data[index] = long(getattr(self, name)) | def pack(self): format = getattr(self, 'format_' + self.dev, None) if format: if callable(format): for index, value in format(): self._data[index] = long(value) else: for index, name in format: self._data[index] = long(getattr(self, name), self._data[index]) return struct.pack(trigger_base_format, *self._data) |
self._write_lock = thread.allocate_lock() | if debug_threads: self._write_lock = verbose_lock() else: self._write_lock = thread.allocate_lock() | def __init__(self, address=None, display=None, stream=None, stream_read=0, poll=None): if stream: self._connection = stream try: self._write = self._connection.send except AttributeError: self._write = self._connection.write self.close_connection = noop self._wait = stream_read self._poll = poll else: self._connection ... |
self.lastClick = (t.x, t.y, camera.yaw, camera.pitch) | self.lastClick = (t.x, t.y, 0,0) | def handler(self, t, sender): # Move the ship and camera in reaction to the mouse position if t.dev == 'mouse': if t.name == 'down': self.lastClick = (t.x, t.y, camera.yaw, camera.pitch) if t.name == 'move' and t.buttons: camera.yaw = float(t.x - self.lastClick[0] + self.lastClick[2]) camera.pitch = float(t.y - self.la... |
print "socketName is " + socketName | def clientConnectionLost(self, connector, reason): reactor.stop() | |
def testNotFound(self): response = self.publish('/foobar', basic='mgr:mgrpw', handle_errors=True) self.assertEqual(response.getStatus(), 404) body = response.getBody() self.assert_( 'The page that you are trying to access is not available' in body) def test_suite(): return unittest.TestSuite(( unittest.makeSuite(TestN... | def __call__(self, *args, **kw): self.request.response.setStatus(404) return self.index(*args, **kw) | def testNotFound(self): response = self.publish('/foobar', basic='mgr:mgrpw', handle_errors=True) self.assertEqual(response.getStatus(), 404) body = response.getBody() self.assert_( 'The page that you are trying to access is not available' in body) |
authservice = DummyAuthService() request.setPrincipal(contained(DummyPrincipal(23), authservice)) | request.setPrincipal(DummyPrincipal(23)) | def test(self): exception = Exception() try: raise exception except: pass request = TestRequest('/') authservice = DummyAuthService() request.setPrincipal(contained(DummyPrincipal(23), authservice)) u = Unauthorized(exception, request) u.issueChallenge() |
self.failUnless(authservice.request is request) self.assertEqual(authservice.principal_id, 23) | self.failUnless(self.authservice.request is request) self.assertEqual(self.authservice.principal_id, 23) | def test(self): exception = Exception() try: raise exception except: pass request = TestRequest('/') authservice = DummyAuthService() request.setPrincipal(contained(DummyPrincipal(23), authservice)) u = Unauthorized(exception, request) u.issueChallenge() |
authservice = DummyAuthService() | def testPluggableAuthService(self): exception = Exception() try: raise exception except: pass request = TestRequest('/') authservice = DummyAuthService() psrc = DummyPrincipalSource() psrc = contained(psrc, authservice) request.setPrincipal(contained(DummyPrincipal(23), psrc)) u = Unauthorized(exception, request) u.iss... | |
psrc = contained(psrc, authservice) request.setPrincipal(contained(DummyPrincipal(23), psrc)) | request.setPrincipal(DummyPrincipal(23)) | def testPluggableAuthService(self): exception = Exception() try: raise exception except: pass request = TestRequest('/') authservice = DummyAuthService() psrc = DummyPrincipalSource() psrc = contained(psrc, authservice) request.setPrincipal(contained(DummyPrincipal(23), psrc)) u = Unauthorized(exception, request) u.iss... |
self.failUnless(authservice.request is request) self.assertEqual(authservice.principal_id, 23) | self.failUnless(self.authservice.request is request) self.assertEqual(self.authservice.principal_id, 23) | def testPluggableAuthService(self): exception = Exception() try: raise exception except: pass request = TestRequest('/') authservice = DummyAuthService() psrc = DummyPrincipalSource() psrc = contained(psrc, authservice) request.setPrincipal(contained(DummyPrincipal(23), psrc)) u = Unauthorized(exception, request) u.iss... |
if f: reqdict[(PreReq, n, r, v)] = True else: reqdict[(Req, n, r, v)] = True | if ((r is not None and r != "=") or ((Prv, n, v) not in prvdict)): if f: reqdict[(PreReq, n, r, v)] = True else: reqdict[(Req, n, r, v)] = True | def load(self): |
cnfargs.append((Cnf, n[i], CM.get(f[i]&CF), vi)) | if i==0 and type(f) != list: fi = f else: fi = f[i] cnfargs.append((Cnf, n[i], CM.get(fi&CF), vi)) | def load(self): CM = self.COMPMAP CF = self.COMPFLAGS Pkg = RPMPackage Prv = RPMProvides NPrv = RPMNameProvides PreReq = RPMPreRequires Req = RPMRequires Obs = RPMObsoletes Cnf = RPMConflicts prog = iface.getProgress(self._cache) for h, offset in self.getHeaders(prog): if h[1106]: # RPMTAG_SOURCEPACKAGE continue arch =... |
upgargs.append((Obs, n[i], CM.get(f[i]&CF), vi)) | if i==0 and type(f) != list: fi = f else: fi = f[i] upgargs.append((Obs, n[i], CM.get(fi&CF), vi)) | def load(self): CM = self.COMPMAP CF = self.COMPFLAGS Pkg = RPMPackage Prv = RPMProvides NPrv = RPMNameProvides PreReq = RPMPreRequires Req = RPMRequires Obs = RPMObsoletes Cnf = RPMConflicts prog = iface.getProgress(self._cache) for h, offset in self.getHeaders(prog): if h[1106]: # RPMTAG_SOURCEPACKAGE continue arch =... |
self._window.connect("destroy", lambda x: gtk.main_quit()) | def delete(widget, event): gtk.main_quit() return True self._window.connect("delete-event", delete) | def __init__(self, ctrl): GtkInterface.__init__(self, ctrl) |
if fetchedsize and self._starttime: self._mirror.addInfo(time=time.time()-self._starttime, size=fetchedsize) | def setSucceeded(self, targetpath, fetchedsize=0): if fetchedsize and self._starttime: self._mirror.addInfo(time=time.time()-self._starttime, size=fetchedsize) self._status = SUCCEEDED self._targetpath = targetpath self._progress.setSubDone(self._urlobj.original) self._progress.show() | |
self._progress.setSubDone(self._urlobj.original) self._progress.show() | if self._starttime: if fetchedsize: self._mirror.addInfo(time=time.time()-self._starttime, size=fetchedsize) self._progress.setSubDone(self._urlobj.original) self._progress.show() | def setSucceeded(self, targetpath, fetchedsize=0): if fetchedsize and self._starttime: self._mirror.addInfo(time=time.time()-self._starttime, size=fetchedsize) self._status = SUCCEEDED self._targetpath = targetpath self._progress.setSubDone(self._urlobj.original) self._progress.show() |
self._mirror.addInfo(failed=1) | def setFailed(self, reason): self._mirror.addInfo(failed=1) self._status = FAILED self._failedreason = reason self._progress.setSubStopped(self._urlobj.original) self._progress.show() | |
self._progress.setSubStopped(self._urlobj.original) self._progress.show() | if self._starttime: self._mirror.addInfo(failed=1) self._progress.setSubStopped(self._urlobj.original) self._progress.show() | def setFailed(self, reason): self._mirror.addInfo(failed=1) self._status = FAILED self._failedreason = reason self._progress.setSubStopped(self._urlobj.original) self._progress.show() |
fetcher.setSucceeded(url, localpath) | item.setSucceeded(localpath) | def runLocal(self, caching=None): fetcher = self._fetcher if not caching: caching = fetcher.getCaching() if caching is not NEVER: uncompressor = fetcher.getUncompressor() for i in range(len(self._queue)-1,-1,-1): item = self._queue[i] localpath = self.getLocalPath(item) uncomphandler = uncompressor.getHandler(localpath... |
fetcher.setFailed(url, reason) | item.setFailed(reason) | def runLocal(self, caching=None): fetcher = self._fetcher if not caching: caching = fetcher.getCaching() if caching is not NEVER: uncompressor = fetcher.getUncompressor() for i in range(len(self._queue)-1,-1,-1): item = self._queue[i] localpath = self.getLocalPath(item) uncomphandler = uncompressor.getHandler(localpath... |
if isinst(upgpkg): | if not force and isinst(upgpkg): | def _updown(self, pkg, force): trans = self._trans changeset = self._changeset locked = self._locked depth = self._depth pruneweight = self._pruneweight self.trace(1, "_updown(%s, pw=%f, yw=%f, f=%d)", (pkg, pruneweight, self._yieldweight, force)) |
if isinst(prvpkg): | if not force and isinst(prvpkg): | def _updown(self, pkg, force): trans = self._trans changeset = self._changeset locked = self._locked depth = self._depth pruneweight = self._pruneweight self.trace(1, "_updown(%s, pw=%f, yw=%f, f=%d)", (pkg, pruneweight, self._yieldweight, force)) |
if prob[4] & rpm.RPMDEP_SENSE_REQUIRES: line = "%s is required by %s" % (name1, name2) | if prob[4] == rpm.RPMDEP_SENSE_REQUIRES: line = "%s requires %s" % (name1, name2) | def commit(self, install, remove, pkgpath): |
PYTHONLIB = sysconfig.get_python_lib(1) | PYTHONLIB = os.path.join(get_python_lib(standard_lib=1, prefix=""), "site-packages") | def copy_tree(*args, **kwargs): outputs = copy_tree_orig(*args, **kwargs) for i in range(len(outputs)): if outputs[i].endswith("bin/smart.py"): outputs[i] = outputs[i][:-3] return outputs |
pruneweight, self._yieldweight, | pruneweight, yieldweight, | def __init__(self): Task.__init__(self, parent, self.evacuate(), cs, lk, pruneweight, self._yieldweight, csweight, 0.0001, order, "evacuate requiring") |
isinst = changeset.installed | def _remove(self, pkg, changeset, locked, pending, pruneweight, depth=0): depth += 1 trace(1, depth, "_remove(%s, pw=%f)", (pkg, pruneweight)) | |
if self._policy.getWeight(changeset) > pruneweight: | optweight = self._policy.getWeight(changeset) for necpkg in self.getNecessary(pkg): if isinst(necpkg): optweight += self._policy.getBestUpdownDeltaWeight(necpkg) if optweight > pruneweight: | def _remove(self, pkg, changeset, locked, pending, pruneweight, depth=0): depth += 1 trace(1, depth, "_remove(%s, pw=%f)", (pkg, pruneweight)) |
return ''.join(c for c in s if chk(c)) | return ''.join([c for c in s if chk(c)]) | def chk(c): if intag[0]: intag[0] = (c != '>') return False elif c == '<': intag[0] = True return False return True |
prv.conlfictedby = [cnf] | prv.conflictedby = [cnf] | def linkDeps(self): reqnames = {} for req in self._requires: for name in req.getMatchNames(): lst = reqnames.get(name) if lst: lst.append(req) else: reqnames[name] = [req] upgnames = {} for upg in self._upgrades: for name in upg.getMatchNames(): lst = upgnames.get(name) if lst: lst.append(upg) else: upgnames[name] = [u... |
trace(3, depth, "feasible upg alternative: %s", (upgpkg)) | def _updown(self, pkg, changeset, locked, pruneweight, depth=0, force=0): depth += 1 trace(1, depth, "_updown(%s, pw=%f, f=%d)", (pkg, pruneweight, force)) | |
trace(3, depth, "feasible dwn alternative: %s", (dwnpkg)) | def _updown(self, pkg, changeset, locked, pruneweight, depth=0, force=0): depth += 1 trace(1, depth, "_updown(%s, pw=%f, f=%d)", (pkg, pruneweight, force)) | |
trace(3, depth, "feasible delete alternative") | def _updown(self, pkg, changeset, locked, pruneweight, depth=0, force=0): depth += 1 trace(1, depth, "_updown(%s, pw=%f, f=%d)", (pkg, pruneweight, force)) | |
trace(2, depth, "feasible PENDING_INSTALL alternative: %s", (prvpkg)) | def _pending(self, changeset, locked, pending, pruneweight, depth=0): depth += 1 if traceVerbosity<4: trace(1, depth, "_pending(pw=%f)", (pruneweight)) else: trace(4, depth, "_pending(%s, pw=%f)", (pending, pruneweight)) | |
trace(3, depth, "feasible PENDING_REMOVE prv alternative: %s", (prvpkg)) | def _pending(self, changeset, locked, pending, pruneweight, depth=0): depth += 1 if traceVerbosity<4: trace(1, depth, "_pending(pw=%f)", (pruneweight)) else: trace(4, depth, "_pending(%s, pw=%f)", (pending, pruneweight)) | |
trace(3, depth, "feasible PENDING_REMOVE remove alternative") | def _pending(self, changeset, locked, pending, pruneweight, depth=0): depth += 1 if traceVerbosity<4: trace(1, depth, "_pending(pw=%f)", (pruneweight)) else: trace(4, depth, "_pending(%s, pw=%f)", (pending, pruneweight)) | |
trace(3, depth, "feasible _fix install alternative") | def _fix(self, pkgs, changeset, locked, pending, pruneweight, depth=0): depth += 1 trace(1, depth, "_fix()") | |
trace(3, depth, "feasible _fix remove alternative") | def _fix(self, pkgs, changeset, locked, pending, pruneweight, depth=0): depth += 1 trace(1, depth, "_fix()") |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.