rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
def __init__(self, rootLogDir=r"C:\Temp\logdir", debug=False):
def __init__(self, options):
def __init__(self, rootLogDir=r"C:\Temp\logdir", debug=False): self.debug = debug self.rootLogDir = os.path.normpath(rootLogDir) try: os.makedirs(self.rootLogDir, 0777) #TODO: change this to makedirs??? except OSError, detail: if(detail.errno==17): #if directory already exists, swallow the error pass else: print "O...
self.debug = debug
self.options = options
def __init__(self, rootLogDir=r"C:\Temp\logdir", debug=False): self.debug = debug self.rootLogDir = os.path.normpath(rootLogDir) try: os.makedirs(self.rootLogDir, 0777) #TODO: change this to makedirs??? except OSError, detail: if(detail.errno==17): #if directory already exists, swallow the error pass else: print "O...
self.rootLogDir = os.path.normpath(rootLogDir)
self.options.dirName = os.path.normpath(self.options.dirName)
def __init__(self, rootLogDir=r"C:\Temp\logdir", debug=False): self.debug = debug self.rootLogDir = os.path.normpath(rootLogDir) try: os.makedirs(self.rootLogDir, 0777) #TODO: change this to makedirs??? except OSError, detail: if(detail.errno==17): #if directory already exists, swallow the error pass else: print "O...
os.makedirs(self.rootLogDir, 0777)
os.makedirs(self.options.dirName, 0777)
def __init__(self, rootLogDir=r"C:\Temp\logdir", debug=False): self.debug = debug self.rootLogDir = os.path.normpath(rootLogDir) try: os.makedirs(self.rootLogDir, 0777) #TODO: change this to makedirs??? except OSError, detail: if(detail.errno==17): #if directory already exists, swallow the error pass else: print "O...
self.systemlog = open(r"C:\Temp\logdir\systemlog.txt", 'a')
def __init__(self, rootLogDir=r"C:\Temp\logdir", debug=False): self.debug = debug self.rootLogDir = os.path.normpath(rootLogDir) try: os.makedirs(self.rootLogDir, 0777) #TODO: change this to makedirs??? except OSError, detail: if(detail.errno==17): #if directory already exists, swallow the error pass else: print "O...
def WriteToLogFile(self, event, options): loggable = self.OpenLogFile(event, options.noLog)
def WriteToLogFile(self, event): loggable = self.TestForNoLog(event)
def WriteToLogFile(self, event, options): loggable = self.OpenLogFile(event, options.noLog) if not loggable: # if the program is in the no-log list, we return without writing to log. if self.debug: print "not loggable, we are outta here" return if self.debug: print "loggable, lets log it" asci...
if self.debug: print "not loggable, we are outta here"
if self.options.debug: print "not loggable, we are outta here"
def WriteToLogFile(self, event, options): loggable = self.OpenLogFile(event, options.noLog) if not loggable: # if the program is in the no-log list, we return without writing to log. if self.debug: print "not loggable, we are outta here" return if self.debug: print "loggable, lets log it" asci...
if self.debug: print "loggable, lets log it"
if self.options.debug: print "loggable, lets log it"
def WriteToLogFile(self, event, options): loggable = self.OpenLogFile(event, options.noLog) if not loggable: # if the program is in the no-log list, we return without writing to log. if self.debug: print "not loggable, we are outta here" return if self.debug: print "loggable, lets log it" asci...
if options.parseBackspace == True:
if self.options.parseBackspace == True:
def WriteToLogFile(self, event, options): loggable = self.OpenLogFile(event, options.noLog) if not loggable: # if the program is in the no-log list, we return without writing to log. if self.debug: print "not loggable, we are outta here" return if self.debug: print "loggable, lets log it" asci...
if options.parseEscape == True:
if self.options.parseEscape == True:
def WriteToLogFile(self, event, options): loggable = self.OpenLogFile(event, options.noLog) if not loggable: # if the program is in the no-log list, we return without writing to log. if self.debug: print "not loggable, we are outta here" return if self.debug: print "loggable, lets log it" asci...
if event.Ascii == 13 and options.addLineFeed == True:
if event.Ascii == 13 and self.options.addLineFeed == True:
def WriteToLogFile(self, event, options): loggable = self.OpenLogFile(event, options.noLog) if not loggable: # if the program is in the no-log list, we return without writing to log. if self.debug: print "not loggable, we are outta here" return if self.debug: print "loggable, lets log it" asci...
if event.Ascii == 8 and options.parseBackspace == True:
if event.Ascii == 8 and self.options.parseBackspace == True:
def WriteToLogFile(self, event, options): loggable = self.OpenLogFile(event, options.noLog) if not loggable: # if the program is in the no-log list, we return without writing to log. if self.debug: print "not loggable, we are outta here" return if self.debug: print "loggable, lets log it" asci...
if event.Ascii == 27 and options.parseEscape == True:
if event.Ascii == 27 and self.options.parseEscape == True:
def WriteToLogFile(self, event, options): loggable = self.OpenLogFile(event, options.noLog) if not loggable: # if the program is in the no-log list, we return without writing to log. if self.debug: print "not loggable, we are outta here" return if self.debug: print "loggable, lets log it" asci...
if event.Key == options.flushKey:
if event.Key == self.options.flushKey:
def WriteToLogFile(self, event, options): loggable = self.OpenLogFile(event, options.noLog) if not loggable: # if the program is in the no-log list, we return without writing to log. if self.debug: print "not loggable, we are outta here" return if self.debug: print "loggable, lets log it" asci...
self.systemlog.flush()
def WriteToLogFile(self, event, options): loggable = self.OpenLogFile(event, options.noLog) if not loggable: # if the program is in the no-log list, we return without writing to log. if self.debug: print "not loggable, we are outta here" return if self.debug: print "loggable, lets log it" asci...
def OpenLogFile(self, event, noLog):
def TestForNoLog(self, event): '''This function returns False if the process name associated with an event is listed in the noLog option, and True otherwise.''' self.processName = self.GetProcessNameFromHwnd(event.Window) if self.options.noLog != None: for path in self.options.noLog: if os.stat(path) == os.stat(self.p...
def OpenLogFile(self, event, noLog): filter=r"[\\\/\:\*\?\"\<\>\|]+" #regexp filter for the non-allowed characters in windows filenames. subDirName = self.GetProcessNameFromHwnd(event.Window) #our subdirname is the full path of the process owning the hwnd. if noLog != None: for path in noLog: #...
subDirName = self.GetProcessNameFromHwnd(event.Window) if noLog != None: for path in noLog: if os.stat(path) == os.stat(subDirName): if self.debug: print "we dont log this" return False if self.debug: print "we log this" subDirName = re.sub(filter,r'__',subDirName)
subDirName = re.sub(filter,r'__',self.processName)
def OpenLogFile(self, event, noLog): filter=r"[\\\/\:\*\?\"\<\>\|]+" #regexp filter for the non-allowed characters in windows filenames. subDirName = self.GetProcessNameFromHwnd(event.Window) #our subdirname is the full path of the process owning the hwnd. if noLog != None: for path in noLog: #...
os.makedirs(os.path.join(self.rootLogDir, subDirName), 0777)
os.makedirs(os.path.join(self.options.dirName, subDirName), 0777)
def OpenLogFile(self, event, noLog): filter=r"[\\\/\:\*\?\"\<\>\|]+" #regexp filter for the non-allowed characters in windows filenames. subDirName = self.GetProcessNameFromHwnd(event.Window) #our subdirname is the full path of the process owning the hwnd. if noLog != None: for path in noLog: #...
filename = time.strftime('%Y%m%d') + "_" + str(event.Window) + "_" + WindowName + ".txt"
filename = time.strftime('%Y%m%d') + "_" + str(event.Window) + "_" + WindowName filename = filename[0:200] + ".txt"
def OpenLogFile(self, event, noLog): filter=r"[\\\/\:\*\?\"\<\>\|]+" #regexp filter for the non-allowed characters in windows filenames. subDirName = self.GetProcessNameFromHwnd(event.Window) #our subdirname is the full path of the process owning the hwnd. if noLog != None: for path in noLog: #...
if self.writeTarget != os.path.join(self.rootLogDir, subDirName, filename):
if self.writeTarget != os.path.join(self.options.dirName, subDirName, filename):
def OpenLogFile(self, event, noLog): filter=r"[\\\/\:\*\?\"\<\>\|]+" #regexp filter for the non-allowed characters in windows filenames. subDirName = self.GetProcessNameFromHwnd(event.Window) #our subdirname is the full path of the process owning the hwnd. if noLog != None: for path in noLog: #...
if self.debug:
if self.options.debug:
def OpenLogFile(self, event, noLog): filter=r"[\\\/\:\*\?\"\<\>\|]+" #regexp filter for the non-allowed characters in windows filenames. subDirName = self.GetProcessNameFromHwnd(event.Window) #our subdirname is the full path of the process owning the hwnd. if noLog != None: for path in noLog: #...
self.systemlog.write("flushing and closing old log\n")
def OpenLogFile(self, event, noLog): filter=r"[\\\/\:\*\?\"\<\>\|]+" #regexp filter for the non-allowed characters in windows filenames. subDirName = self.GetProcessNameFromHwnd(event.Window) #our subdirname is the full path of the process owning the hwnd. if noLog != None: for path in noLog: #...
self.writeTarget = os.path.join(self.rootLogDir, subDirName, filename) if self.debug:
self.writeTarget = os.path.join(self.options.dirName, subDirName, filename) if self.options.debug:
def OpenLogFile(self, event, noLog): filter=r"[\\\/\:\*\?\"\<\>\|]+" #regexp filter for the non-allowed characters in windows filenames. subDirName = self.GetProcessNameFromHwnd(event.Window) #our subdirname is the full path of the process owning the hwnd. if noLog != None: for path in noLog: #...
self.systemlog.write("writeTarget: " + self.writeTarget + "\n")
def OpenLogFile(self, event, noLog): filter=r"[\\\/\:\*\?\"\<\>\|]+" #regexp filter for the non-allowed characters in windows filenames. subDirName = self.GetProcessNameFromHwnd(event.Window) #our subdirname is the full path of the process owning the hwnd. if noLog != None: for path in noLog: #...
return True
def OpenLogFile(self, event, noLog): filter=r"[\\\/\:\*\?\"\<\>\|]+" #regexp filter for the non-allowed characters in windows filenames. subDirName = self.GetProcessNameFromHwnd(event.Window) #our subdirname is the full path of the process owning the hwnd. if noLog != None: for path in noLog: #...
if self.debug == False:
if not self.options.debug:
def PrintStuff(self, stuff): if self.debug == False: self.log.write(stuff) self.systemlog.write(stuff) else: sys.stdout.write(stuff)
self.systemlog.write(stuff)
def PrintStuff(self, stuff): if self.debug == False: self.log.write(stuff) self.systemlog.write(stuff) else: sys.stdout.write(stuff)
except OSError, detail: if(detail.errno==17): pass else: self.PrintDebug(sys.exc_info()[0] + ", " + sys.exc_info()[1] + "\n") return False except: self.PrintDebug("Unexpected error: " + sys.exc_info()[0] + ", " + sys.exc_info()[1] + "\n")
except OSError, detail: if(detail.errno==17): pass else: self.PrintDebug(sys.exc_info()[0] + ", " + sys.exc_info()[1] + "\n")
def OpenLogFile(self, event): if self.options.oneFile != None: if self.writeTarget == "": self.writeTarget = os.path.join(os.path.normpath(self.options.dirName), os.path.normpath(self.options.oneFile)) try: self.log = open(self.writeTarget, 'a') except OSError, detail: if(detail.errno==17): #if file already exists, s...
filename = time.strftime('%Y%m%d') + "_" + str(event.Window) + "_" + WindowName
filename = time.strftime('%Y%m%d') + "_" + str(event.Window) + "_" + WindowName + ".txt"
def OpenLogFile(self, event): if self.options.oneFile != None: if self.writeTarget == "": self.writeTarget = os.path.join(os.path.normpath(self.options.dirName), os.path.normpath(self.options.oneFile)) try: self.log = open(self.writeTarget, 'a') except OSError, detail: if(detail.errno==17): #if file already exists, s...
firstMark = [0, 0xc0, 0xc1, 0xf0] [byteLen - 1]
firstMark = [0, 0xc0, 0xe0, 0xf0] [byteLen - 1]
def symbolToUTF8(codePoint): byteLen = 1 for k in [0x0000007F, 0x000007FF, 0x0000FFFF, 0x001FFFFF]: if codePoint <= k: break byteLen += 1 else: raise Exception("UTF-8 Error: Can not encode codePoint [" + codePoint + "] in UTF-8. It is bigger than 0x001FFFFF") result = [0] * byteLen c = codePoint k = byteLen - 1 if by...
byteLen += 1 if byteLen > 4:
byteLen += 1 b <<= 1 if byteLen > 4:
def readSymbol(sourceFun): first = sourceFun(1) if len(first) == 0: return None b = ord(first) # number of 1's: 0, 2, 3, 4 byteLen = 1 while b & 0x80: byteLen += 1 if byteLen > 4: raise Exception("UTF-8 Error: Incorrect UTF-8 encoding" +" (first octet of symbol = 0x%x)" % ord(first)) b <<= 1 if byteLen > 1: byteLen -= ...
+" (first octet of symbol = 0x%x)" % ord(first)) b <<= 1 if byteLen > 1:
+" (first octet of symbol = 0x%x)" % ord(first)) elif byteLen > 1:
def readSymbol(sourceFun): first = sourceFun(1) if len(first) == 0: return None b = ord(first) # number of 1's: 0, 2, 3, 4 byteLen = 1 while b & 0x80: byteLen += 1 if byteLen > 4: raise Exception("UTF-8 Error: Incorrect UTF-8 encoding" +" (first octet of symbol = 0x%x)" % ord(first)) b <<= 1 if byteLen > 1: byteLen -= ...
def symbolToUTF8(codePoint): byteLen = 1 for k in [0x0000007F, 0x000007FF, 0x0000FFFF, 0x001FFFFF]: if codePoint < k:
def symbolToUTF8(codePoint): byteLen = 1 for k in [0x0000007F, 0x000007FF, 0x0000FFFF, 0x001FFFFF]: if codePoint <= k:
def symbolToUTF8(codePoint): byteLen = 1 for k in [0x0000007F, 0x000007FF, 0x0000FFFF, 0x001FFFFF]: if codePoint < k: break byteLen += 1 if byteLen > 4: raise Exception("UTF-8 Error: Can not encode codePoint [" + codePoint + "] in UTF-8 (it is too big)") result = [0] * byteLen c = codePoint k = byteLen - 1 if byteLen ...
if byteLen > 4: raise Exception("UTF-8 Error: Can not encode codePoint [" + codePoint + "] in UTF-8 (it is too big)") result = [0] * byteLen
else: raise Exception("UTF-8 Error: Can not encode codePoint [" + codePoint + "] in UTF-8. It is bigger than 0x001FFFFF") result = [0] * byteLen
def symbolToUTF8(codePoint): byteLen = 1 for k in [0x0000007F, 0x000007FF, 0x0000FFFF, 0x001FFFFF]: if codePoint < k: break byteLen += 1 if byteLen > 4: raise Exception("UTF-8 Error: Can not encode codePoint [" + codePoint + "] in UTF-8 (it is too big)") result = [0] * byteLen c = codePoint k = byteLen - 1 if byteLen ...
def __eq__(self, other): return self.url == other.url
def __init__(self, url): self.url = url
"Reference to a remote interface."
def __init__(self, url): self.url = url
self.typename_streamer.read(stream, stream.read(1))
typeName = self.typename_streamer.read(stream, stream.read(1))
def read(self, stream, prefix): assert prefix in self.codes # skip typeNmae of remote interface self.typename_streamer.read(stream, stream.read(1)) # read url url = self.url_streamer(stream, stream.read(1)) # NOTE: non HTTP transports are not yet supported. # TODO: (See comments to HttpProxy class) return RemoteRefere...
url = self.url_streamer(stream, stream.read(1))
url = self.url_streamer.read(stream, stream.read(1))
def read(self, stream, prefix): assert prefix in self.codes # skip typeNmae of remote interface self.typename_streamer.read(stream, stream.read(1)) # read url url = self.url_streamer(stream, stream.read(1)) # NOTE: non HTTP transports are not yet supported. # TODO: (See comments to HttpProxy class) return RemoteRefere...
stream.write(self.codes[0]) typeName, url = remote self.type_streamer.write(stream, typeName)
stream.write(self.codes[0]) typeName = "Python" self.typename_streamer.write(stream, typeName)
def write(self, stream, remote): "remote - RemoteReference-like object" stream.write(self.codes[0]) typeName, url = remote self.type_streamer.write(stream, typeName) self.url_streamer.write(stream, remote.url)
message = proxy.hello() assert message == message
msg = proxy.hello() assert message == msg
def callTest0(url): srv = TestServer() srv.setDaemon(True) srv.start() proxy = HttpProxy(url) message = proxy.hello() assert message == message try: proxy.askBitchy() assert False # should not get here except Exception, e: # print traceback.format_exc() # debug pass if False: print "Some performance measurements..."...
if ch==curses.KEY_LEFT and self.carx>0:
if ch==curses.KEY_LEFT and self.carx>0 and self.slip<=0:
def key(self, ch): delta = 0 if ch==curses.KEY_LEFT and self.carx>0: delta = -1 elif ch==curses.KEY_RIGHT and self.carx<self.width-1: delta = 1 elif ch==ESC: self.esc=1 self.carx += delta self.update_car(delta)
elif ch==curses.KEY_RIGHT and self.carx<self.width-1:
elif ch==curses.KEY_RIGHT and self.carx<self.width-1 and self.slip<=0:
def key(self, ch): delta = 0 if ch==curses.KEY_LEFT and self.carx>0: delta = -1 elif ch==curses.KEY_RIGHT and self.carx<self.width-1: delta = 1 elif ch==ESC: self.esc=1 self.carx += delta self.update_car(delta)
self.crash = c!=ord(ROAD) and c!=ord(BONUS)
self.crash = c not in (ord(ROAD), ord(BONUS), ord(OIL), ord(CAR)) if c==ord(OIL): self.slip += OIL_DUR
def update_car(self, delta): if self.bx!=None: self.race_win.addstr(0, self.rx+len(EDGE)+self.bx, BONUS) if self.ox!=None: self.race_win.addstr(0, self.rx+len(EDGE)+self.ox, OBS) c = self.race_win.inch(self.cary, self.carx) if c==ord(BONUS): self.score += SCORE_BONUS self.crash = c!=ord(ROAD) and c!=ord(BONUS) if delta...
self.log = open("event.log", "w")
def __init__(self, win, tick, tick_func, key_func, quit_func): self.log = open("event.log", "w") self.win = win self.tick = tick self.tick_func = tick_func self.key_func = key_func self.quit_func = quit_func self.next_tick = time.time()
self.log.write('next'+str(self.next_tick)+'time '+str(now))
def run(self): while not self.quit_func(): now = time.time() self.log.write('next'+str(self.next_tick)+'time '+str(now)) still = self.next_tick-now if still<=0: self.log.write('tick\n') self.tick_func() self.next_tick += self.tick else: self.win.timeout(1000*still) ch = self.win.getch() if ch != curses.ERR: self.key_fu...
self.log.write('tick\n')
def run(self): while not self.quit_func(): now = time.time() self.log.write('next'+str(self.next_tick)+'time '+str(now)) still = self.next_tick-now if still<=0: self.log.write('tick\n') self.tick_func() self.next_tick += self.tick else: self.win.timeout(1000*still) ch = self.win.getch() if ch != curses.ERR: self.key_fu...
bool = self.get(question) return bool == 'true'
result = self.get(question) return result == 'true'
def getBoolean(self, question): bool = self.get(question) return bool == 'true'
' register unregister subst fset fget'
' register unregister subst fset fget previous_module'
def __init__(self, title=None): for command in ('capb set reset title input beginblock endblock go get' ' register unregister subst fset fget' ' visible purge metaget exist version settitle').split(): self.setCommand(command) self.write, self.read = sys.stdout, sys.stdin sys.stdout = sys.stderr self.setUp(title)
class DebconfCommunicator(debconf.Debconf, object):
class DebconfCommunicator(Debconf, object):
def getString(self, question): return self.get(question)
if child.alive:
if getattr(child,'alive',False):
def marshal(parent): for child in parent.children: if child.alive: continue child.alive = True newNodes.append(( parent.id, child.tag.decode('ascii'), child.kwargs)) marshal(child)
newNodes.append(( parent.id, child.tag.decode('ascii'), child.kwargs)) marshal(child)
if isinstance(child, (xmlstan.NSTag, xmlstan.Tag)): pass else: newNodes.append(( parent.id, child.tag.decode('ascii'), child.kwargs)) marshal(child)
def marshal(parent): for child in parent.children: if child.alive: continue child.alive = True newNodes.append(( parent.id, child.tag.decode('ascii'), child.kwargs)) marshal(child)
self.callRemote('setWindowTitle', title)
def setTitle(self, title): self.setAttr('title', title)
if 'title' in self.window.kwargs: self.window.setTitle(self.window.kwargs['title']) if self.constrainDimensions: self.window.setDimensions(self.window.kwargs.get('height'), self.window.kwargs.get('width'))
def goingLive(self, ctx, client): self.client = client
self.removePage(page) for page in toRemove
self.removePage(rpage) for rpage in toRemove
def addPage(self, page): # First, remove pages beyond the current index. index = wait(self.get('selectedIndex')) yield index index = index.getResult() toRemove = self.children[index + 1:] yield wait(DeferredList([ self.removePage(page) for page in toRemove ])) # Next, add the new page. index = wait(std.Deck.addPage(sel...
Returns a DeferredList that calls back with a list of
Returns a deferred that calls back with a list of
def dispatch(self, signal, *args): """Dispatch ``signal`` with optional ``args`` to listeners.
result = wait(result) yield result result = result.getResult()
if isinstance(result, Deferred): result = wait(result) yield result result = result.getResult()
def dispatch(self, signal, *args): """Dispatch ``signal`` with optional ``args`` to listeners.
return value.lower() == u'true'
return str(value).lower() == 'true'
def _to_bool(value): return value.lower() == u'true'
return unicode(value).lower()
if value: return u'true' else: return u''
def _from_bool(value): return unicode(value).lower()
d = utils.getProcessOutput('/usr/bin/firefox', args, os.environ)
if os.name == 'nt': executable = 'C:/Program Files/Mozilla Firefox/firefox.exe' else: executable = '/usr/bin/firefox' d = utils.getProcessOutput(executable, args, os.environ)
def start(): args = ['-chrome', 'http://127.0.0.1:8090'] if firefoxArgs: args.extend(firefoxArgs) d = utils.getProcessOutput('/usr/bin/firefox', args, os.environ) d.addCallback(stop)
'TreeSeparator','Triple', 'VBox', 'Window', 'Wizard', 'wizardPage']
'TreeSeparator','Triple', 'VBox', 'Window', 'Wizard', 'WizardPage']
def getTag(self): self.kwargs.update(dict([(k,v[1]) for k,v in self.handlers.items()])) return getattr(xulns, self.tag)(**self.kwargs)
"application/vnd.mozilla.xul+xml; charset=UTF-8")
"application/vnd.mozilla.xul+xml; charset=%s" % (self.charset,))
def renderHTTP(self, ctx): #ensure that we are delivered with the correct content type header inevow.IRequest(ctx).setHeader("Content-Type", "application/vnd.mozilla.xul+xml; charset=UTF-8")
'children', 'id', 'pageCtx', 'rend', 'addHandler', 'handlers', 'getTag'
'addHandler', 'children', 'getTag', 'handlers', 'id', 'kwargs', 'pageCtx', 'rend', 'tag',
def __getattr__(self, name): # Delegate most of genericwidget's interface to our tree # widget. if name in [ 'children', 'id', 'pageCtx', 'rend', 'addHandler', 'handlers', 'getTag' ]: return getattr(self.tree, name) raise AttributeError, name
th.append(xul.Splitter(_class="tree-splitter"))
th.append(xul.Splitter(_class=u"tree-splitter"))
def __init__(self, headerLabels, mapper, items=None, **kwargs): t = xul.Tree(**kwargs) th = xul.TreeCols() for cell in headerLabels: th.append(xul.TreeCol(flex=1, label=cell)) th.append(xul.Splitter(_class="tree-splitter")) t.append(th) tc = xul.TreeChildren() t.append(tc) self.tree = t self.treeChildren = tc self.clie...
'console' : 'one', 'controls' : 'ImageWindow', 'maintainaspect' : 'true' }
'console' : u'one', 'controls' : u'ImageWindow', 'maintainaspect' : u'true' }
def __init__(self, mediaURL, width=300, height=300): xul.GenericWidget.__init__(self) newKwargs = { 'src' : mediaURL, 'width' : width, 'height' : height, 'console' : 'one', 'controls' : 'ImageWindow', 'maintainaspect' : 'true' } self.kwargs = newKwargs
th.append(xul.TreeCol(flex=1, label=label, primary="true"))
th.append(xul.TreeCol(flex=1, label=label, primary=u"true"))
def __init__(self, abstraction, headerLabels, **kwargs): self.abstraction = abstraction
if node.alive: node.setAttr("open", "true")
if node.alive: node.setAttr("open", u"true")
def loadNode(self, node): if not node.loaded: children = self.abstraction.getChildren(node.segments) if len(children): if node.alive: node.setAttr("open", "true")
ti = xul.TreeItem(container="true", open="false", empty=empty)
ti = xul.TreeItem(container=u"true", open=u"false", empty=empty)
def loadNode(self, node): if not node.loaded: children = self.abstraction.getChildren(node.segments) if len(children): if node.alive: node.setAttr("open", "true")
print "ADDING", childlabel, "TO", parent
def addChild(parent, childlabel): print "ADDING", childlabel, "TO", parent item = xul.TreeItem(container='true', open='true') row = xul.TreeRow() row.append(xul.TreeCell(label=childlabel)) item.append(row) parent.append(item) return item
return self.childFactories[name] class LivePageChildDispatcher(object): """ LivePageChildDispatcher handles dispatching child requests to other LivePage subclasses by persisting their LivePageFactory instances on the parent factory. """ liveChildren = {} def childFactory(self, ctx, name): if name in self.liveChildren...
return self.childFactories[name] class XULPage(athena.LivePage):
def getChildFactory(self, name, LivePageClass, FactoryClass=athena.LivePageFactory, *args, **kwargs): if not name in self.childFactories: self.childFactories[name] = FactoryClass(LivePageClass, *args, **kwargs) return self.childFactories[name]
my.nrpc += 1 my.sent_bytes += size
def sendremote (my, t, size):
if t != lasttime and t > 200 : if maxblocks > 0: for t in xrange(lasttime+1,t-1):
if t != lasttime: if maxblocks > 0 and t > 200: for nt in xrange(lasttime+1,t-1):
def random_blockid (): s = sha.sha("%d" % random_id ()) id = str2bigint (s.digest ()) while id in inserted: # Damn birthdays. s = sha.sha("%d" % random_id ()) id = str2bigint (s.digest ()) inserted[id] = 1 return id
print t, "insert", nnode, random_blockid ()
print nt, "insert", nnode, random_blockid ()
def random_blockid (): s = sha.sha("%d" % random_id ()) id = str2bigint (s.digest ()) while id in inserted: # Damn birthdays. s = sha.sha("%d" % random_id ()) id = str2bigint (s.digest ()) inserted[id] = 1 return id
def start_vnode(): """Start a new vnode and do a demonstration lookup.""" arg = cd_prot.cd_newvnode_arg() arg.routing_mode = cd_prot.MODE_CHORD def newvnodecb(res): if res.stat == chord_types.CHORD_OK: print "Vnode created:", res.resok.vnode do_lookup(res.resok.vnode, res.resok.vnode + 1) else: print "Vnode creation ...
def start_vnode(): """Start a new vnode and do a demonstration lookup.""" arg = cd_prot.cd_newvnode_arg() arg.routing_mode = cd_prot.MODE_CHORD def newvnodecb(res): if res.stat == chord_types.CHORD_OK: print "Vnode created:", res.resok.vnode do_lookup(res.resok.vnode, res.resok.vnode + 1) else: print "Vnode creation ...
start_vnode."""
do_lookup."""
def start_chord(): """Start a Chord instance and launch a single vnode when done. Since cd is a very thin wrapper around the Chord API, it is necessary to initialize the chord object with the appropriate arguments. Once the Chord object has been created, this calls start_vnode.""" arg = cd_prot.cd_newchord_arg() if...
arg.wellknownhost = ""
arg.wellknownhost = options.myname
def start_chord(): """Start a Chord instance and launch a single vnode when done. Since cd is a very thin wrapper around the Chord API, it is necessary to initialize the chord object with the appropriate arguments. Once the Chord object has been created, this calls start_vnode.""" arg = cd_prot.cd_newchord_arg() if...
arg.myname = ""
arg.myname = options.myname
def start_chord(): """Start a Chord instance and launch a single vnode when done. Since cd is a very thin wrapper around the Chord API, it is necessary to initialize the chord object with the appropriate arguments. Once the Chord object has been created, this calls start_vnode.""" arg = cd_prot.cd_newchord_arg() if...
start_vnode()
print "Vnodes:" for x in res.resok.vnodes: print str(x) vnid = res.resok.vnodes[0] do_lookup(vnid, vnid+1)
def newchordcb(res): if res.stat == chord_types.CHORD_NOTINRANGE: print "Chord object already exists, continuing anyways" else: print "Chord object created" start_vnode()
parser.add_option("-l", type="string", dest="myname", default="", help="specifies local host name to bind to")
def join_arg(option, opt, value, parser): """Parse host:port value of join option""" parts = value.split(":") if len(parts) != 2: raise optparse.OptionValueError, \ "option %s: must specify host:port" % opt host, port = parts port = int(port) parser.values.join = (host, port)
return transl if transl: def N_(message): return transl.gettext(message)
return _transl if _transl: def N_(message): return _transl.gettext(message)
def getTrans(): return transl
print "translated: ", N_('Separator in dates')
def N_(message): return message
global _transl if _transLookedUp: return _transl try: return gettext.translation('gryn', './var/gryn/locale', ['no']) except IOError: return None _transl= getTrans() _transLookedUp= 1 if _transl: def N_(message): return _transl.gettext(message)
return transl if transl: def N_(message): return transl.gettext(message)
def getTrans(): global _transl #if getLocale() != None: if _transLookedUp: return _transl try: return gettext.translation('gryn', './var/gryn/locale', ['no']) except IOError: return None
<color r="1.0" g="0.0", b="0.0"/>
<color r="1.0" g="0.0" b="0.0"/>
def calcBounds(file): """ Gets the bounds of the OBJ in the current file """ (xmin, ymin, zmin) = ( 1000000.0, 1000000.0, 1000000.0) (xmax, ymax, zmax) = (-1000000.0, -1000000.0, -1000000.0) # loop on the lines in the file for line in open(file, 'r').readlines(): result = line matches = re.compile(r'v +(-?\d+\.\d+)...
sys.stdout.write(xml % (xmin, xmax, ymin, ymax,
sys.stdout.write(xml % (xmin, xmax, zmin, zmax,
def calcBounds(file): """ Gets the bounds of the OBJ in the current file """ (xmin, ymin, zmin) = ( 1000000.0, 1000000.0, 1000000.0) (xmax, ymax, zmax) = (-1000000.0, -1000000.0, -1000000.0) # loop on the lines in the file for line in open(file, 'r').readlines(): result = line matches = re.compile(r'v +(-?\d+\.\d+)...
template = q.template.copy(True)
template = q.template.copy()
def dynamic(self): q = self.q template = q.template.copy(True) template["pagemode"] = self.pagemode template["pagetitle"] = self.pagetitle self.r.content = HtmlContent(str(template))
self.r.content = HtmlContent(str(template))
self.r.content = HtmlContent(template)
def dynamic(self): q = self.q template = q.template.copy(True) template["pagemode"] = self.pagemode template["pagetitle"] = self.pagetitle self.r.content = HtmlContent(str(template))
q.template = Template.from_file("templates/welcome/page.tmpl")
q.template = Template.open("templates/welcome/page.tmpl")
def static(self): q = self.q q.template = Template.from_file("templates/welcome/page.tmpl") self._files_Handler = FileHandler q._files_Handler = dict(location="htdocs/welcome")
prefix = os.path.join(sys.prefix, "/".join(["lib", python_ver, "site-packages", "biz"]))
prefix = os.path.join(sys.prefix, "lib", python_ver, "site-packages", "biz")
def admin_create(options, args): if len(args) < 1: return False for arg in args: destination = os.path.join(os.getcwd(), arg) python_ver = sys.version_info python_ver = "python%d.%d" % (python_ver[0],python_ver[1]) platform = sys.platform if options.prefix: prefix = options.prefix else: if platform.startswith("linux...
source = prefix + "/default"
source = os.path.join(prefix, "default")
def admin_create(options, args): if len(args) < 1: return False for arg in args: destination = os.path.join(os.getcwd(), arg) python_ver = sys.version_info python_ver = "python%d.%d" % (python_ver[0],python_ver[1]) platform = sys.platform if options.prefix: prefix = options.prefix else: if platform.startswith("linux...
print '%4d %5.3f %5d %5d %5d %4.2f %6.2f' % \
print '%4d %5.3f %5d %5d %5d %4.2f %6.2f %5.2f' % \
def _print_integrate_lp(integrate_lp_stats): '''Print the contents of the integrate.lp dictionary.''' images = integrate_lp_stats.keys() images.sort() for i in images: data = integrate_lp_stats[i] print '%4d %5.3f %5d %5d %5d %4.2f %6.2f' % \ (i, data['scale'], data['strong'], data['overloads'], data['rejected'], dat...
data.get('mosaic', 0.0), data['distance'])
data.get('mosaic', 0.0), data['distance'], data['resolution'])
def _print_integrate_lp(integrate_lp_stats): '''Print the contents of the integrate.lp dictionary.''' images = integrate_lp_stats.keys() images.sort() for i in images: data = integrate_lp_stats[i] print '%4d %5.3f %5d %5d %5d %4.2f %6.2f' % \ (i, data['scale'], data['strong'], data['overloads'], data['rejected'], dat...
phi_width = self.get_header_item('phi_width') min_images = max(3, int(2 * mosaic / phi_width))
def _mosflm_refine_cell(self): '''Perform the refinement of the unit cell. This will populate all of the information needed to perform the integration.'''
images = self.get_matching_images() if len(images) < num_wedges * min_images: raise RuntimeError, 'not enough images to refine unit cell' cell_ref_images = [] cell_ref_images.append((images[0], images[min_images - 1])) if num_wedges == 2: ideal_last = int(90.0 / phi_width) + min_images if ideal_last in images: cell_...
if not self._mosflm_cell_ref_images: self._mosflm_cell_ref_images = self._refine_select_images( num_wedges, mosaic)
def _mosflm_refine_cell(self): '''Perform the refinement of the unit cell. This will populate all of the information needed to perform the integration.'''
task = 'Refine cell from %d wedges' % len(cell_ref_images)
task = 'Refine cell from %d wedges' % \ len(self._mosflm_cell_ref_images)
def _mosflm_refine_cell(self): '''Perform the refinement of the unit cell. This will populate all of the information needed to perform the integration.'''
self.input('postref multi segments %d' % len(cell_ref_images)) for cri in cell_ref_images:
self.input('postref multi segments %d' % \ len(self._mosflm_cell_ref_images)) for cri in self._mosflm_cell_ref_images:
def _mosflm_refine_cell(self): '''Perform the refinement of the unit cell. This will populate all of the information needed to perform the integration.'''
Science.write( 'Integration will be aborted because of this.') raise RuntimeError, 'cell refinement failed: ' + \ 'inaccurate cell parameters'
if len(self._mosflm_cell_ref_images) <= 3: new_cell_ref_images = self._refine_select_images( len(self._mosflm_cell_ref_images) + 1, mosaic) self._mosflm_cell_ref_images = new_cell_ref_images self._intgr_prepare_done = False Science.write( 'Repeating cell refinement with more data.') return else: Science.wr...
def _mosflm_refine_cell(self): '''Perform the refinement of the unit cell. This will populate all of the information needed to perform the integration.'''
self.input(m)
self.input('"%s"' % m)
def sort(self): '''Actually sort the reflections.''' # if we have not specified > 1 hklin file via the add method, # check that the set_hklin method has been used. if not self._hklin_files: self.check_hklin() self.check_hklout()
lattice_to_spacegroup = {'aP':1, 'mP':3, 'mC':5, 'oP':16, 'oC':20, 'oF':22, 'oI':23, 'tP':75, 'tI':79, 'hP':143, 'hR':143, 'cP':195, 'cF':196, 'cI':197}
def do_funky(pdb_file_name): pdb, cell, symm = parse_pdb(pdb_file_name) if cell[0] * cell[1] * cell[2] < 100.0: # this is an unlikely unit cell... return print '----------- Analysing %s ----------' % pdb # check that the symmetry is legal, not something whacky! try: original_lattice = Syminfo.get_lattice(symm) origi...
dataset_info = md.get_dataset_info()
datasets = md.get_datasets() Chatter.write('In reflection file %s found:' % hklin) for d in datasets: Chatter.write('... %s' % d) dataset_info = md.get_dataset_info(datasets[0])
def _scale(self): '''Perform all of the operations required to deliver the scaled data.'''
(pname, xname, name, counter))
(pname, xname, dname, counter))
def _scale(self): '''Perform all of the operations required to deliver the scaled data.'''
self._spacegroup = sg_node.getElementsbyTagName(
self._spacegroup = sg_node.getElementsByTagName(
def decide_spacegroup(self): '''Given data indexed in the correct pointgroup, have a guess at the spacegroup.'''