rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
def launchProcess(self, cmd, outputFile = "process.txt", cwd = ''): | def launchProcess(self, cmd, outputFile = "process.txt", cwd = '', env = ''): | def launchProcess(self, cmd, outputFile = "process.txt", cwd = ''): cmdline = subprocess.list2cmdline(cmd) if (outputFile == "process.txt" or outputFile == None): outputFile = self.getDeviceRoot() + '/' + "process.txt" cmdline += " > " + outputFile |
localFile = os.path.join(self.tempRoot, "temp.txt") promptre = re.compile(self.prompt_regex + '.*') retVal = self.catFile(remoteFile) | localFile = os.path.join(self.tempRoot, "temp.txt") retVal = self.pullFile(remoteFile) if retVal == None: return None | def getFile(self, remoteFile, localFile = ''): if localFile == '': localFile = os.path.join(self.tempRoot, "temp.txt") promptre = re.compile(self.prompt_regex + '.*') retVal = self.catFile(remoteFile) fhandle = open(localFile, 'wb') fhandle.write(retVal) fhandle.close() return retVal |
if (self.isDir(os.path.join(remoteDir, f))): if (self.getDirectory(remoteDir + '/' + f, os.path.join(localDir, f)) == None): | if f == '.' or f == '..': continue remotePath = remoteDir + '/' + f localPath = os.path.join(localDir, f) try: is_dir = self.isDir(remotePath) except FileError: print 'isdir failed on file "%s"; continuing anyway...' % remotePath continue if is_dir: if (self.getDirectory(remotePath, localPath) == None): print 'failed t... | def getDirectory(self, remoteDir, localDir): if (self.debug >= 2): print "getting files in '" + remoteDir + "'" filelist = self.listFiles(remoteDir) if (filelist == None): return None if (self.debug >= 3): print filelist if not os.path.exists(localDir): os.makedirs(localDir) for f in filelist: if (self.isDir(os.path.j... |
if (self.getFile(remoteDir + '/' + f, os.path.join(localDir, f)) == None): return None | if self.getFile(remotePath, localPath) == None: print 'failed to get file "%s"; continuing anyway...' % remotePath | def getDirectory(self, remoteDir, localDir): if (self.debug >= 2): print "getting files in '" + remoteDir + "'" filelist = self.listFiles(remoteDir) if (filelist == None): return None if (self.debug >= 3): print filelist if not os.path.exists(localDir): os.makedirs(localDir) for f in filelist: if (self.isDir(os.path.j... |
def reboot(self, wait = False): self.sendCMD(['rebt']) if wait == True: time.sleep(30) timeout = 270 done = False while (not done): if self.listFiles('/') != None: return '' print "sleeping another 10 seconds" time.sleep(10) timeout = timeout - 10 if (timeout <= 0): return None | def reboot(self, ipAddr=None, port=30000): cmd = 'rebt' if (self.debug > 3): print "INFO: sending rebt command" if (ipAddr is not None): ip, port = self.getCallbackIpAndPort(ipAddr, port) callbacksvr = callbackServer(ip, port, self.debug) data = self.sendCMD([cmd]) status = callbacksvr.disconnect() else: status = se... | def reboot(self, wait = False): self.sendCMD(['rebt']) |
def updateApp(self, appBundlePath, processName=None, destPath=None, ipAddr=None, port=None): | def updateApp(self, appBundlePath, processName=None, destPath=None, ipAddr=None, port=30000): | def updateApp(self, appBundlePath, processName=None, destPath=None, ipAddr=None, port=None): status = None cmd = 'updt ' if (processName == None): # Then we pass '' for processName cmd += "'' " + appBundlePath else: cmd += processName + ' ' + appBundlePath |
if port: | if (self.debug > 3): print "INFO: updateApp using command: " + str(cmd) if (ipAddr is not None): | def updateApp(self, appBundlePath, processName=None, destPath=None, ipAddr=None, port=None): status = None cmd = 'updt ' if (processName == None): # Then we pass '' for processName cmd += "'' " + appBundlePath else: cmd += processName + ' ' + appBundlePath |
ip, port = self.getCallbackIpAndPort(ipAddr, 30000) cmd += " %s %s" % (ip, port) if (self.debug > 3): print "updateApp using command: " + str(cmd) callbacksvr = callbackServer(ip, port, self.debug) data = self.sendCMD([cmd]) status = callbacksvr.disconnect() if (self.debug > 3): print "got status back: " + str(stat... | status = self.sendCMD([cmd]) if (self.debug > 3): print "INFO: updateApp: got status back: " + str(status) | def updateApp(self, appBundlePath, processName=None, destPath=None, ipAddr=None, port=None): status = None cmd = 'updt ' if (processName == None): # Then we pass '' for processName cmd += "'' " + appBundlePath else: cmd += processName + ' ' + appBundlePath |
print "FAIL: graph server does not resolve" | print "FAIL: graph server URLError" | def link_exists(host, selector): """ Check to see if the given host exists and is reachable """ try: site = urllib2.urlopen("http://" + host + selector) meta = site.info() except urllib2.URLError, e: print "FAIL: graph server does not resolve" print "FAIL: " + str(e) return 0 return 1 |
if option in ("--deviceRoot"): | if option in ("--deviceRoot",): | def main(argv=None): exePath = "" configPath = "" sampleConfig = "sample.config" output = "" title = defaultTitle branch = "" branchName = "" testDate = "" browserWait = "5" verbose = False buildid = "" useId = False resultsServer = '' resultsLink = '' activeTests = '' noChrome = False fast = False symbolsPath = None r... |
if option in ("--fast"): | if option in ("--fast",): | def main(argv=None): exePath = "" configPath = "" sampleConfig = "sample.config" output = "" title = defaultTitle branch = "" branchName = "" testDate = "" browserWait = "5" verbose = False buildid = "" useId = False resultsServer = '' resultsLink = '' activeTests = '' noChrome = False fast = False symbolsPath = None r... |
debug = 2 | debug = 3 | def run(self): promptre =re.compile('.*\$\>.$') data = "" try: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) except: return None try: s.connect((self.host, int(self.port))) except: s.close() return None try: s.recv(1024) except: s.close() return None for cmd in self.cmdline: if (cmd == 'quit'): break if self... |
dirSlash = "/" deviceRoot = '/tests' | deviceRoot = None | def run(self): promptre =re.compile('.*\$\>.$') data = "" try: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) except: return None try: s.connect((self.host, int(self.port))) except: s.close() return None try: s.recv(1024) except: s.close() return None for cmd in self.cmdline: if (cmd == 'quit'): break if self... |
def __init__(self, host, port = 27020): | base_prompt = '\$\>' prompt_sep = '\x00' prompt_regex = '.*' + base_prompt + prompt_sep agentErrorRE = re.compile('^ def __init__(self, host, port = 20701): | def run(self): promptre =re.compile('.*\$\>.$') data = "" try: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) except: return None try: s.connect((self.host, int(self.port))) except: s.close() return None try: s.recv(1024) except: s.close() return None for cmd in self.cmdline: if (cmd == 'quit'): break if self... |
def sendCMD(self, cmdline, newline = True, sleep = 0): promptre = re.compile('.*\$\>.$') pushre = re.compile('^push .*$') | self.getDeviceRoot() def cmdNeedsResponse(self, cmd): """ Not all commands need a response from the agent: * if the cmd matches the pushRE then it is the first half of push and therefore we want to wait until the second half before looking for a response * rebt obviously doesn't get a response * uninstall performs a r... | def __init__(self, host, port = 27020): self.host = host self.port = port self._sock = None |
noQuit = False | shouldCloseSocket = False recvGuard = 1000 | def sendCMD(self, cmdline, newline = True, sleep = 0): promptre = re.compile('.*\$\>.$') |
print "reconnecting socket" | if (self.debug >= 1): print "reconnecting socket" | def sendCMD(self, cmdline, newline = True, sleep = 0): promptre = re.compile('.*\$\>.$') |
if (cmd == 'quit'): break | def sendCMD(self, cmdline, newline = True, sleep = 0): promptre = re.compile('.*\$\>.$') | |
self._sock.send(cmd) | numbytes = self._sock.send(cmd) if (numbytes != len(cmd)): print "ERROR: our cmd was " + str(len(cmd)) + " bytes and we only sent " + str(numbytes) return None if (self.debug >= 4): print "send cmd: " + str(cmd) | def sendCMD(self, cmdline, newline = True, sleep = 0): promptre = re.compile('.*\$\>.$') |
if (pushre.match(cmd) or cmd == 'rebt'): noQuit = True elif noQuit == False: time.sleep(int(sleep)) | shouldCloseSocket = self.shouldCmdCloseSocket(cmd) if (self.cmdNeedsResponse(cmd)): | def sendCMD(self, cmdline, newline = True, sleep = 0): promptre = re.compile('.*\$\>.$') |
while (found == False): if (self.debug >= 3): print "recv'ing..." | loopguard = 0 while (found == False and (loopguard < recvGuard)): if (self.debug >= 4): print "recv'ing..." | def sendCMD(self, cmdline, newline = True, sleep = 0): promptre = re.compile('.*\$\>.$') |
time.sleep(int(sleep)) if (noQuit == True): | loopguard = loopguard + 1 if (shouldCloseSocket == True): | def sendCMD(self, cmdline, newline = True, sleep = 0): promptre = re.compile('.*\$\>.$') |
promptre = re.compile('.*\$\>.*') | promptre = re.compile(self.prompt_regex + '.*') | def stripPrompt(self, data): promptre = re.compile('.*\$\>.*') retVal = [] lines = data.split('\n') for line in lines: try: while (promptre.match(line)): pieces = line.split('\x00') index = pieces.index("$>") pieces.pop(index) line = '\x00'.join(pieces) except(ValueError): pass retVal.append(line) |
pieces = line.split('\x00') index = pieces.index("$>") | pieces = line.split(self.prompt_sep) index = pieces.index('$>') | def stripPrompt(self, data): promptre = re.compile('.*\$\>.*') retVal = [] lines = data.split('\n') for line in lines: try: while (promptre.match(line)): pieces = line.split('\x00') index = pieces.index("$>") pieces.pop(index) line = '\x00'.join(pieces) except(ValueError): pass retVal.append(line) |
line = '\x00'.join(pieces) | line = self.prompt_sep.join(pieces) | def stripPrompt(self, data): promptre = re.compile('.*\$\>.*') retVal = [] lines = data.split('\n') for line in lines: try: while (promptre.match(line)): pieces = line.split('\x00') index = pieces.index("$>") pieces.pop(index) line = '\x00'.join(pieces) except(ValueError): pass retVal.append(line) |
self.mkDirs(destname) | if self.mkDirs(destname) == None: print "unable to make dirs: " + destname return None | def pushFile(self, localname, destname): if (self.validateFile(destname, localname) == True): return '' |
sleepsize = 1024 * 1024 sleepTime = int(filesize / sleepsize) * 5 | def pushFile(self, localname, destname): if (self.validateFile(destname, localname) == True): return '' | |
retVal = self.sendCMD(['push ' + destname + '\r\n', data], newline = False, sleep = sleepTime) if (retVal == None): return None if (self.validateFile(destname, localname) == False): if (self.debug >= 2): print "file did not copy as expected" return None return retVal | retVal = self.sendCMD(['push ' + destname + ' ' + str(filesize) + '\r\n', data], newline = False) if (self.debug >= 3): print "push returned: " + str(retVal) validated = False if (retVal): retline = self.stripPrompt(retVal).strip() if (retline == None or self.agentErrorRE.match(retVal)): validated = self.validateFil... | def pushFile(self, localname, destname): if (self.validateFile(destname, localname) == True): return '' |
parts = filename.split(self.dirSlash) | parts = filename.split('/') | def mkDirs(self, filename): parts = filename.split(self.dirSlash) name = "" for part in parts: if (part == parts[-1]): break if (part != ""): name += self.dirSlash + part if (self.mkDir(name) == None): return None |
name += self.dirSlash + part | name += '/' + part | def mkDirs(self, filename): parts = filename.split(self.dirSlash) name = "" for part in parts: if (part == parts[-1]): break if (part != ""): name += self.dirSlash + part if (self.mkDir(name) == None): return None |
return '' | def mkDirs(self, filename): parts = filename.split(self.dirSlash) name = "" for part in parts: if (part == parts[-1]): break if (part != ""): name += self.dirSlash + part if (self.mkDir(name) == None): return None | |
remoteRoot = remoteDir + self.dirSlash + parts[1] remoteRoot = remoteRoot.replace('/', self.dirSlash) remoteRoot = remoteRoot.replace('\\\\', '\\') remoteName = remoteRoot + self.dirSlash + file | remoteRoot = remoteDir + '/' + parts[1] remoteName = remoteRoot + '/' + file | def pushDir(self, localDir, remoteDir): if (self.debug >= 2): print "pushing directory: " + localDir + " to " + remoteDir for root, dirs, files in os.walk(localDir): parts = root.split(localDir) for file in files: remoteRoot = remoteDir + self.dirSlash + parts[1] remoteRoot = remoteRoot.replace('/', self.dirSlash) remo... |
time.sleep(5) | def pushDir(self, localDir, remoteDir): if (self.debug >= 2): print "pushing directory: " + localDir + " to " + remoteDir for root, dirs, files in os.walk(localDir): parts = root.split(localDir) for file in files: remoteRoot = remoteDir + self.dirSlash + parts[1] remoteRoot = remoteRoot.replace('/', self.dirSlash) remo... | |
match = ".*" + dirname.replace('\\', '\\\\') + "$" | match = ".*" + dirname + "$" | def dirExists(self, dirname): match = ".*" + dirname.replace('\\', '\\\\') + "$" |
data = self.sendCMD(['cd ' + dirname, 'cwd', 'quit'], sleep = 1) | data = self.sendCMD(['cd ' + dirname, 'cwd']) | def dirExists(self, dirname): match = ".*" + dirname.replace('\\', '\\\\') + "$" |
filelist = self.listFiles(remoteDir) if (filelist == None): return None isFile = re.compile('^([a-zA-Z0-9_\-\. ]+)\.([a-zA-Z0-9]+)$') for f in filelist: if (isFile.match(f)): if (self.removeFile(remoteDir + self.dirSlash + f) == None): return None else: if (self.removeDir(remoteDir + self.dirSlash + f) == None): retu... | self.sendCMD(['rmdr ' + remoteDir]) | def removeDir(self, remoteDir): filelist = self.listFiles(remoteDir) if (filelist == None): return None #TODO: logic is way too simple and basic, make more robust isFile = re.compile('^([a-zA-Z0-9_\-\. ]+)\.([a-zA-Z0-9]+)$') for f in filelist: if (isFile.match(f)): if (self.removeFile(remoteDir + self.dirSlash + f) ==... |
data = self.sendCMD(['ps', 'quit'], sleep = 3) | data = self.sendCMD(['ps']) | def getProcessList(self): data = self.sendCMD(['ps', 'quit'], sleep = 3) if (data == None): return None retVal = self.stripPrompt(data) lines = retVal.split('\n') files = [] for line in lines: if (line.strip() != ''): pidproc = line.strip().split(' ') if (len(pidproc) == 2): files += [[pidproc[0], pidproc[1]]] return... |
pidproc = line.strip().split(' ') | pidproc = line.strip().split() | def getProcessList(self): data = self.sendCMD(['ps', 'quit'], sleep = 3) if (data == None): return None retVal = self.stripPrompt(data) lines = retVal.split('\n') files = [] for line in lines: if (line.strip() != ''): pidproc = line.strip().split(' ') if (len(pidproc) == 2): files += [[pidproc[0], pidproc[1]]] return... |
elif (len(pidproc) == 3): files += [[pidproc[1], pidproc[2], pidproc[0]]] | def getProcessList(self): data = self.sendCMD(['ps', 'quit'], sleep = 3) if (data == None): return None retVal = self.stripPrompt(data) lines = retVal.split('\n') files = [] for line in lines: if (line.strip() != ''): pidproc = line.strip().split(' ') if (len(pidproc) == 2): files += [[pidproc[0], pidproc[1]]] return... | |
self.process = myProc(self.host, self.port, ['exec ' + appname, 'quit']) self.process.start() | if (self.processExist(appname) != ''): print "WARNING: process %s appears to be running already\n" % appname self.sendCMD(['exec ' + appname]) time.sleep(30) self.process = self.processExist(appname) if (self.debug >= 4): print "got pid: " + str(self.process) + " for process: " + str(appname) | def fireProcess(self, appname): if (self.debug >= 2): print "FIRE PROC: '" + appname + "'" self.process = myProc(self.host, self.port, ['exec ' + appname, 'quit']) self.process.start() |
outputFile = self.getDeviceRoot() + self.dirSlash + "process.txt" | outputFile = self.getDeviceRoot() + '/' + "process.txt" | def launchProcess(self, cmd, outputFile = "process.txt", cwd = ''): if (outputFile == "process.txt"): outputFile = self.getDeviceRoot() + self.dirSlash + "process.txt" cmdline = subprocess.list2cmdline(cmd) self.fireProcess(cmdline + " > " + outputFile) handle = outputFile return handle |
time.sleep(1) | time.sleep(interval) | def communicate(self, process, timeout = 600): timed_out = True if (timeout > 0): total_time = 0 while total_time < timeout: time.sleep(1) if (not self.poll(process)): timed_out = False break total_time += 1 |
total_time += 1 | total_time += interval | def communicate(self, process, timeout = 600): timed_out = True if (timeout > 0): total_time = 0 while total_time < timeout: time.sleep(1) if (not self.poll(process)): timed_out = False break total_time += 1 |
if (not self.process.isAlive()): | if (self.processExist(process) == None): | def poll(self, process): try: if (not self.process.isAlive()): return None return 1 except: return None return 1 |
pieces = appname.split(self.dirSlash) app = pieces[-1] | pieces = appname.split(' ') parts = pieces[0].split('/') app = parts[-1] | def processExist(self, appname): pid = '' pieces = appname.split(self.dirSlash) app = pieces[-1] procre = re.compile('.*' + app + '.*') procList = self.getProcessList() if (procList == None): return None for proc in procList: if (procre.match(proc[1])): pid = proc[0] break return pid |
pid = "0xFEEDFACE" while (pid != ''): pid = self.processExist(appname) if (pid == None): return None if (pid != ''): if (self.debug >= 2): print "found pid, now kill: " + pid if (self.sendCMD(['kill ' + pid, 'quit']) == None): return None | if (self.sendCMD(['kill ' + appname]) == None): return None | def killProcess(self, appname): pid = "0xFEEDFACE" while (pid != ''): pid = self.processExist(appname) if (pid == None): return None if (pid != ''): if (self.debug >= 2): print "found pid, now kill: " + pid if (self.sendCMD(['kill ' + pid, 'quit']) == None): return None |
promptre = re.compile('.*\$\>\x00.*') | def getTempDir(self): promptre = re.compile('.*\$\>\x00.*') retVal = '' data = self.sendCMD(['tmpd', 'quit']) if (data == None): return None return self.stripPrompt(data).strip('\n') | |
data = self.sendCMD(['tmpd', 'quit']) | data = self.sendCMD(['tmpd']) | def getTempDir(self): promptre = re.compile('.*\$\>\x00.*') retVal = '' data = self.sendCMD(['tmpd', 'quit']) if (data == None): return None return self.stripPrompt(data).strip('\n') |
promptre = re.compile('.*\$\>\x00.*') data = self.sendCMD(['cat ' + remoteFile, 'quit'], sleep = 5) | promptre = re.compile(self.prompt_regex + '.*') data = self.sendCMD(['cat ' + remoteFile]) | def getFile(self, remoteFile, localFile = ''): if localFile == '': localFile = os.path.join(self.tempRoot, "temp.txt") promptre = re.compile('.*\$\>\x00.*') data = self.sendCMD(['cat ' + remoteFile, 'quit'], sleep = 5) if (data == None): return None retVal = self.stripPrompt(data) fhandle = open(localFile, 'wb') fhand... |
if (self.getFile(remoteDir + self.dirSlash + f, os.path.join(localDir, f)) == None): | if (self.getFile(remoteDir + '/' + f, os.path.join(localDir, f)) == None): | def getDirectory(self, remoteDir, localDir): if (self.debug >= 2): print "getting files in '" + remoteDir + "'" filelist = self.listFiles(remoteDir) if (filelist == None): return None if (self.debug >= 3): print filelist if not os.path.exists(localDir): os.makedirs(localDir) #TODO: is this a comprehensive file regex? ... |
if (self.getDirectory(remoteDir + self.dirSlash + f, os.path.join(localDir, f)) == None): | if (self.getDirectory(remoteDir + '/' + f, os.path.join(localDir, f)) == None): | def getDirectory(self, remoteDir, localDir): if (self.debug >= 2): print "getting files in '" + remoteDir + "'" filelist = self.listFiles(remoteDir) if (filelist == None): return None if (self.debug >= 3): print filelist if not os.path.exists(localDir): os.makedirs(localDir) #TODO: is this a comprehensive file regex? ... |
filename = filename.replace("/", self.dirSlash) filename = filename.replace("\\\\", "\\") data = self.sendCMD(['hash ' + filename, 'quit'], sleep = 1) | data = self.sendCMD(['hash ' + filename]) | def getRemoteHash(self, filename): filename = filename.replace("/", self.dirSlash) filename = filename.replace("\\\\", "\\") data = self.sendCMD(['hash ' + filename, 'quit'], sleep = 1) if (data == None): return '' retVal = self.stripPrompt(data) if (retVal != None): retVal = retVal.strip('\n') if (self.debug >= 3): pr... |
if (self.debug >= 3): print "remote hash: '" + retVal + "'" | if (self.debug >= 3): print "remote hash returned: '" + retVal + "'" | def getRemoteHash(self, filename): filename = filename.replace("/", self.dirSlash) filename = filename.replace("\\\\", "\\") data = self.sendCMD(['hash ' + filename, 'quit'], sleep = 1) if (data == None): return '' retVal = self.stripPrompt(data) if (retVal != None): retVal = retVal.strip('\n') if (self.debug >= 3): pr... |
mdsum = hashlib.md5() | try: mdsum = hashlib.md5() except: return None | def getLocalHash(self, filename): file = open(filename, 'rb') if (file == None): return None mdsum = hashlib.md5() |
if (self.debug >= 3): print "local hash: '" + hexval + "'" | if (self.debug >= 3): print "local hash returned: '" + hexval + "'" | def getLocalHash(self, filename): file = open(filename, 'rb') if (file == None): return None mdsum = hashlib.md5() |
if (self.dirExists('/tests')): self.deviceRoot = '/tests' else: self.mkDir('/tests') self.deviceRoot = '/tests' | data = self.sendCMD(['testroot']) if (data == None): return '/tests' self.deviceRoot = self.stripPrompt(data).strip('\n') + '/tests' if (not self.dirExists(self.deviceRoot)): self.mkDir(self.deviceRoot) | def getDeviceRoot(self): if (not self.deviceRoot): if (self.dirExists('/tests')): self.deviceRoot = '/tests' else: self.mkDir('/tests') self.deviceRoot = '/tests' return self.deviceRoot |
return self.getDeviceRoot() + '/firefox' | return 'org.mozilla.fennec' | def getAppRoot(self): if (self.dirExists(self.getDeviceRoot() + '/fennec')): return self.getDeviceRoot() + '/fennec' else: return self.getDeviceRoot() + '/firefox' |
self.sendCMD(['cd \\tests', 'unzp ' + filename]) | dir = '' parts = filename.split('/') if (len(parts) > 1): if self.fileExists(filename): dir = '/'.join(parts[:-1]) elif self.fileExists('/' + filename): dir = '/' + filename elif self.fileExists(self.getDeviceRoot() + '/' + filename): dir = self.getDeviceRoot() + '/' + filename else: return None return self.sendCMD(['... | def unpackFile(self, filename): self.sendCMD(['cd \\tests', 'unzp ' + filename]) |
remoteRoot = remoteDir + self.dirSlash + parts[1] remoteRoot = remoteRoot.replace('/', self.dirSlash) remoteRoot = remoteRoot.replace('\\\\', '\\') | remoteRoot = remoteDir + '/' + parts[1] remoteRoot = remoteRoot.replace('/', '/') | def validateDir(self, localDir, remoteDir): if (self.debug >= 2): print "validating directory: " + localDir + " to " + remoteDir for root, dirs, files in os.walk(localDir): parts = root.split(localDir) for file in files: remoteRoot = remoteDir + self.dirSlash + parts[1] remoteRoot = remoteRoot.replace('/', self.dirSlas... |
remoteName = remoteRoot + self.dirSlash + file | remoteName = remoteRoot + '/' + file | def validateDir(self, localDir, remoteDir): if (self.debug >= 2): print "validating directory: " + localDir + " to " + remoteDir for root, dirs, files in os.walk(localDir): parts = root.split(localDir) for file in files: remoteRoot = remoteDir + self.dirSlash + parts[1] remoteRoot = remoteRoot.replace('/', self.dirSlas... |
def getCurrentTime(self): """ return the current time on the device """ data = self.sendCMD(['clok']) if (data == None): return None return self.stripPrompt(data).strip('\n') def addRemoteServerPref(self, profile_dir, server): """ edit the user.js in the profile (on the host machine) and add the xpconnect priviledges ... | def getInfo(self, directive=None): data = None result = {} collapseSpaces = re.compile(' +') directives = ['os', 'id','uptime','systime','screen','memory','process', 'disk','power'] if (directive in directives): directives = [directive] for d in directives: data = self.sendCMD(['info ' + d]) if (data is None): conti... | def getCurrentTime(self): """ return the current time on the device """ data = self.sendCMD(['clok']) if (data == None): return None return self.stripPrompt(data).strip('\n') |
self.timeout = 600 | self.timeout = 1200 | def __init__(self, command, mod, name, child_process, timeout, log, host='', port=20701, root=''): global ffprocess self.command = command self.mod = mod self.process_name = name self.child_process = child_process self.browser_wait = timeout self.log = log self.timeout = 600 #no output from the browser in 10 minutes = ... |
writer = csv.writer(open(os.path.join(csv_dir, res + '_' + count_type + '.csv'), "wb")) | writer = csv.writer(open(os.path.join(csv_dir, counterName + '.csv'), "wb")) | def avg_excluding_max(val_list): """return float rounded to two decimal places, converted to string calculates the average value in the list exluding the max value""" i = len(val_list) total = sum(float(v) for v in val_list) maxval = max(float(v) for v in val_list) if total > maxval: avg = str(round((total - maxval)/(i... |
writer.writerow(['RETURN: ' + res + '_' + count_type + ': ' + avg_excluding_max(cd[count_type]),]) def filesizeformat(bytes): """ Format the value like a 'human-readable' file size (i.e. 13 KB, 4.1 MB, 102 bytes, etc). """ bytes = float(bytes) if bytes < 1024: return "%dB" % (bytes) if bytes < 1024 * 1024: return "%.1... | if isMemoryMetric(shortName(count_type)): writer.writerow(['RETURN: ' + counterName + ': ' + filesizeformat(avg_excluding_max(cd[count_type])),]) else: writer.writerow(['RETURN: ' + counterName + ': ' + avg_excluding_max(cd[count_type]),]) | def avg_excluding_max(val_list): """return float rounded to two decimal places, converted to string calculates the average value in the list exluding the max value""" i = len(val_list) total = sum(float(v) for v in val_list) maxval = max(float(v) for v in val_list) if total > maxval: avg = str(round((total - maxval)/(i... |
memory_metric = ['memset', 'rss', 'pbytes', 'xres', 'modlistbytes'] | def results_from_graph(links, results_server): #take the results from the graph server collection script and put it into a pretty format for the waterfall url_format = "http://%s/%s" link_format= "<a href=\'%s\'>%s</a>" first_results = 'RETURN:<br>' last_results = '' full_results = '\nRETURN:<p style="font-size:smaller... | |
if filter(lambda x: x in linkName, memory_metric): | if isMemoryMetric(linkName): | def results_from_graph(links, results_server): #take the results from the graph server collection script and put it into a pretty format for the waterfall url_format = "http://%s/%s" link_format= "<a href=\'%s\'>%s</a>" first_results = 'RETURN:<br>' last_results = '' full_results = '\nRETURN:<p style="font-size:smaller... |
print 'RETURN: new graph links' | def results_from_graph(links, results_server): #take the results from the graph server collection script and put it into a pretty format for the waterfall url_format = "http://%s/%s" link_format= "<a href=\'%s\'>%s</a>" first_results = 'RETURN:<br>' last_results = '' full_results = '\nRETURN:<p style="font-size:smaller... | |
counterName = testname + '_' + shortName(count_type) utils.stamped_msg("Generating results file: " + counterName, "Started") | def send_to_graph(results_server, results_link, machine, date, browser_config, results): links = '' result_strings = [] #construct all the strings of data, one string per test and one string per counter for testname in results: vals = [] fullname = testname browser_dump, counter_dump, print_format = results[testname]... | |
addon_id = '' | addon_id = None | def install_addon(self, profile_path, addon): """Installs the given addon in the profile. most of this borrowed from mozrunner, except downgraded to work on python 2.4 # Contributor(s) for mozrunner: # Mikeal Rogers <mikeal.rogers@gmail.com> # Clint Talbert <ctalbert@mozilla.com> # Henrik Skupin <hskupin@mozilla.com> "... |
for elem in desc: apps = elem.getElementsByTagName('em:targetApplication') if apps: for app in apps: elem.removeChild(app) addon_id = str(elem.getElementsByTagName('em:id')[0].firstChild.data) | addon_id = find_id(desc) if not addon_id: desc = doc.getElementsByTagName('RDF:Description') addon_id = find_id(desc) | def install_addon(self, profile_path, addon): """Installs the given addon in the profile. most of this borrowed from mozrunner, except downgraded to work on python 2.4 # Contributor(s) for mozrunner: # Mikeal Rogers <mikeal.rogers@gmail.com> # Clint Talbert <ctalbert@mozilla.com> # Henrik Skupin <hskupin@mozilla.com> "... |
os.kill(pid, signal.SIGSEGV) | os.kill(pid, signal.SIGABRT) | def TerminateProcess(self, pid, timeout): """Helper function to terminate a process, given the pid |
for system in config_checks: sys.stdout.write("Checking: %s\n" % (system['name'])) | def get_content(system): | def check_config_value(regex, secure_value, message, content): u"""Test method for doing entire check without code replication""" if regex.search(content): value = regex.findall(content)[-1] if secure_value == value: colour = "green" value = value + " (secure)" else: colour = "red" value = value + " (not secure)" else:... |
content = content + "\n" + open(extra_file, "r").read() | content = content + "\n" + open(os.path.join(path, extra_file), "r").read() | def check_config_value(regex, secure_value, message, content): u"""Test method for doing entire check without code replication""" if regex.search(content): value = regex.findall(content)[-1] if secure_value == value: colour = "green" value = value + " (secure)" else: colour = "red" value = value + " (not secure)" else:... |
if getattr(ref, 'field', None): | if getattr(ref, 'field', None) == None: | def getData(self): """ Returns backreferences: { 'uid-obj-a': { 'the-field': [ 'uid-of-another-unpublished-object', 'my-uid', 'uid-obj-b', ], }, 'uid-obj-b': { 'ref-field': 'my-uid', }, } """ data = {} for ref in self.context.getBackReferenceImpl(): # get source object src = ref.getSourceObject() suid = src.UID() if su... |
if not self.object.__annotations__.has_key('plone.portlets.contextassignments'): | annotations = getattr(self.object, '__annotations__', None) if not annotations: return data if not annotations.has_key('plone.portlets.contextassignments'): | def getData(self): """returns all important data data form {'column': {portlet: {key:value} } . . . . {'blackliststatus': {category:True}, {'order': ['portlet 1', 'portlet 2']} } } """ |
self.assertEquals(['title2', 'collection', 'blubb', 'news', 'search'], self.right_portlets._order) | self.assertEquals(['title2', 'blubb', 'news', 'search', 'collection'], self.right_portlets._order) | def test_portlets_adapter_setter(self): #getter adapter = getAdapter(self.folder1, IDataCollector, name="portlet_data_adapter") data = adapter.getData() |
portlets._order = order | def setData(self, portletsdata, metadata): """create or updates portlet informations """ for manager_name in portletsdata.keys(): column = queryUtility(IPortletManager, name=manager_name, context=self.object) if column is None: Acontinue #ok we have a portlet manager #get all current assigned portlets portlets = getMu... | |
current_criterias = [o.id for o in self.object.objectValues()] | self.object.manage_delObjects([i for i in self.object.objectIds() if i != 'syndication_information']) | def setData(self, topic_criteria_data, metadata): """ creates criterias fro a topic from {'criteria_type':{field_data_adapter result}} """ self.logger.info('Updating criterias for topic (UID %s)' % (self.object.UID()) ) |
if criteria_id not in current_criterias: if 'ATSortCriterion' not in criteria_id: criteria = self.object.addCriterion(data['field'],data['meta_type']) else: criteria = self.object[criteria_id] | def setData(self, topic_criteria_data, metadata): """ creates criterias fro a topic from {'criteria_type':{field_data_adapter result}} """ self.logger.info('Updating criterias for topic (UID %s)' % (self.object.UID()) ) | |
if 'ATSortCriterion' not in criteria_id: criteria = self.object.addCriterion(data['field'],data['meta_type']) | def setData(self, topic_criteria_data, metadata): """ creates criterias fro a topic from {'criteria_type':{field_data_adapter result}} """ self.logger.info('Updating criterias for topic (UID %s)' % (self.object.UID()) ) | |
data[suid][ref.field] = src.getField(ref.field).getRaw(src) | field = src.getField(ref.field) if field: data[suid][ref.field] = field.getRaw(src) | def getData(self): """ Returns backreferences: { 'uid-obj-a': { 'the-field': [ 'uid-of-another-unpublished-object', 'my-uid', 'uid-obj-b', ], }, 'uid-obj-b': { 'ref-field': 'my-uid', }, } """ data = {} for ref in self.context.getBackReferenceImpl(): # get source object src = ref.getSourceObject() suid = src.UID() if su... |
continue | Acontinue | def setData(self, portletsdata, metadata): """create or updates portlet informations """ for manager_name in portletsdata.keys(): column = queryUtility(IPortletManager, name=manager_name, context=self.object) if column is None: continue #ok we have a portlet manager #get all current assigned portlets portlets = getMul... |
order = portletsdata[manager_name]['order'] | order = [portlet_id for portlet_id in portletsdata[manager_name]['order'] if portlet_id in portletsdata[manager_name].keys()] | def setData(self, portletsdata, metadata): """create or updates portlet informations """ for manager_name in portletsdata.keys(): column = queryUtility(IPortletManager, name=manager_name, context=self.object) if column is None: continue #ok we have a portlet manager #get all current assigned portlets portlets = getMul... |
fields += ISchemaExtender(self.object).getFields() | for name, extender in list(getAdapters((self.object,), ISchemaExtender)): fields += extender.getFields() | def getFieldData(self): """ Extracts data from the object fields and creates / returns a dictionary with the data. Objects are converted to string. @return: dictionary with extracetd data @rtype: dict """ data = {} |
'data' : base64.encodestring(value.data), | 'data' : base64.encodestring(tmp.read()), | def fieldSerialization(self, field, value): """ Custom serialization for fields which provide field values that are incompatible with simplejson / JSON-standard. @param field: Field-Object from Schema @type field: Field @param value: Return-Value of the Raw-Accessor of the Field on the current context @type valu... |
order = [portlet_id for portlet_id in portletsdata[manager_name]['order'] if portlet_id in portletsdata[manager_name].keys()] if order: portlets._order = order.split(',') | def setData(self, portletsdata, metadata): """create or updates portlet informations """ for manager_name in portletsdata.keys(): column = queryUtility(IPortletManager, name=manager_name, context=self.object) if column is None: Acontinue #ok we have a portlet manager #get all current assigned portlets portlets = getMu... | |
if portlet_id in portlets.keys(): del portlets[portlet_id] if portlet_id in portlets.keys(): pass | for k,v in portletfielddata.items(): if isinstance(v, dict): klass = modules[v['module']].__dict__[v['klass_name']] imgobj = klass(v['id'],v['title'],base64.decodestring(v['data'])) portletfielddata[k] = imgobj portlets[portlet_id] = portlet_module.Assignment(**portletfielddata) | def setData(self, portletsdata, metadata): """create or updates portlet informations """ for manager_name in portletsdata.keys(): column = queryUtility(IPortletManager, name=manager_name, context=self.object) if column is None: Acontinue #ok we have a portlet manager #get all current assigned portlets portlets = getMu... |
else: portlet_module = modules[portletfielddata['module']] del portletfielddata['module'] for k,v in portletfielddata.items(): if isinstance(v, dict): klass = modules[v['module']].__dict__[v['klass_name']] imgobj = klass(v['id'],v['title'],base64.decodestring(v['data'])) portletfielddata[k] = imgobj portlets[... | for k,v in portletfielddata.items(): if isinstance(v, bool): setattr(portlets[portlet_id], k, v) | def setData(self, portletsdata, metadata): """create or updates portlet informations """ for manager_name in portletsdata.keys(): column = queryUtility(IPortletManager, name=manager_name, context=self.object) if column is None: Acontinue #ok we have a portlet manager #get all current assigned portlets portlets = getMu... |
for k,v in portletfielddata.items(): if isinstance(v, bool): setattr(portlets[portlet_id], k, v) | order = [portlet_id for portlet_id in portletsdata[manager_name]['order'].split(',') if portlet_id in portlets.keys()] if order: portlets._order = order | def setData(self, portletsdata, metadata): """create or updates portlet informations """ for manager_name in portletsdata.keys(): column = queryUtility(IPortletManager, name=manager_name, context=self.object) if column is None: Acontinue #ok we have a portlet manager #get all current assigned portlets portlets = getMu... |
(self.object.UID()) | (uid) | def setData(self, properties, metadata): """ Sets a list of properties on a object. Warning: all currently set properties which are not in the properties-list wille be removed! |
help = 'File to be show, otherwise read from standard input.') | help = 'File to be shown, otherwise read from standard input.') | def natural(value): number = int(value, 10) if number < 0: raise argparse.ArgumentTypeError('%d is not a natural number' % value) return number |
diff_args = ['diff', '-u', '-L', args.L[0], '-L', args.L[1]] | labels = [l.replace('\t', ' ') for l in args.L] diff_args = ['diff', '-u', '-L', labels[0], '-L', labels[1]] | def locale_writer(stream): return codecs.getwriter(locale.getpreferredencoding())(stream) |
else | else: | def size(self): if hasattr(os, 'fstat'): return os.fstat(self.fileno()).st_size else return os.stat(self.name).st_size |
self.keep_tracebacks = asbool(kwargs.get('keep_tracebacks', config.get('keep_tracebacks', False))) | self.keep_tracebacks = asbool(kwargs.get( 'keep_tracebacks', config.get( 'keep_tracebacks', RequestHandler.keep_tracebacks))) self.keep_tracebacks_limit = int(kwargs.get( 'keep_tracebacks_limit', config.get( 'keep_tracebacks_limit', RequestHandler.keep_tracebacks_limit))) self.skip_last_n_frames = int(kwargs.get( 'skip... | def __init__(self, app, config=None, loglevel='DEBUG', **kwargs): """Stores logging statements per request, and includes a bar on the page that shows the logging statements |
self.keep_tracebacks = False | def __init__(self): """Initialize the handler.""" logging.Handler.__init__(self) self.buffer = {} self.keep_tracebacks = False | |
record.traceback = ''.join(traceback.format_stack(sys._getframe(6))) | if (not self.keep_tracebacks_limit or len(self.buffer[record.thread]) < self.keep_tracebacks_limit): f = sys._getframe(self.skip_last_n_frames) record.traceback = ''.join(traceback.format_stack(f)) | def emit(self, record): """Emit a record. |
languages = files.keys() | pull_languages = files.keys() | def pull(self, languages=[], resources=[], overwrite=True, fetchall=False, force=False): """ Pull all translations file from transifex server """ if resources: resource_list = resources else: resource_list = self.get_resource_list() |
languages.remove(l) | pull_languages.remove(l) | def pull(self, languages=[], resources=[], overwrite=True, fetchall=False, force=False): """ Pull all translations file from transifex server """ if resources: resource_list = resources else: resource_list = self.get_resource_list() |
for lang in languages: | for lang in pull_languages: | def pull(self, languages=[], resources=[], overwrite=True, fetchall=False, force=False): """ Pull all translations file from transifex server """ if resources: resource_list = resources else: resource_list = self.get_resource_list() |
if languages and lang not in languages: | if languages and lang not in pull_languages: | def pull(self, languages=[], resources=[], overwrite=True, fetchall=False, force=False): """ Pull all translations file from transifex server """ if resources: resource_list = resources else: resource_list = self.get_resource_list() |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.