rem
stringlengths 1
322k
| add
stringlengths 0
2.05M
| context
stringlengths 4
228k
| meta
stringlengths 156
215
|
---|---|---|---|
predefined = { 'TODO': 'SUBMITTED,WAITING,READY,QUEUED', 'ALL': 'SUBMITTED,WAITING,READY,QUEUED,RUNNING', 'COMPLETE': str.join(',', Job.states)} | predefined = { 'TODO': 'SUBMITTED,WAITING,READY,QUEUED', 'ALL': str.join(',', Job.states)} | def getJobs(self, selector): predefined = { 'TODO': 'SUBMITTED,WAITING,READY,QUEUED', 'ALL': 'SUBMITTED,WAITING,READY,QUEUED,RUNNING', 'COMPLETE': str.join(',', Job.states)} jobFilter = predefined.get(selector.upper(), selector.upper()) | 1d672dd0ac973e070b3223da423ac624c4f866aa /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/8443/1d672dd0ac973e070b3223da423ac624c4f866aa/job_db.py |
regex = re.compile(site) if regex.search(dest) and jobObj.state not in (Job.SUCCESS, Job.FAILED): | if re.compile(site).search(dest): | def siteFilter(jobObj): dest = jobObj.get("dest") if not dest: return False dest = str.join("/", map(lambda x: x.split(":")[0], dest.upper().split("/"))) for site in jobFilter.split(','): regex = re.compile(site) if regex.search(dest) and jobObj.state not in (Job.SUCCESS, Job.FAILED): return True return False | 1d672dd0ac973e070b3223da423ac624c4f866aa /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/8443/1d672dd0ac973e070b3223da423ac624c4f866aa/job_db.py |
infos[dsName][DataProvider.lfn] = block[DataProvider.FileList][0][DataProvider.lfn] | if len(block[DataProvider.FileList]): infos[dsName][DataProvider.lfn] = block[DataProvider.FileList][0][DataProvider.lfn] | def unique(seq): set = {} map(set.__setitem__, seq, []) return set.keys() | 5abdbf289399736ed597228cd18d8075e6184ac7 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/8443/5abdbf289399736ed597228cd18d8075e6184ac7/datasetListInfo.py |
wms = config.get(backend, 'wms', defaultwms[backend]) wms = WMS.open(wms, config, module, monitor) | if backend == 'grid': wms = WMS.open(config.get(backend, 'wms', 'GliteWMS'), config, module, monitor) elif backend == 'local': wms = WMS.open(defaultwms[backend], config, module, monitor) else: raise UserError("Invalid backend specified!" % config.workDir) | def interrupt(sig, frame): global opts, log, handler opts.abort = True log = utils.ActivityLog('Quitting grid-control! (This can take a few seconds...)') signal.signal(signal.SIGINT, handler) | a7ee33ef9aaa5a422776375dba59e324d6874db4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/8443/a7ee33ef9aaa5a422776375dba59e324d6874db4/go.py |
def getMissing(self, nJobs): | def extendJobDB(self, nJobs): | def getMissing(self, nJobs): self.nJobs = nJobs if len(self._jobs) < nJobs: return filter(lambda x: x not in self._jobs, range(nJobs)) return [] | fae3293189327f9ad5eb9062c6b1154674e82ed4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/8443/fae3293189327f9ad5eb9062c6b1154674e82ed4/job_db.py |
return jobNum in map(int, arg.split(",")) | def checkID(idArg): (start, end) = (idArg.split('-')[0], idArg.split('-')[-1]) if (start == '') or jobNum >= int(start): if (end == '') or jobNum <= int(end): return True return False return reduce(operator.or_, map(checkID, arg.split(","))) | def selectByID(jobNum, jobObj, arg): try: return jobNum in map(int, arg.split(",")) except: raise UserError('Job identifiers must be integers.') | fae3293189327f9ad5eb9062c6b1154674e82ed4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/8443/fae3293189327f9ad5eb9062c6b1154674e82ed4/job_db.py |
raise UserError('Job identifiers must be integers.') | raise UserError('Job identifiers must be integers or ranges.') | def selectByID(jobNum, jobObj, arg): try: return jobNum in map(int, arg.split(",")) except: raise UserError('Job identifiers must be integers.') | fae3293189327f9ad5eb9062c6b1154674e82ed4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/8443/fae3293189327f9ad5eb9062c6b1154674e82ed4/job_db.py |
def selectSpecific(specific): selectorType = QM(sepcific.isdigit(), 'id', 'state') | def selectSpecific(specific): cmpValue = QM(specific[0] == '~', False, True) specific = specific.lstrip('~') selectorType = QM(specific[0].isdigit(), 'id', 'state') | def selectSpecific(specific): selectorType = QM(sepcific.isdigit(), 'id', 'state') if ':' in specific: selectorType = specific.split(':', 1)[0].lower() return selectorMap[selectorType](jobNum, jobObj, specific.split(':', 1)[-1]) | fae3293189327f9ad5eb9062c6b1154674e82ed4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/8443/fae3293189327f9ad5eb9062c6b1154674e82ed4/job_db.py |
return selectorMap[selectorType](jobNum, jobObj, specific.split(':', 1)[-1]) | return selectorMap[selectorType](jobNum, jobObj, specific.split(':', 1)[-1]) == cmpValue | def selectSpecific(specific): selectorType = QM(sepcific.isdigit(), 'id', 'state') if ':' in specific: selectorType = specific.split(':', 1)[0].lower() return selectorMap[selectorType](jobNum, jobObj, specific.split(':', 1)[-1]) | fae3293189327f9ad5eb9062c6b1154674e82ed4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/8443/fae3293189327f9ad5eb9062c6b1154674e82ed4/job_db.py |
self.ready.extend(self.jobDB.getMissing(self.nJobs)) | self.ready.extend(self.jobDB.extendJobDB(self.nJobs)) | def __init__(self, config, module, monitor): (self.module, self.monitor) = (module, monitor) self.errorDict = module.errorDict self._dbPath = os.path.join(config.workDir, 'jobs') self.disableLog = os.path.join(config.workDir, 'disabled') try: if not os.path.exists(self._dbPath): if config.opts.init: os.mkdir(self._dbPath) else: raise ConfigError("Not a properly initialized work directory '%s'." % config.workDir) except IOError: raise RethrowError("Problem creating work directory '%s'" % self._dbPath) | fae3293189327f9ad5eb9062c6b1154674e82ed4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/8443/fae3293189327f9ad5eb9062c6b1154674e82ed4/job_db.py |
self.ready.extend(self.jobDB.getMissing(self.nJobs)) | self.ready.extend(self.jobDB.extendJobDB(self.nJobs)) | def resetState(jobs, newState): jobSet = utils.set(jobs) for jobNum in jobs: jobObj = self.jobDB.get(jobNum) if jobObj.state in [ Job.INIT, Job.DISABLED, Job.ABORTED, Job.CANCELLED, Job.DONE, Job.FAILED, Job.SUCCESS ]: self._update(jobObj, jobNum, newState) jobSet.remove(jobNum) jobObj.attempt = 0 if len(jobSet) > 0: output = (Job.states[newState], str.join(', ', map(str, jobSet))) raise RuntimeError('For the following jobs it was not possible to reset the state to %s:\n%s' % output) | fae3293189327f9ad5eb9062c6b1154674e82ed4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/8443/fae3293189327f9ad5eb9062c6b1154674e82ed4/job_db.py |
params = PBSGE.getSubmitArguments(self, jobNum, sandbox, stdout, stderr, addAttr, reqMap) | params = PBSGECommon.getSubmitArguments(self, jobNum, sandbox, stdout, stderr, addAttr, reqMap) | def getSubmitArguments(self, jobNum, sandbox, stdout, stderr, addAttr): reqMap = { WMS.MEMORY: ("pvmem", lambda m: "%dmb" % m) } params = PBSGE.getSubmitArguments(self, jobNum, sandbox, stdout, stderr, addAttr, reqMap) # Job requirements reqs = dict(self.wms.getRequirements(jobNum)) if reqs.get(WMS.SITES, (None, None))[1]: params += ' -l host=%s' % str.join("+", reqs[WMS.SITES][1]) return params | f642d6218e107fc5c46d7f5902becdbca605ae86 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/8443/f642d6218e107fc5c46d7f5902becdbca605ae86/pbs.py |
if len(self.sePaths) <= 1: | if len(self.sePaths) == 1: | def getTaskConfig(self): taskConfig = { # Space limits 'SCRATCH_UL' : self.seSDUpperLimit, 'SCRATCH_LL' : self.seSDLowerLimit, 'LANDINGZONE_UL': self.seLZUpperLimit, 'LANDINGZONE_LL': self.seLZLowerLimit, # Storage element 'SE_MINFILESIZE': self.seMinSize, 'SE_OUTPUT_FILES': str.join(' ', self.seOutputFiles), 'SE_INPUT_FILES': str.join(' ', self.seInputFiles), 'SE_OUTPUT_PATTERN': self.seOutputPattern, 'SE_INPUT_PATTERN': self.seInputPattern, # Sandbox 'SB_OUTPUT_FILES': str.join(' ', self.getOutFiles()), 'SB_INPUT_FILES': str.join(' ', map(utils.shellEscape, map(os.path.basename, self.getInFiles()))), # Runtime 'DOBREAK': self.nodeTimeout, 'MY_RUNTIME': self.getCommand(), 'GC_DEPFILES': str.join(' ', self.getDependencies()), # Seeds and substitutions 'SEEDS': str.join(' ', map(str, self.seeds)), 'SUBST_FILES': str.join(' ', map(os.path.basename, self.getSubstFiles())), # Task infos 'TASK_ID': self.taskID, 'GC_CONF': self.config.confName, 'GC_VERSION': utils.getVersion(), 'DB_EXEC': 'shellscript' } if len(self.sePaths) <= 1: taskConfig['SE_PATH'] = self.sePaths[0] return dict(taskConfig.items() + self.constants.items()) | 0920550492cbb06a9a58fc3a7bcabf24771555a0 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/8443/0920550492cbb06a9a58fc3a7bcabf24771555a0/module.py |
tmp = map(str.strip, rsplit(line, '=', 1)) | tmp = map(str.strip, [i[::-1] for i in line[::-1].split("=",1)[::-1]]) | def doFilter(blockinfo): name = self._filter if self._filter: name = blockinfo[DataProvider.Dataset] if DataProvider.BlockName in blockinfo and "#" in self._filter: name = "%s#%s" % (name, blockinfo[DataProvider.BlockName]) if name.startswith(self._filter): return True return False | 8dc40669421a368436f240739cd07eac54e00844 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/8443/8dc40669421a368436f240739cd07eac54e00844/provider_basic.py |
selist = self.dataSplitter.getSplitInfo(jobNum).get(DataSplitter.SEList, []) if selist != None: | selist = self.dataSplitter.getSplitInfo(jobNum).get(DataSplitter.SEList, False) if selist != False: | def getRequirements(self, jobNum): reqs = Module.getRequirements(self, jobNum) if self.dataSplitter != None: selist = self.dataSplitter.getSplitInfo(jobNum).get(DataSplitter.SEList, []) if selist != None: reqs.append((WMS.STORAGE, selist)) return reqs | 85dd2751878f085523c6f257ebf20af8407910f3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/8443/85dd2751878f085523c6f257ebf20af8407910f3/datamod.py |
result.extend(api.listFiles(self.datasetPath, retriveList=([], ['retrive_lumi'])[self.selectedLumis])) | result.extend(api.listFiles(self.datasetPath, retriveList=(['retrive_lumi'], [])[self.selectedLumis == '' ])) | def listFileInfoThread(self, result): result.extend(api.listFiles(self.datasetPath, retriveList=([], ['retrive_lumi'])[self.selectedLumis])) | 19191655f6392d56fca7bc6a3731aea61390b5a6 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/8443/19191655f6392d56fca7bc6a3731aea61390b5a6/provider_dbsv2.py |
if 'config file' in config.parser.options(self.__class__.__name__): raise ConfigError("Please use 'nickname config' instead of 'config file'") | def parseMap(x, parser): result = {} for entry in x.split('\n'): if "=>" in entry: nick, value = map(str.strip, entry.split('=>')) else: nick, value = (None, entry) result[nick] = filter(lambda x: x, parser(value.strip())) return result | a43bea10a1881d93c54f0a88f30edaa3d31d1ad8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/8443/a43bea10a1881d93c54f0a88f30edaa3d31d1ad8/cmssw_advanced.py |
|
return self.selectedLumis == None | return False | def lumiFilter(lfn): for lumi in listLumiInfo[lfn]: if selectLumi(lumi, self.selectedLumis): return True return self.selectedLumis == None | bfc54e5df32fb542c082f8c3d690825f31e75090 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/8443/bfc54e5df32fb542c082f8c3d690825f31e75090/provider_dbsv2.py |
se_rm = lambda target: utils.LoggedProcess(se_runcmd("url_rm", se_url(target))) | se_rm = lambda target: utils.LoggedProcess(se_runcmd("url_rm", target)) | def se_runcmd(cmd, urls): runLib = utils.pathGC('share', 'gc-run.lib') urlargs = str.join(' ', map(lambda x: '"%s"' % x.replace('dir://', 'file://'), urls)) return 'source %s || exit 1; print_and_eval "%s" %s' % (runLib, cmd, urlargs) | 4373c49969d7d4f906a48b713fc72e43b61f6f22 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/8443/4373c49969d7d4f906a48b713fc72e43b61f6f22/se_utils.py |
def lenSplit(list, maxlen): clen = 0 tmp = [] for item in list: if clen + len(item) < maxlen: tmp.append(item) clen += len(item) else: tmp.append('') yield tmp tmp = [item] clen = len(item) yield tmp | 6f1ce4463fea7b255caf5af4e5250ca38457ef47 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/8443/6f1ce4463fea7b255caf5af4e5250ca38457ef47/queryRunRegistry.py |
||
def bytes(obj, enc = None): | def bytes(obj, enc=None): | def bytes(obj, enc = None): return obj | 9c2eaf1c9f74544afe20a86fa591d97eeaa8921c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/13138/9c2eaf1c9f74544afe20a86fa591d97eeaa8921c/socks.py |
"invalid data", "not connected", "not available", "bad proxy type", "bad input") | "invalid data", "not connected", "not available", "bad proxy type", "bad input") | def __str__(self): return repr(self.value) | 9c2eaf1c9f74544afe20a86fa591d97eeaa8921c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/13138/9c2eaf1c9f74544afe20a86fa591d97eeaa8921c/socks.py |
"general SOCKS server failure", "connection not allowed by ruleset", "Network unreachable", "Host unreachable", "Connection refused", "TTL expired", "Command not supported", "Address type not supported", "Unknown error") | "general SOCKS server failure", "connection not allowed by ruleset", "Network unreachable", "Host unreachable", "Connection refused", "TTL expired", "Command not supported", "Address type not supported", "Unknown error") | def __str__(self): return repr(self.value) | 9c2eaf1c9f74544afe20a86fa591d97eeaa8921c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/13138/9c2eaf1c9f74544afe20a86fa591d97eeaa8921c/socks.py |
"authentication is required", "all offered authentication methods were rejected", "unknown username or invalid password", "unknown error") | "authentication is required", "all offered authentication methods were rejected", "unknown username or invalid password", "unknown error") | def __str__(self): return repr(self.value) | 9c2eaf1c9f74544afe20a86fa591d97eeaa8921c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/13138/9c2eaf1c9f74544afe20a86fa591d97eeaa8921c/socks.py |
"request rejected or failed", "request rejected because SOCKS server cannot connect to identd on the client", "request rejected because the client program and identd report different user-ids", "unknown error") def setdefaultproxy(proxytype=None,addr=None,port=None,rdns=True,username=None,password=None): | "request rejected or failed", ("request rejected because SOCKS server cannot connect to " "identd on the client"), ("request rejected because the client program and identd" " report different user-ids"), "unknown error") def setdefaultproxy(proxytype=None, addr=None, port=None, rdns=True, username=None, password=None): | def __str__(self): return repr(self.value) | 9c2eaf1c9f74544afe20a86fa591d97eeaa8921c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/13138/9c2eaf1c9f74544afe20a86fa591d97eeaa8921c/socks.py |
_defaultproxy = (proxytype,addr,port,rdns,username,password) | _defaultproxy = (proxytype, addr, port, rdns, username, password) | def setdefaultproxy(proxytype=None,addr=None,port=None,rdns=True,username=None,password=None): """setdefaultproxy(proxytype, addr[, port[, rdns[, username[, password]]]]) Sets a default proxy which all further socksocket objects will use, unless explicitly changed. """ global _defaultproxy _defaultproxy = (proxytype,addr,port,rdns,username,password) | 9c2eaf1c9f74544afe20a86fa591d97eeaa8921c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/13138/9c2eaf1c9f74544afe20a86fa591d97eeaa8921c/socks.py |
def __init__(self, family=socket.AF_INET, type=socket.SOCK_STREAM, proto=0, _sock=None): _orgsocket.__init__(self,family,type,proto,_sock) | def __init__(self, family=socket.AF_INET, type=socket.SOCK_STREAM, proto=0, _sock=None): socket.socket.__init__(self, family, type, proto, _sock) | def __init__(self, family=socket.AF_INET, type=socket.SOCK_STREAM, proto=0, _sock=None): _orgsocket.__init__(self,family,type,proto,_sock) if _defaultproxy != None: self.__proxy = _defaultproxy else: self.__proxy = (None, None, None, None, None, None) self.__proxysockname = None self.__proxypeername = None | 9c2eaf1c9f74544afe20a86fa591d97eeaa8921c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/13138/9c2eaf1c9f74544afe20a86fa591d97eeaa8921c/socks.py |
if 'decode' in dir(bytes): | if getattr(bytes, 'decode', False): | def __decode(self, bytes): if 'decode' in dir(bytes): try: bytes = bytes.decode() except Exception: pass return bytes | 9c2eaf1c9f74544afe20a86fa591d97eeaa8921c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/13138/9c2eaf1c9f74544afe20a86fa591d97eeaa8921c/socks.py |
if 'encode' in dir(bytes): | if getattr(bytes, 'encode', False): | def __encode(self, bytes): if 'encode' in dir(bytes): try: bytes = bytes.encode() except Exception: pass return bytes | 9c2eaf1c9f74544afe20a86fa591d97eeaa8921c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/13138/9c2eaf1c9f74544afe20a86fa591d97eeaa8921c/socks.py |
d = self.recv(count-len(data)) if not d: raise GeneralProxyError((0,"connection closed unexpectedly")) | d = self.recv(count - len(data)) if not d: raise GeneralProxyError( (0, "connection closed unexpectedly")) | def __recvall(self, count): """__recvall(count) -> data Receive EXACTLY the number of bytes requested from the socket. Blocks until the required number of bytes have been received. """ data = bytes("") while len(data) < count: d = self.recv(count-len(data)) if not d: raise GeneralProxyError((0,"connection closed unexpectedly")) data = data + self.__decode(d) return data | 9c2eaf1c9f74544afe20a86fa591d97eeaa8921c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/13138/9c2eaf1c9f74544afe20a86fa591d97eeaa8921c/socks.py |
def setproxy(self,proxytype=None,addr=None,port=None,rdns=True,username=None,password=None): | def setproxy(self, proxytype=None, addr=None, port=None, rdns=True, username=None, password=None): | def setproxy(self,proxytype=None,addr=None,port=None,rdns=True,username=None,password=None): """setproxy(proxytype, addr[, port[, rdns[, username[, password]]]]) Sets the proxy to be used. proxytype - The type of the proxy to be used. Three types are supported: PROXY_TYPE_SOCKS4 (including socks4a), PROXY_TYPE_SOCKS5 and PROXY_TYPE_HTTP addr - The address of the server (IP or DNS). port - The port of the server. Defaults to 1080 for SOCKS servers and 8080 for HTTP proxy servers. rdns - Should DNS queries be preformed on the remote side (rather than the local side). The default is True. Note: This has no effect with SOCKS4 servers. username - Username to authenticate with to the server. The default is no authentication. password - Password to authenticate with to the server. Only relevant when username is also provided. """ self.__proxy = (proxytype,addr,port,rdns,username,password) | 9c2eaf1c9f74544afe20a86fa591d97eeaa8921c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/13138/9c2eaf1c9f74544afe20a86fa591d97eeaa8921c/socks.py |
self.__proxy = (proxytype,addr,port,rdns,username,password) def __negotiatesocks5(self,destaddr,destport): | self.__proxy = (proxytype, addr, port, rdns, username, password) def __negotiatesocks5(self, destaddr, destport): | def setproxy(self,proxytype=None,addr=None,port=None,rdns=True,username=None,password=None): """setproxy(proxytype, addr[, port[, rdns[, username[, password]]]]) Sets the proxy to be used. proxytype - The type of the proxy to be used. Three types are supported: PROXY_TYPE_SOCKS4 (including socks4a), PROXY_TYPE_SOCKS5 and PROXY_TYPE_HTTP addr - The address of the server (IP or DNS). port - The port of the server. Defaults to 1080 for SOCKS servers and 8080 for HTTP proxy servers. rdns - Should DNS queries be preformed on the remote side (rather than the local side). The default is True. Note: This has no effect with SOCKS4 servers. username - Username to authenticate with to the server. The default is no authentication. password - Password to authenticate with to the server. Only relevant when username is also provided. """ self.__proxy = (proxytype,addr,port,rdns,username,password) | 9c2eaf1c9f74544afe20a86fa591d97eeaa8921c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/13138/9c2eaf1c9f74544afe20a86fa591d97eeaa8921c/socks.py |
if (self.__proxy[4]!=None) and (self.__proxy[5]!=None): | if (self.__proxy[4] != None) and (self.__proxy[5] != None): | def __negotiatesocks5(self,destaddr,destport): """__negotiatesocks5(self,destaddr,destport) Negotiates a connection through a SOCKS5 server. """ # First we'll send the authentication packages we support. if (self.__proxy[4]!=None) and (self.__proxy[5]!=None): # The username/password details were supplied to the # setproxy method so we support the USERNAME/PASSWORD # authentication (in addition to the standard none). self.sendall("\x05\x02\x00\x02") else: # No username/password were entered, therefore we # only support connections with no authentication. self.sendall("\x05\x01\x00") # We'll receive the server's response to determine which # method was selected chosenauth = self.__recvall(2) if chosenauth[0] != "\x05": self.close() raise GeneralProxyError((1,_generalerrors[1])) # Check the chosen authentication method if chosenauth[1] == "\x00": # No authentication is required pass elif chosenauth[1] == "\x02": # Okay, we need to perform a basic username/password # authentication. self.sendall("\x01" + chr(len(self.__proxy[4])) + self.__proxy[4] + chr(len(self.__proxy[5])) + self.__proxy[5]) authstat = self.__recvall(2) if authstat[0] != "\x01": # Bad response self.close() raise GeneralProxyError((1,_generalerrors[1])) if authstat[1] != "\x00": # Authentication failed self.close() raise Socks5AuthError((3,_socks5autherrors[3])) # Authentication succeeded else: # Reaching here is always bad self.close() if chosenauth[1] == "\xFF": raise Socks5AuthError((2,_socks5autherrors[2])) else: raise GeneralProxyError((1,_generalerrors[1])) # Now we can request the actual connection req = "\x05\x01\x00" # If the given destination address is an IP address, we'll # use the IPv4 address request even if remote resolving was specified. try: ipaddr = socket.inet_aton(destaddr) req = req + "\x01" + ipaddr except socket.error: # Well it's not an IP number, so it's probably a DNS name. if self.__proxy[3]==True: # Resolve remotely ipaddr = None req = req + "\x03" + chr(len(destaddr)) + destaddr else: # Resolve locally ipaddr = socket.inet_aton(socket.gethostbyname(destaddr)) req = req + "\x01" + ipaddr req = req + self.__decode(struct.pack(">H",destport)) self.sendall(req) # Get the response resp = self.__recvall(4) if resp[0] != "\x05": self.close() raise GeneralProxyError((1,_generalerrors[1])) elif resp[1] != "\x00": # Connection failed self.close() if ord(resp[1])<=8: raise Socks5Error((ord(resp[1]),_socks5errors[ord(resp[1])])) else: raise Socks5Error((9,_socks5errors[9])) # Get the bound address/port elif resp[3] == "\x01": boundaddr = self.__recvall(4) elif resp[3] == "\x03": resp = resp + self.recv(1) boundaddr = self.__recvall(ord(resp[4])) else: self.close() raise GeneralProxyError((1,_generalerrors[1])) boundport = struct.unpack(">H",bytes(self.__recvall(2), 'utf8'))[0] self.__proxysockname = (boundaddr,boundport) if ipaddr != None: self.__proxypeername = (socket.inet_ntoa(ipaddr),destport) else: self.__proxypeername = (destaddr,destport) | 9c2eaf1c9f74544afe20a86fa591d97eeaa8921c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/13138/9c2eaf1c9f74544afe20a86fa591d97eeaa8921c/socks.py |
raise GeneralProxyError((1,_generalerrors[1])) | raise GeneralProxyError((1, _generalerrors[1])) | def __negotiatesocks5(self,destaddr,destport): """__negotiatesocks5(self,destaddr,destport) Negotiates a connection through a SOCKS5 server. """ # First we'll send the authentication packages we support. if (self.__proxy[4]!=None) and (self.__proxy[5]!=None): # The username/password details were supplied to the # setproxy method so we support the USERNAME/PASSWORD # authentication (in addition to the standard none). self.sendall("\x05\x02\x00\x02") else: # No username/password were entered, therefore we # only support connections with no authentication. self.sendall("\x05\x01\x00") # We'll receive the server's response to determine which # method was selected chosenauth = self.__recvall(2) if chosenauth[0] != "\x05": self.close() raise GeneralProxyError((1,_generalerrors[1])) # Check the chosen authentication method if chosenauth[1] == "\x00": # No authentication is required pass elif chosenauth[1] == "\x02": # Okay, we need to perform a basic username/password # authentication. self.sendall("\x01" + chr(len(self.__proxy[4])) + self.__proxy[4] + chr(len(self.__proxy[5])) + self.__proxy[5]) authstat = self.__recvall(2) if authstat[0] != "\x01": # Bad response self.close() raise GeneralProxyError((1,_generalerrors[1])) if authstat[1] != "\x00": # Authentication failed self.close() raise Socks5AuthError((3,_socks5autherrors[3])) # Authentication succeeded else: # Reaching here is always bad self.close() if chosenauth[1] == "\xFF": raise Socks5AuthError((2,_socks5autherrors[2])) else: raise GeneralProxyError((1,_generalerrors[1])) # Now we can request the actual connection req = "\x05\x01\x00" # If the given destination address is an IP address, we'll # use the IPv4 address request even if remote resolving was specified. try: ipaddr = socket.inet_aton(destaddr) req = req + "\x01" + ipaddr except socket.error: # Well it's not an IP number, so it's probably a DNS name. if self.__proxy[3]==True: # Resolve remotely ipaddr = None req = req + "\x03" + chr(len(destaddr)) + destaddr else: # Resolve locally ipaddr = socket.inet_aton(socket.gethostbyname(destaddr)) req = req + "\x01" + ipaddr req = req + self.__decode(struct.pack(">H",destport)) self.sendall(req) # Get the response resp = self.__recvall(4) if resp[0] != "\x05": self.close() raise GeneralProxyError((1,_generalerrors[1])) elif resp[1] != "\x00": # Connection failed self.close() if ord(resp[1])<=8: raise Socks5Error((ord(resp[1]),_socks5errors[ord(resp[1])])) else: raise Socks5Error((9,_socks5errors[9])) # Get the bound address/port elif resp[3] == "\x01": boundaddr = self.__recvall(4) elif resp[3] == "\x03": resp = resp + self.recv(1) boundaddr = self.__recvall(ord(resp[4])) else: self.close() raise GeneralProxyError((1,_generalerrors[1])) boundport = struct.unpack(">H",bytes(self.__recvall(2), 'utf8'))[0] self.__proxysockname = (boundaddr,boundport) if ipaddr != None: self.__proxypeername = (socket.inet_ntoa(ipaddr),destport) else: self.__proxypeername = (destaddr,destport) | 9c2eaf1c9f74544afe20a86fa591d97eeaa8921c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/13138/9c2eaf1c9f74544afe20a86fa591d97eeaa8921c/socks.py |
self.sendall("\x01" + chr(len(self.__proxy[4])) + self.__proxy[4] + chr(len(self.__proxy[5])) + self.__proxy[5]) | self.sendall("\x01" + chr(len(self.__proxy[4])) + self.__proxy[4] + chr(len(self.__proxy[5])) + self.__proxy[5]) | def __negotiatesocks5(self,destaddr,destport): """__negotiatesocks5(self,destaddr,destport) Negotiates a connection through a SOCKS5 server. """ # First we'll send the authentication packages we support. if (self.__proxy[4]!=None) and (self.__proxy[5]!=None): # The username/password details were supplied to the # setproxy method so we support the USERNAME/PASSWORD # authentication (in addition to the standard none). self.sendall("\x05\x02\x00\x02") else: # No username/password were entered, therefore we # only support connections with no authentication. self.sendall("\x05\x01\x00") # We'll receive the server's response to determine which # method was selected chosenauth = self.__recvall(2) if chosenauth[0] != "\x05": self.close() raise GeneralProxyError((1,_generalerrors[1])) # Check the chosen authentication method if chosenauth[1] == "\x00": # No authentication is required pass elif chosenauth[1] == "\x02": # Okay, we need to perform a basic username/password # authentication. self.sendall("\x01" + chr(len(self.__proxy[4])) + self.__proxy[4] + chr(len(self.__proxy[5])) + self.__proxy[5]) authstat = self.__recvall(2) if authstat[0] != "\x01": # Bad response self.close() raise GeneralProxyError((1,_generalerrors[1])) if authstat[1] != "\x00": # Authentication failed self.close() raise Socks5AuthError((3,_socks5autherrors[3])) # Authentication succeeded else: # Reaching here is always bad self.close() if chosenauth[1] == "\xFF": raise Socks5AuthError((2,_socks5autherrors[2])) else: raise GeneralProxyError((1,_generalerrors[1])) # Now we can request the actual connection req = "\x05\x01\x00" # If the given destination address is an IP address, we'll # use the IPv4 address request even if remote resolving was specified. try: ipaddr = socket.inet_aton(destaddr) req = req + "\x01" + ipaddr except socket.error: # Well it's not an IP number, so it's probably a DNS name. if self.__proxy[3]==True: # Resolve remotely ipaddr = None req = req + "\x03" + chr(len(destaddr)) + destaddr else: # Resolve locally ipaddr = socket.inet_aton(socket.gethostbyname(destaddr)) req = req + "\x01" + ipaddr req = req + self.__decode(struct.pack(">H",destport)) self.sendall(req) # Get the response resp = self.__recvall(4) if resp[0] != "\x05": self.close() raise GeneralProxyError((1,_generalerrors[1])) elif resp[1] != "\x00": # Connection failed self.close() if ord(resp[1])<=8: raise Socks5Error((ord(resp[1]),_socks5errors[ord(resp[1])])) else: raise Socks5Error((9,_socks5errors[9])) # Get the bound address/port elif resp[3] == "\x01": boundaddr = self.__recvall(4) elif resp[3] == "\x03": resp = resp + self.recv(1) boundaddr = self.__recvall(ord(resp[4])) else: self.close() raise GeneralProxyError((1,_generalerrors[1])) boundport = struct.unpack(">H",bytes(self.__recvall(2), 'utf8'))[0] self.__proxysockname = (boundaddr,boundport) if ipaddr != None: self.__proxypeername = (socket.inet_ntoa(ipaddr),destport) else: self.__proxypeername = (destaddr,destport) | 9c2eaf1c9f74544afe20a86fa591d97eeaa8921c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/13138/9c2eaf1c9f74544afe20a86fa591d97eeaa8921c/socks.py |
raise GeneralProxyError((1,_generalerrors[1])) | raise GeneralProxyError((1, _generalerrors[1])) | def __negotiatesocks5(self,destaddr,destport): """__negotiatesocks5(self,destaddr,destport) Negotiates a connection through a SOCKS5 server. """ # First we'll send the authentication packages we support. if (self.__proxy[4]!=None) and (self.__proxy[5]!=None): # The username/password details were supplied to the # setproxy method so we support the USERNAME/PASSWORD # authentication (in addition to the standard none). self.sendall("\x05\x02\x00\x02") else: # No username/password were entered, therefore we # only support connections with no authentication. self.sendall("\x05\x01\x00") # We'll receive the server's response to determine which # method was selected chosenauth = self.__recvall(2) if chosenauth[0] != "\x05": self.close() raise GeneralProxyError((1,_generalerrors[1])) # Check the chosen authentication method if chosenauth[1] == "\x00": # No authentication is required pass elif chosenauth[1] == "\x02": # Okay, we need to perform a basic username/password # authentication. self.sendall("\x01" + chr(len(self.__proxy[4])) + self.__proxy[4] + chr(len(self.__proxy[5])) + self.__proxy[5]) authstat = self.__recvall(2) if authstat[0] != "\x01": # Bad response self.close() raise GeneralProxyError((1,_generalerrors[1])) if authstat[1] != "\x00": # Authentication failed self.close() raise Socks5AuthError((3,_socks5autherrors[3])) # Authentication succeeded else: # Reaching here is always bad self.close() if chosenauth[1] == "\xFF": raise Socks5AuthError((2,_socks5autherrors[2])) else: raise GeneralProxyError((1,_generalerrors[1])) # Now we can request the actual connection req = "\x05\x01\x00" # If the given destination address is an IP address, we'll # use the IPv4 address request even if remote resolving was specified. try: ipaddr = socket.inet_aton(destaddr) req = req + "\x01" + ipaddr except socket.error: # Well it's not an IP number, so it's probably a DNS name. if self.__proxy[3]==True: # Resolve remotely ipaddr = None req = req + "\x03" + chr(len(destaddr)) + destaddr else: # Resolve locally ipaddr = socket.inet_aton(socket.gethostbyname(destaddr)) req = req + "\x01" + ipaddr req = req + self.__decode(struct.pack(">H",destport)) self.sendall(req) # Get the response resp = self.__recvall(4) if resp[0] != "\x05": self.close() raise GeneralProxyError((1,_generalerrors[1])) elif resp[1] != "\x00": # Connection failed self.close() if ord(resp[1])<=8: raise Socks5Error((ord(resp[1]),_socks5errors[ord(resp[1])])) else: raise Socks5Error((9,_socks5errors[9])) # Get the bound address/port elif resp[3] == "\x01": boundaddr = self.__recvall(4) elif resp[3] == "\x03": resp = resp + self.recv(1) boundaddr = self.__recvall(ord(resp[4])) else: self.close() raise GeneralProxyError((1,_generalerrors[1])) boundport = struct.unpack(">H",bytes(self.__recvall(2), 'utf8'))[0] self.__proxysockname = (boundaddr,boundport) if ipaddr != None: self.__proxypeername = (socket.inet_ntoa(ipaddr),destport) else: self.__proxypeername = (destaddr,destport) | 9c2eaf1c9f74544afe20a86fa591d97eeaa8921c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/13138/9c2eaf1c9f74544afe20a86fa591d97eeaa8921c/socks.py |
raise Socks5AuthError((3,_socks5autherrors[3])) | raise Socks5AuthError((3, _socks5autherrors[3])) | def __negotiatesocks5(self,destaddr,destport): """__negotiatesocks5(self,destaddr,destport) Negotiates a connection through a SOCKS5 server. """ # First we'll send the authentication packages we support. if (self.__proxy[4]!=None) and (self.__proxy[5]!=None): # The username/password details were supplied to the # setproxy method so we support the USERNAME/PASSWORD # authentication (in addition to the standard none). self.sendall("\x05\x02\x00\x02") else: # No username/password were entered, therefore we # only support connections with no authentication. self.sendall("\x05\x01\x00") # We'll receive the server's response to determine which # method was selected chosenauth = self.__recvall(2) if chosenauth[0] != "\x05": self.close() raise GeneralProxyError((1,_generalerrors[1])) # Check the chosen authentication method if chosenauth[1] == "\x00": # No authentication is required pass elif chosenauth[1] == "\x02": # Okay, we need to perform a basic username/password # authentication. self.sendall("\x01" + chr(len(self.__proxy[4])) + self.__proxy[4] + chr(len(self.__proxy[5])) + self.__proxy[5]) authstat = self.__recvall(2) if authstat[0] != "\x01": # Bad response self.close() raise GeneralProxyError((1,_generalerrors[1])) if authstat[1] != "\x00": # Authentication failed self.close() raise Socks5AuthError((3,_socks5autherrors[3])) # Authentication succeeded else: # Reaching here is always bad self.close() if chosenauth[1] == "\xFF": raise Socks5AuthError((2,_socks5autherrors[2])) else: raise GeneralProxyError((1,_generalerrors[1])) # Now we can request the actual connection req = "\x05\x01\x00" # If the given destination address is an IP address, we'll # use the IPv4 address request even if remote resolving was specified. try: ipaddr = socket.inet_aton(destaddr) req = req + "\x01" + ipaddr except socket.error: # Well it's not an IP number, so it's probably a DNS name. if self.__proxy[3]==True: # Resolve remotely ipaddr = None req = req + "\x03" + chr(len(destaddr)) + destaddr else: # Resolve locally ipaddr = socket.inet_aton(socket.gethostbyname(destaddr)) req = req + "\x01" + ipaddr req = req + self.__decode(struct.pack(">H",destport)) self.sendall(req) # Get the response resp = self.__recvall(4) if resp[0] != "\x05": self.close() raise GeneralProxyError((1,_generalerrors[1])) elif resp[1] != "\x00": # Connection failed self.close() if ord(resp[1])<=8: raise Socks5Error((ord(resp[1]),_socks5errors[ord(resp[1])])) else: raise Socks5Error((9,_socks5errors[9])) # Get the bound address/port elif resp[3] == "\x01": boundaddr = self.__recvall(4) elif resp[3] == "\x03": resp = resp + self.recv(1) boundaddr = self.__recvall(ord(resp[4])) else: self.close() raise GeneralProxyError((1,_generalerrors[1])) boundport = struct.unpack(">H",bytes(self.__recvall(2), 'utf8'))[0] self.__proxysockname = (boundaddr,boundport) if ipaddr != None: self.__proxypeername = (socket.inet_ntoa(ipaddr),destport) else: self.__proxypeername = (destaddr,destport) | 9c2eaf1c9f74544afe20a86fa591d97eeaa8921c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/13138/9c2eaf1c9f74544afe20a86fa591d97eeaa8921c/socks.py |
raise Socks5AuthError((2,_socks5autherrors[2])) else: raise GeneralProxyError((1,_generalerrors[1])) | raise Socks5AuthError((2, _socks5autherrors[2])) else: raise GeneralProxyError((1, _generalerrors[1])) | def __negotiatesocks5(self,destaddr,destport): """__negotiatesocks5(self,destaddr,destport) Negotiates a connection through a SOCKS5 server. """ # First we'll send the authentication packages we support. if (self.__proxy[4]!=None) and (self.__proxy[5]!=None): # The username/password details were supplied to the # setproxy method so we support the USERNAME/PASSWORD # authentication (in addition to the standard none). self.sendall("\x05\x02\x00\x02") else: # No username/password were entered, therefore we # only support connections with no authentication. self.sendall("\x05\x01\x00") # We'll receive the server's response to determine which # method was selected chosenauth = self.__recvall(2) if chosenauth[0] != "\x05": self.close() raise GeneralProxyError((1,_generalerrors[1])) # Check the chosen authentication method if chosenauth[1] == "\x00": # No authentication is required pass elif chosenauth[1] == "\x02": # Okay, we need to perform a basic username/password # authentication. self.sendall("\x01" + chr(len(self.__proxy[4])) + self.__proxy[4] + chr(len(self.__proxy[5])) + self.__proxy[5]) authstat = self.__recvall(2) if authstat[0] != "\x01": # Bad response self.close() raise GeneralProxyError((1,_generalerrors[1])) if authstat[1] != "\x00": # Authentication failed self.close() raise Socks5AuthError((3,_socks5autherrors[3])) # Authentication succeeded else: # Reaching here is always bad self.close() if chosenauth[1] == "\xFF": raise Socks5AuthError((2,_socks5autherrors[2])) else: raise GeneralProxyError((1,_generalerrors[1])) # Now we can request the actual connection req = "\x05\x01\x00" # If the given destination address is an IP address, we'll # use the IPv4 address request even if remote resolving was specified. try: ipaddr = socket.inet_aton(destaddr) req = req + "\x01" + ipaddr except socket.error: # Well it's not an IP number, so it's probably a DNS name. if self.__proxy[3]==True: # Resolve remotely ipaddr = None req = req + "\x03" + chr(len(destaddr)) + destaddr else: # Resolve locally ipaddr = socket.inet_aton(socket.gethostbyname(destaddr)) req = req + "\x01" + ipaddr req = req + self.__decode(struct.pack(">H",destport)) self.sendall(req) # Get the response resp = self.__recvall(4) if resp[0] != "\x05": self.close() raise GeneralProxyError((1,_generalerrors[1])) elif resp[1] != "\x00": # Connection failed self.close() if ord(resp[1])<=8: raise Socks5Error((ord(resp[1]),_socks5errors[ord(resp[1])])) else: raise Socks5Error((9,_socks5errors[9])) # Get the bound address/port elif resp[3] == "\x01": boundaddr = self.__recvall(4) elif resp[3] == "\x03": resp = resp + self.recv(1) boundaddr = self.__recvall(ord(resp[4])) else: self.close() raise GeneralProxyError((1,_generalerrors[1])) boundport = struct.unpack(">H",bytes(self.__recvall(2), 'utf8'))[0] self.__proxysockname = (boundaddr,boundport) if ipaddr != None: self.__proxypeername = (socket.inet_ntoa(ipaddr),destport) else: self.__proxypeername = (destaddr,destport) | 9c2eaf1c9f74544afe20a86fa591d97eeaa8921c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/13138/9c2eaf1c9f74544afe20a86fa591d97eeaa8921c/socks.py |
if self.__proxy[3]==True: | if self.__proxy[3] == True: | def __negotiatesocks5(self,destaddr,destport): """__negotiatesocks5(self,destaddr,destport) Negotiates a connection through a SOCKS5 server. """ # First we'll send the authentication packages we support. if (self.__proxy[4]!=None) and (self.__proxy[5]!=None): # The username/password details were supplied to the # setproxy method so we support the USERNAME/PASSWORD # authentication (in addition to the standard none). self.sendall("\x05\x02\x00\x02") else: # No username/password were entered, therefore we # only support connections with no authentication. self.sendall("\x05\x01\x00") # We'll receive the server's response to determine which # method was selected chosenauth = self.__recvall(2) if chosenauth[0] != "\x05": self.close() raise GeneralProxyError((1,_generalerrors[1])) # Check the chosen authentication method if chosenauth[1] == "\x00": # No authentication is required pass elif chosenauth[1] == "\x02": # Okay, we need to perform a basic username/password # authentication. self.sendall("\x01" + chr(len(self.__proxy[4])) + self.__proxy[4] + chr(len(self.__proxy[5])) + self.__proxy[5]) authstat = self.__recvall(2) if authstat[0] != "\x01": # Bad response self.close() raise GeneralProxyError((1,_generalerrors[1])) if authstat[1] != "\x00": # Authentication failed self.close() raise Socks5AuthError((3,_socks5autherrors[3])) # Authentication succeeded else: # Reaching here is always bad self.close() if chosenauth[1] == "\xFF": raise Socks5AuthError((2,_socks5autherrors[2])) else: raise GeneralProxyError((1,_generalerrors[1])) # Now we can request the actual connection req = "\x05\x01\x00" # If the given destination address is an IP address, we'll # use the IPv4 address request even if remote resolving was specified. try: ipaddr = socket.inet_aton(destaddr) req = req + "\x01" + ipaddr except socket.error: # Well it's not an IP number, so it's probably a DNS name. if self.__proxy[3]==True: # Resolve remotely ipaddr = None req = req + "\x03" + chr(len(destaddr)) + destaddr else: # Resolve locally ipaddr = socket.inet_aton(socket.gethostbyname(destaddr)) req = req + "\x01" + ipaddr req = req + self.__decode(struct.pack(">H",destport)) self.sendall(req) # Get the response resp = self.__recvall(4) if resp[0] != "\x05": self.close() raise GeneralProxyError((1,_generalerrors[1])) elif resp[1] != "\x00": # Connection failed self.close() if ord(resp[1])<=8: raise Socks5Error((ord(resp[1]),_socks5errors[ord(resp[1])])) else: raise Socks5Error((9,_socks5errors[9])) # Get the bound address/port elif resp[3] == "\x01": boundaddr = self.__recvall(4) elif resp[3] == "\x03": resp = resp + self.recv(1) boundaddr = self.__recvall(ord(resp[4])) else: self.close() raise GeneralProxyError((1,_generalerrors[1])) boundport = struct.unpack(">H",bytes(self.__recvall(2), 'utf8'))[0] self.__proxysockname = (boundaddr,boundport) if ipaddr != None: self.__proxypeername = (socket.inet_ntoa(ipaddr),destport) else: self.__proxypeername = (destaddr,destport) | 9c2eaf1c9f74544afe20a86fa591d97eeaa8921c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/13138/9c2eaf1c9f74544afe20a86fa591d97eeaa8921c/socks.py |
req = req + self.__decode(struct.pack(">H",destport)) | req = req + self.__decode(struct.pack(">H", destport)) | def __negotiatesocks5(self,destaddr,destport): """__negotiatesocks5(self,destaddr,destport) Negotiates a connection through a SOCKS5 server. """ # First we'll send the authentication packages we support. if (self.__proxy[4]!=None) and (self.__proxy[5]!=None): # The username/password details were supplied to the # setproxy method so we support the USERNAME/PASSWORD # authentication (in addition to the standard none). self.sendall("\x05\x02\x00\x02") else: # No username/password were entered, therefore we # only support connections with no authentication. self.sendall("\x05\x01\x00") # We'll receive the server's response to determine which # method was selected chosenauth = self.__recvall(2) if chosenauth[0] != "\x05": self.close() raise GeneralProxyError((1,_generalerrors[1])) # Check the chosen authentication method if chosenauth[1] == "\x00": # No authentication is required pass elif chosenauth[1] == "\x02": # Okay, we need to perform a basic username/password # authentication. self.sendall("\x01" + chr(len(self.__proxy[4])) + self.__proxy[4] + chr(len(self.__proxy[5])) + self.__proxy[5]) authstat = self.__recvall(2) if authstat[0] != "\x01": # Bad response self.close() raise GeneralProxyError((1,_generalerrors[1])) if authstat[1] != "\x00": # Authentication failed self.close() raise Socks5AuthError((3,_socks5autherrors[3])) # Authentication succeeded else: # Reaching here is always bad self.close() if chosenauth[1] == "\xFF": raise Socks5AuthError((2,_socks5autherrors[2])) else: raise GeneralProxyError((1,_generalerrors[1])) # Now we can request the actual connection req = "\x05\x01\x00" # If the given destination address is an IP address, we'll # use the IPv4 address request even if remote resolving was specified. try: ipaddr = socket.inet_aton(destaddr) req = req + "\x01" + ipaddr except socket.error: # Well it's not an IP number, so it's probably a DNS name. if self.__proxy[3]==True: # Resolve remotely ipaddr = None req = req + "\x03" + chr(len(destaddr)) + destaddr else: # Resolve locally ipaddr = socket.inet_aton(socket.gethostbyname(destaddr)) req = req + "\x01" + ipaddr req = req + self.__decode(struct.pack(">H",destport)) self.sendall(req) # Get the response resp = self.__recvall(4) if resp[0] != "\x05": self.close() raise GeneralProxyError((1,_generalerrors[1])) elif resp[1] != "\x00": # Connection failed self.close() if ord(resp[1])<=8: raise Socks5Error((ord(resp[1]),_socks5errors[ord(resp[1])])) else: raise Socks5Error((9,_socks5errors[9])) # Get the bound address/port elif resp[3] == "\x01": boundaddr = self.__recvall(4) elif resp[3] == "\x03": resp = resp + self.recv(1) boundaddr = self.__recvall(ord(resp[4])) else: self.close() raise GeneralProxyError((1,_generalerrors[1])) boundport = struct.unpack(">H",bytes(self.__recvall(2), 'utf8'))[0] self.__proxysockname = (boundaddr,boundport) if ipaddr != None: self.__proxypeername = (socket.inet_ntoa(ipaddr),destport) else: self.__proxypeername = (destaddr,destport) | 9c2eaf1c9f74544afe20a86fa591d97eeaa8921c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/13138/9c2eaf1c9f74544afe20a86fa591d97eeaa8921c/socks.py |
raise GeneralProxyError((1,_generalerrors[1])) | raise GeneralProxyError((1, _generalerrors[1])) | def __negotiatesocks5(self,destaddr,destport): """__negotiatesocks5(self,destaddr,destport) Negotiates a connection through a SOCKS5 server. """ # First we'll send the authentication packages we support. if (self.__proxy[4]!=None) and (self.__proxy[5]!=None): # The username/password details were supplied to the # setproxy method so we support the USERNAME/PASSWORD # authentication (in addition to the standard none). self.sendall("\x05\x02\x00\x02") else: # No username/password were entered, therefore we # only support connections with no authentication. self.sendall("\x05\x01\x00") # We'll receive the server's response to determine which # method was selected chosenauth = self.__recvall(2) if chosenauth[0] != "\x05": self.close() raise GeneralProxyError((1,_generalerrors[1])) # Check the chosen authentication method if chosenauth[1] == "\x00": # No authentication is required pass elif chosenauth[1] == "\x02": # Okay, we need to perform a basic username/password # authentication. self.sendall("\x01" + chr(len(self.__proxy[4])) + self.__proxy[4] + chr(len(self.__proxy[5])) + self.__proxy[5]) authstat = self.__recvall(2) if authstat[0] != "\x01": # Bad response self.close() raise GeneralProxyError((1,_generalerrors[1])) if authstat[1] != "\x00": # Authentication failed self.close() raise Socks5AuthError((3,_socks5autherrors[3])) # Authentication succeeded else: # Reaching here is always bad self.close() if chosenauth[1] == "\xFF": raise Socks5AuthError((2,_socks5autherrors[2])) else: raise GeneralProxyError((1,_generalerrors[1])) # Now we can request the actual connection req = "\x05\x01\x00" # If the given destination address is an IP address, we'll # use the IPv4 address request even if remote resolving was specified. try: ipaddr = socket.inet_aton(destaddr) req = req + "\x01" + ipaddr except socket.error: # Well it's not an IP number, so it's probably a DNS name. if self.__proxy[3]==True: # Resolve remotely ipaddr = None req = req + "\x03" + chr(len(destaddr)) + destaddr else: # Resolve locally ipaddr = socket.inet_aton(socket.gethostbyname(destaddr)) req = req + "\x01" + ipaddr req = req + self.__decode(struct.pack(">H",destport)) self.sendall(req) # Get the response resp = self.__recvall(4) if resp[0] != "\x05": self.close() raise GeneralProxyError((1,_generalerrors[1])) elif resp[1] != "\x00": # Connection failed self.close() if ord(resp[1])<=8: raise Socks5Error((ord(resp[1]),_socks5errors[ord(resp[1])])) else: raise Socks5Error((9,_socks5errors[9])) # Get the bound address/port elif resp[3] == "\x01": boundaddr = self.__recvall(4) elif resp[3] == "\x03": resp = resp + self.recv(1) boundaddr = self.__recvall(ord(resp[4])) else: self.close() raise GeneralProxyError((1,_generalerrors[1])) boundport = struct.unpack(">H",bytes(self.__recvall(2), 'utf8'))[0] self.__proxysockname = (boundaddr,boundport) if ipaddr != None: self.__proxypeername = (socket.inet_ntoa(ipaddr),destport) else: self.__proxypeername = (destaddr,destport) | 9c2eaf1c9f74544afe20a86fa591d97eeaa8921c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/13138/9c2eaf1c9f74544afe20a86fa591d97eeaa8921c/socks.py |
if ord(resp[1])<=8: raise Socks5Error((ord(resp[1]),_socks5errors[ord(resp[1])])) else: raise Socks5Error((9,_socks5errors[9])) | if ord(resp[1]) <= 8: raise Socks5Error((ord(resp[1]), _socks5errors[ord(resp[1])])) else: raise Socks5Error((9, _socks5errors[9])) | def __negotiatesocks5(self,destaddr,destport): """__negotiatesocks5(self,destaddr,destport) Negotiates a connection through a SOCKS5 server. """ # First we'll send the authentication packages we support. if (self.__proxy[4]!=None) and (self.__proxy[5]!=None): # The username/password details were supplied to the # setproxy method so we support the USERNAME/PASSWORD # authentication (in addition to the standard none). self.sendall("\x05\x02\x00\x02") else: # No username/password were entered, therefore we # only support connections with no authentication. self.sendall("\x05\x01\x00") # We'll receive the server's response to determine which # method was selected chosenauth = self.__recvall(2) if chosenauth[0] != "\x05": self.close() raise GeneralProxyError((1,_generalerrors[1])) # Check the chosen authentication method if chosenauth[1] == "\x00": # No authentication is required pass elif chosenauth[1] == "\x02": # Okay, we need to perform a basic username/password # authentication. self.sendall("\x01" + chr(len(self.__proxy[4])) + self.__proxy[4] + chr(len(self.__proxy[5])) + self.__proxy[5]) authstat = self.__recvall(2) if authstat[0] != "\x01": # Bad response self.close() raise GeneralProxyError((1,_generalerrors[1])) if authstat[1] != "\x00": # Authentication failed self.close() raise Socks5AuthError((3,_socks5autherrors[3])) # Authentication succeeded else: # Reaching here is always bad self.close() if chosenauth[1] == "\xFF": raise Socks5AuthError((2,_socks5autherrors[2])) else: raise GeneralProxyError((1,_generalerrors[1])) # Now we can request the actual connection req = "\x05\x01\x00" # If the given destination address is an IP address, we'll # use the IPv4 address request even if remote resolving was specified. try: ipaddr = socket.inet_aton(destaddr) req = req + "\x01" + ipaddr except socket.error: # Well it's not an IP number, so it's probably a DNS name. if self.__proxy[3]==True: # Resolve remotely ipaddr = None req = req + "\x03" + chr(len(destaddr)) + destaddr else: # Resolve locally ipaddr = socket.inet_aton(socket.gethostbyname(destaddr)) req = req + "\x01" + ipaddr req = req + self.__decode(struct.pack(">H",destport)) self.sendall(req) # Get the response resp = self.__recvall(4) if resp[0] != "\x05": self.close() raise GeneralProxyError((1,_generalerrors[1])) elif resp[1] != "\x00": # Connection failed self.close() if ord(resp[1])<=8: raise Socks5Error((ord(resp[1]),_socks5errors[ord(resp[1])])) else: raise Socks5Error((9,_socks5errors[9])) # Get the bound address/port elif resp[3] == "\x01": boundaddr = self.__recvall(4) elif resp[3] == "\x03": resp = resp + self.recv(1) boundaddr = self.__recvall(ord(resp[4])) else: self.close() raise GeneralProxyError((1,_generalerrors[1])) boundport = struct.unpack(">H",bytes(self.__recvall(2), 'utf8'))[0] self.__proxysockname = (boundaddr,boundport) if ipaddr != None: self.__proxypeername = (socket.inet_ntoa(ipaddr),destport) else: self.__proxypeername = (destaddr,destport) | 9c2eaf1c9f74544afe20a86fa591d97eeaa8921c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/13138/9c2eaf1c9f74544afe20a86fa591d97eeaa8921c/socks.py |
raise GeneralProxyError((1,_generalerrors[1])) boundport = struct.unpack(">H",bytes(self.__recvall(2), 'utf8'))[0] self.__proxysockname = (boundaddr,boundport) | raise GeneralProxyError((1, _generalerrors[1])) boundport = struct.unpack(">H", bytes(self.__recvall(2), 'utf8'))[0] self.__proxysockname = boundaddr, boundport | def __negotiatesocks5(self,destaddr,destport): """__negotiatesocks5(self,destaddr,destport) Negotiates a connection through a SOCKS5 server. """ # First we'll send the authentication packages we support. if (self.__proxy[4]!=None) and (self.__proxy[5]!=None): # The username/password details were supplied to the # setproxy method so we support the USERNAME/PASSWORD # authentication (in addition to the standard none). self.sendall("\x05\x02\x00\x02") else: # No username/password were entered, therefore we # only support connections with no authentication. self.sendall("\x05\x01\x00") # We'll receive the server's response to determine which # method was selected chosenauth = self.__recvall(2) if chosenauth[0] != "\x05": self.close() raise GeneralProxyError((1,_generalerrors[1])) # Check the chosen authentication method if chosenauth[1] == "\x00": # No authentication is required pass elif chosenauth[1] == "\x02": # Okay, we need to perform a basic username/password # authentication. self.sendall("\x01" + chr(len(self.__proxy[4])) + self.__proxy[4] + chr(len(self.__proxy[5])) + self.__proxy[5]) authstat = self.__recvall(2) if authstat[0] != "\x01": # Bad response self.close() raise GeneralProxyError((1,_generalerrors[1])) if authstat[1] != "\x00": # Authentication failed self.close() raise Socks5AuthError((3,_socks5autherrors[3])) # Authentication succeeded else: # Reaching here is always bad self.close() if chosenauth[1] == "\xFF": raise Socks5AuthError((2,_socks5autherrors[2])) else: raise GeneralProxyError((1,_generalerrors[1])) # Now we can request the actual connection req = "\x05\x01\x00" # If the given destination address is an IP address, we'll # use the IPv4 address request even if remote resolving was specified. try: ipaddr = socket.inet_aton(destaddr) req = req + "\x01" + ipaddr except socket.error: # Well it's not an IP number, so it's probably a DNS name. if self.__proxy[3]==True: # Resolve remotely ipaddr = None req = req + "\x03" + chr(len(destaddr)) + destaddr else: # Resolve locally ipaddr = socket.inet_aton(socket.gethostbyname(destaddr)) req = req + "\x01" + ipaddr req = req + self.__decode(struct.pack(">H",destport)) self.sendall(req) # Get the response resp = self.__recvall(4) if resp[0] != "\x05": self.close() raise GeneralProxyError((1,_generalerrors[1])) elif resp[1] != "\x00": # Connection failed self.close() if ord(resp[1])<=8: raise Socks5Error((ord(resp[1]),_socks5errors[ord(resp[1])])) else: raise Socks5Error((9,_socks5errors[9])) # Get the bound address/port elif resp[3] == "\x01": boundaddr = self.__recvall(4) elif resp[3] == "\x03": resp = resp + self.recv(1) boundaddr = self.__recvall(ord(resp[4])) else: self.close() raise GeneralProxyError((1,_generalerrors[1])) boundport = struct.unpack(">H",bytes(self.__recvall(2), 'utf8'))[0] self.__proxysockname = (boundaddr,boundport) if ipaddr != None: self.__proxypeername = (socket.inet_ntoa(ipaddr),destport) else: self.__proxypeername = (destaddr,destport) | 9c2eaf1c9f74544afe20a86fa591d97eeaa8921c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/13138/9c2eaf1c9f74544afe20a86fa591d97eeaa8921c/socks.py |
self.__proxypeername = (socket.inet_ntoa(ipaddr),destport) else: self.__proxypeername = (destaddr,destport) | self.__proxypeername = (socket.inet_ntoa(ipaddr), destport) else: self.__proxypeername = (destaddr, destport) | def __negotiatesocks5(self,destaddr,destport): """__negotiatesocks5(self,destaddr,destport) Negotiates a connection through a SOCKS5 server. """ # First we'll send the authentication packages we support. if (self.__proxy[4]!=None) and (self.__proxy[5]!=None): # The username/password details were supplied to the # setproxy method so we support the USERNAME/PASSWORD # authentication (in addition to the standard none). self.sendall("\x05\x02\x00\x02") else: # No username/password were entered, therefore we # only support connections with no authentication. self.sendall("\x05\x01\x00") # We'll receive the server's response to determine which # method was selected chosenauth = self.__recvall(2) if chosenauth[0] != "\x05": self.close() raise GeneralProxyError((1,_generalerrors[1])) # Check the chosen authentication method if chosenauth[1] == "\x00": # No authentication is required pass elif chosenauth[1] == "\x02": # Okay, we need to perform a basic username/password # authentication. self.sendall("\x01" + chr(len(self.__proxy[4])) + self.__proxy[4] + chr(len(self.__proxy[5])) + self.__proxy[5]) authstat = self.__recvall(2) if authstat[0] != "\x01": # Bad response self.close() raise GeneralProxyError((1,_generalerrors[1])) if authstat[1] != "\x00": # Authentication failed self.close() raise Socks5AuthError((3,_socks5autherrors[3])) # Authentication succeeded else: # Reaching here is always bad self.close() if chosenauth[1] == "\xFF": raise Socks5AuthError((2,_socks5autherrors[2])) else: raise GeneralProxyError((1,_generalerrors[1])) # Now we can request the actual connection req = "\x05\x01\x00" # If the given destination address is an IP address, we'll # use the IPv4 address request even if remote resolving was specified. try: ipaddr = socket.inet_aton(destaddr) req = req + "\x01" + ipaddr except socket.error: # Well it's not an IP number, so it's probably a DNS name. if self.__proxy[3]==True: # Resolve remotely ipaddr = None req = req + "\x03" + chr(len(destaddr)) + destaddr else: # Resolve locally ipaddr = socket.inet_aton(socket.gethostbyname(destaddr)) req = req + "\x01" + ipaddr req = req + self.__decode(struct.pack(">H",destport)) self.sendall(req) # Get the response resp = self.__recvall(4) if resp[0] != "\x05": self.close() raise GeneralProxyError((1,_generalerrors[1])) elif resp[1] != "\x00": # Connection failed self.close() if ord(resp[1])<=8: raise Socks5Error((ord(resp[1]),_socks5errors[ord(resp[1])])) else: raise Socks5Error((9,_socks5errors[9])) # Get the bound address/port elif resp[3] == "\x01": boundaddr = self.__recvall(4) elif resp[3] == "\x03": resp = resp + self.recv(1) boundaddr = self.__recvall(ord(resp[4])) else: self.close() raise GeneralProxyError((1,_generalerrors[1])) boundport = struct.unpack(">H",bytes(self.__recvall(2), 'utf8'))[0] self.__proxysockname = (boundaddr,boundport) if ipaddr != None: self.__proxypeername = (socket.inet_ntoa(ipaddr),destport) else: self.__proxypeername = (destaddr,destport) | 9c2eaf1c9f74544afe20a86fa591d97eeaa8921c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/13138/9c2eaf1c9f74544afe20a86fa591d97eeaa8921c/socks.py |
return _orgsocket.getpeername(self) | return socket.socket.getpeername(self) | def getproxypeername(self): """getproxypeername() -> address info Returns the IP and port number of the proxy. """ return _orgsocket.getpeername(self) | 9c2eaf1c9f74544afe20a86fa591d97eeaa8921c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/13138/9c2eaf1c9f74544afe20a86fa591d97eeaa8921c/socks.py |
def __negotiatesocks4(self,destaddr,destport): | def __negotiatesocks4(self, destaddr, destport): | def __negotiatesocks4(self,destaddr,destport): """__negotiatesocks4(self,destaddr,destport) Negotiates a connection through a SOCKS4 server. """ # Check if the destination address provided is an IP address rmtrslv = False try: ipaddr = socket.inet_aton(destaddr) except socket.error: # It's a DNS name. Check where it should be resolved. if self.__proxy[3]==True: ipaddr = "\x00\x00\x00\x01" rmtrslv = True else: ipaddr = socket.inet_aton(socket.gethostbyname(destaddr)) # Construct the request packet req = "\x04\x01" + self.__decode(struct.pack(">H",destport)) + ipaddr # The username parameter is considered userid for SOCKS4 if self.__proxy[4] != None: req = req + self.__proxy[4] req = req + "\x00" # DNS name if remote resolving is required # NOTE: This is actually an extension to the SOCKS4 protocol # called SOCKS4A and may not be supported in all cases. if rmtrslv==True: req = req + destaddr + "\x00" self.sendall(req) # Get the response from the server resp = self.__recvall(8) if resp[0] != "\x00": # Bad data self.close() raise GeneralProxyError((1,_generalerrors[1])) if resp[1] != "\x5A": # Server returned an error self.close() if ord(resp[1]) in (91,92,93): self.close() raise Socks4Error((ord(resp[1]),_socks4errors[ord(resp[1])-90])) else: raise Socks4Error((94,_socks4errors[4])) # Get the bound address/port self.__proxysockname = (socket.inet_ntoa(resp[4:]),struct.unpack(">H",bytes(resp[2:4],'utf8'))[0]) if rmtrslv != None: self.__proxypeername = (socket.inet_ntoa(ipaddr),destport) else: self.__proxypeername = (destaddr,destport) | 9c2eaf1c9f74544afe20a86fa591d97eeaa8921c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/13138/9c2eaf1c9f74544afe20a86fa591d97eeaa8921c/socks.py |
if self.__proxy[3]==True: | if self.__proxy[3] == True: | def __negotiatesocks4(self,destaddr,destport): """__negotiatesocks4(self,destaddr,destport) Negotiates a connection through a SOCKS4 server. """ # Check if the destination address provided is an IP address rmtrslv = False try: ipaddr = socket.inet_aton(destaddr) except socket.error: # It's a DNS name. Check where it should be resolved. if self.__proxy[3]==True: ipaddr = "\x00\x00\x00\x01" rmtrslv = True else: ipaddr = socket.inet_aton(socket.gethostbyname(destaddr)) # Construct the request packet req = "\x04\x01" + self.__decode(struct.pack(">H",destport)) + ipaddr # The username parameter is considered userid for SOCKS4 if self.__proxy[4] != None: req = req + self.__proxy[4] req = req + "\x00" # DNS name if remote resolving is required # NOTE: This is actually an extension to the SOCKS4 protocol # called SOCKS4A and may not be supported in all cases. if rmtrslv==True: req = req + destaddr + "\x00" self.sendall(req) # Get the response from the server resp = self.__recvall(8) if resp[0] != "\x00": # Bad data self.close() raise GeneralProxyError((1,_generalerrors[1])) if resp[1] != "\x5A": # Server returned an error self.close() if ord(resp[1]) in (91,92,93): self.close() raise Socks4Error((ord(resp[1]),_socks4errors[ord(resp[1])-90])) else: raise Socks4Error((94,_socks4errors[4])) # Get the bound address/port self.__proxysockname = (socket.inet_ntoa(resp[4:]),struct.unpack(">H",bytes(resp[2:4],'utf8'))[0]) if rmtrslv != None: self.__proxypeername = (socket.inet_ntoa(ipaddr),destport) else: self.__proxypeername = (destaddr,destport) | 9c2eaf1c9f74544afe20a86fa591d97eeaa8921c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/13138/9c2eaf1c9f74544afe20a86fa591d97eeaa8921c/socks.py |
req = "\x04\x01" + self.__decode(struct.pack(">H",destport)) + ipaddr | req = "\x04\x01" + self.__decode(struct.pack(">H", destport)) + ipaddr | def __negotiatesocks4(self,destaddr,destport): """__negotiatesocks4(self,destaddr,destport) Negotiates a connection through a SOCKS4 server. """ # Check if the destination address provided is an IP address rmtrslv = False try: ipaddr = socket.inet_aton(destaddr) except socket.error: # It's a DNS name. Check where it should be resolved. if self.__proxy[3]==True: ipaddr = "\x00\x00\x00\x01" rmtrslv = True else: ipaddr = socket.inet_aton(socket.gethostbyname(destaddr)) # Construct the request packet req = "\x04\x01" + self.__decode(struct.pack(">H",destport)) + ipaddr # The username parameter is considered userid for SOCKS4 if self.__proxy[4] != None: req = req + self.__proxy[4] req = req + "\x00" # DNS name if remote resolving is required # NOTE: This is actually an extension to the SOCKS4 protocol # called SOCKS4A and may not be supported in all cases. if rmtrslv==True: req = req + destaddr + "\x00" self.sendall(req) # Get the response from the server resp = self.__recvall(8) if resp[0] != "\x00": # Bad data self.close() raise GeneralProxyError((1,_generalerrors[1])) if resp[1] != "\x5A": # Server returned an error self.close() if ord(resp[1]) in (91,92,93): self.close() raise Socks4Error((ord(resp[1]),_socks4errors[ord(resp[1])-90])) else: raise Socks4Error((94,_socks4errors[4])) # Get the bound address/port self.__proxysockname = (socket.inet_ntoa(resp[4:]),struct.unpack(">H",bytes(resp[2:4],'utf8'))[0]) if rmtrslv != None: self.__proxypeername = (socket.inet_ntoa(ipaddr),destport) else: self.__proxypeername = (destaddr,destport) | 9c2eaf1c9f74544afe20a86fa591d97eeaa8921c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/13138/9c2eaf1c9f74544afe20a86fa591d97eeaa8921c/socks.py |
raise GeneralProxyError((1,_generalerrors[1])) | raise GeneralProxyError((1, _generalerrors[1])) | def __negotiatesocks4(self,destaddr,destport): """__negotiatesocks4(self,destaddr,destport) Negotiates a connection through a SOCKS4 server. """ # Check if the destination address provided is an IP address rmtrslv = False try: ipaddr = socket.inet_aton(destaddr) except socket.error: # It's a DNS name. Check where it should be resolved. if self.__proxy[3]==True: ipaddr = "\x00\x00\x00\x01" rmtrslv = True else: ipaddr = socket.inet_aton(socket.gethostbyname(destaddr)) # Construct the request packet req = "\x04\x01" + self.__decode(struct.pack(">H",destport)) + ipaddr # The username parameter is considered userid for SOCKS4 if self.__proxy[4] != None: req = req + self.__proxy[4] req = req + "\x00" # DNS name if remote resolving is required # NOTE: This is actually an extension to the SOCKS4 protocol # called SOCKS4A and may not be supported in all cases. if rmtrslv==True: req = req + destaddr + "\x00" self.sendall(req) # Get the response from the server resp = self.__recvall(8) if resp[0] != "\x00": # Bad data self.close() raise GeneralProxyError((1,_generalerrors[1])) if resp[1] != "\x5A": # Server returned an error self.close() if ord(resp[1]) in (91,92,93): self.close() raise Socks4Error((ord(resp[1]),_socks4errors[ord(resp[1])-90])) else: raise Socks4Error((94,_socks4errors[4])) # Get the bound address/port self.__proxysockname = (socket.inet_ntoa(resp[4:]),struct.unpack(">H",bytes(resp[2:4],'utf8'))[0]) if rmtrslv != None: self.__proxypeername = (socket.inet_ntoa(ipaddr),destport) else: self.__proxypeername = (destaddr,destport) | 9c2eaf1c9f74544afe20a86fa591d97eeaa8921c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/13138/9c2eaf1c9f74544afe20a86fa591d97eeaa8921c/socks.py |
raise Socks4Error((ord(resp[1]),_socks4errors[ord(resp[1])-90])) | raise Socks4Error((ord(resp[1]), _socks4errors[ord(resp[1])-90])) | def __negotiatesocks4(self,destaddr,destport): """__negotiatesocks4(self,destaddr,destport) Negotiates a connection through a SOCKS4 server. """ # Check if the destination address provided is an IP address rmtrslv = False try: ipaddr = socket.inet_aton(destaddr) except socket.error: # It's a DNS name. Check where it should be resolved. if self.__proxy[3]==True: ipaddr = "\x00\x00\x00\x01" rmtrslv = True else: ipaddr = socket.inet_aton(socket.gethostbyname(destaddr)) # Construct the request packet req = "\x04\x01" + self.__decode(struct.pack(">H",destport)) + ipaddr # The username parameter is considered userid for SOCKS4 if self.__proxy[4] != None: req = req + self.__proxy[4] req = req + "\x00" # DNS name if remote resolving is required # NOTE: This is actually an extension to the SOCKS4 protocol # called SOCKS4A and may not be supported in all cases. if rmtrslv==True: req = req + destaddr + "\x00" self.sendall(req) # Get the response from the server resp = self.__recvall(8) if resp[0] != "\x00": # Bad data self.close() raise GeneralProxyError((1,_generalerrors[1])) if resp[1] != "\x5A": # Server returned an error self.close() if ord(resp[1]) in (91,92,93): self.close() raise Socks4Error((ord(resp[1]),_socks4errors[ord(resp[1])-90])) else: raise Socks4Error((94,_socks4errors[4])) # Get the bound address/port self.__proxysockname = (socket.inet_ntoa(resp[4:]),struct.unpack(">H",bytes(resp[2:4],'utf8'))[0]) if rmtrslv != None: self.__proxypeername = (socket.inet_ntoa(ipaddr),destport) else: self.__proxypeername = (destaddr,destport) | 9c2eaf1c9f74544afe20a86fa591d97eeaa8921c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/13138/9c2eaf1c9f74544afe20a86fa591d97eeaa8921c/socks.py |
self.__proxypeername = (destaddr,destport) def __negotiatehttp(self,destaddr,destport): | self.__proxypeername = (destaddr, destport) def __negotiatehttp(self, destaddr, destport): | def __negotiatesocks4(self,destaddr,destport): """__negotiatesocks4(self,destaddr,destport) Negotiates a connection through a SOCKS4 server. """ # Check if the destination address provided is an IP address rmtrslv = False try: ipaddr = socket.inet_aton(destaddr) except socket.error: # It's a DNS name. Check where it should be resolved. if self.__proxy[3]==True: ipaddr = "\x00\x00\x00\x01" rmtrslv = True else: ipaddr = socket.inet_aton(socket.gethostbyname(destaddr)) # Construct the request packet req = "\x04\x01" + self.__decode(struct.pack(">H",destport)) + ipaddr # The username parameter is considered userid for SOCKS4 if self.__proxy[4] != None: req = req + self.__proxy[4] req = req + "\x00" # DNS name if remote resolving is required # NOTE: This is actually an extension to the SOCKS4 protocol # called SOCKS4A and may not be supported in all cases. if rmtrslv==True: req = req + destaddr + "\x00" self.sendall(req) # Get the response from the server resp = self.__recvall(8) if resp[0] != "\x00": # Bad data self.close() raise GeneralProxyError((1,_generalerrors[1])) if resp[1] != "\x5A": # Server returned an error self.close() if ord(resp[1]) in (91,92,93): self.close() raise Socks4Error((ord(resp[1]),_socks4errors[ord(resp[1])-90])) else: raise Socks4Error((94,_socks4errors[4])) # Get the bound address/port self.__proxysockname = (socket.inet_ntoa(resp[4:]),struct.unpack(">H",bytes(resp[2:4],'utf8'))[0]) if rmtrslv != None: self.__proxypeername = (socket.inet_ntoa(ipaddr),destport) else: self.__proxypeername = (destaddr,destport) | 9c2eaf1c9f74544afe20a86fa591d97eeaa8921c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/13138/9c2eaf1c9f74544afe20a86fa591d97eeaa8921c/socks.py |
self.sendall("CONNECT " + addr + ":" + str(destport) + " HTTP/1.1\r\n" + "Host: " + destaddr + "\r\n\r\n") | self.sendall(("CONNECT %s:%s HTTP/1.1\r\n" "Host: %s\r\n\r\n") % (addr, destport, destaddr)) | def __negotiatehttp(self,destaddr,destport): """__negotiatehttp(self,destaddr,destport) Negotiates a connection through an HTTP server. """ # If we need to resolve locally, we do this now if self.__proxy[3] == False: addr = socket.gethostbyname(destaddr) else: addr = destaddr self.sendall("CONNECT " + addr + ":" + str(destport) + " HTTP/1.1\r\n" + "Host: " + destaddr + "\r\n\r\n") # We read the response until we get the string "\r\n\r\n" resp = self.recv(1) while resp.find("\r\n\r\n")==-1: resp = resp + self.recv(1) # We just need the first line to check if the connection # was successful statusline = resp.splitlines()[0].split(" ",2) if statusline[0] not in ("HTTP/1.0","HTTP/1.1"): self.close() raise GeneralProxyError((1,_generalerrors[1])) try: statuscode = int(statusline[1]) except ValueError: self.close() raise GeneralProxyError((1,_generalerrors[1])) if statuscode != 200: self.close() raise HTTPError((statuscode,statusline[2])) self.__proxysockname = ("0.0.0.0",0) self.__proxypeername = (addr,destport) | 9c2eaf1c9f74544afe20a86fa591d97eeaa8921c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/13138/9c2eaf1c9f74544afe20a86fa591d97eeaa8921c/socks.py |
while resp.find("\r\n\r\n")==-1: | while resp.find("\r\n\r\n") == -1: | def __negotiatehttp(self,destaddr,destport): """__negotiatehttp(self,destaddr,destport) Negotiates a connection through an HTTP server. """ # If we need to resolve locally, we do this now if self.__proxy[3] == False: addr = socket.gethostbyname(destaddr) else: addr = destaddr self.sendall("CONNECT " + addr + ":" + str(destport) + " HTTP/1.1\r\n" + "Host: " + destaddr + "\r\n\r\n") # We read the response until we get the string "\r\n\r\n" resp = self.recv(1) while resp.find("\r\n\r\n")==-1: resp = resp + self.recv(1) # We just need the first line to check if the connection # was successful statusline = resp.splitlines()[0].split(" ",2) if statusline[0] not in ("HTTP/1.0","HTTP/1.1"): self.close() raise GeneralProxyError((1,_generalerrors[1])) try: statuscode = int(statusline[1]) except ValueError: self.close() raise GeneralProxyError((1,_generalerrors[1])) if statuscode != 200: self.close() raise HTTPError((statuscode,statusline[2])) self.__proxysockname = ("0.0.0.0",0) self.__proxypeername = (addr,destport) | 9c2eaf1c9f74544afe20a86fa591d97eeaa8921c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/13138/9c2eaf1c9f74544afe20a86fa591d97eeaa8921c/socks.py |
statusline = resp.splitlines()[0].split(" ",2) if statusline[0] not in ("HTTP/1.0","HTTP/1.1"): self.close() raise GeneralProxyError((1,_generalerrors[1])) | statusline = resp.splitlines()[0].split(" ", 2) if statusline[0] not in ("HTTP/1.0", "HTTP/1.1"): self.close() raise GeneralProxyError((1, _generalerrors[1])) | def __negotiatehttp(self,destaddr,destport): """__negotiatehttp(self,destaddr,destport) Negotiates a connection through an HTTP server. """ # If we need to resolve locally, we do this now if self.__proxy[3] == False: addr = socket.gethostbyname(destaddr) else: addr = destaddr self.sendall("CONNECT " + addr + ":" + str(destport) + " HTTP/1.1\r\n" + "Host: " + destaddr + "\r\n\r\n") # We read the response until we get the string "\r\n\r\n" resp = self.recv(1) while resp.find("\r\n\r\n")==-1: resp = resp + self.recv(1) # We just need the first line to check if the connection # was successful statusline = resp.splitlines()[0].split(" ",2) if statusline[0] not in ("HTTP/1.0","HTTP/1.1"): self.close() raise GeneralProxyError((1,_generalerrors[1])) try: statuscode = int(statusline[1]) except ValueError: self.close() raise GeneralProxyError((1,_generalerrors[1])) if statuscode != 200: self.close() raise HTTPError((statuscode,statusline[2])) self.__proxysockname = ("0.0.0.0",0) self.__proxypeername = (addr,destport) | 9c2eaf1c9f74544afe20a86fa591d97eeaa8921c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/13138/9c2eaf1c9f74544afe20a86fa591d97eeaa8921c/socks.py |
raise GeneralProxyError((1,_generalerrors[1])) | raise GeneralProxyError((1, _generalerrors[1])) | def __negotiatehttp(self,destaddr,destport): """__negotiatehttp(self,destaddr,destport) Negotiates a connection through an HTTP server. """ # If we need to resolve locally, we do this now if self.__proxy[3] == False: addr = socket.gethostbyname(destaddr) else: addr = destaddr self.sendall("CONNECT " + addr + ":" + str(destport) + " HTTP/1.1\r\n" + "Host: " + destaddr + "\r\n\r\n") # We read the response until we get the string "\r\n\r\n" resp = self.recv(1) while resp.find("\r\n\r\n")==-1: resp = resp + self.recv(1) # We just need the first line to check if the connection # was successful statusline = resp.splitlines()[0].split(" ",2) if statusline[0] not in ("HTTP/1.0","HTTP/1.1"): self.close() raise GeneralProxyError((1,_generalerrors[1])) try: statuscode = int(statusline[1]) except ValueError: self.close() raise GeneralProxyError((1,_generalerrors[1])) if statuscode != 200: self.close() raise HTTPError((statuscode,statusline[2])) self.__proxysockname = ("0.0.0.0",0) self.__proxypeername = (addr,destport) | 9c2eaf1c9f74544afe20a86fa591d97eeaa8921c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/13138/9c2eaf1c9f74544afe20a86fa591d97eeaa8921c/socks.py |
raise HTTPError((statuscode,statusline[2])) self.__proxysockname = ("0.0.0.0",0) self.__proxypeername = (addr,destport) def connect(self,destpair): | raise HTTPError((statuscode, statusline[2])) self.__proxysockname = ("0.0.0.0", 0) self.__proxypeername = (addr, destport) def connect(self, destpair): | def __negotiatehttp(self,destaddr,destport): """__negotiatehttp(self,destaddr,destport) Negotiates a connection through an HTTP server. """ # If we need to resolve locally, we do this now if self.__proxy[3] == False: addr = socket.gethostbyname(destaddr) else: addr = destaddr self.sendall("CONNECT " + addr + ":" + str(destport) + " HTTP/1.1\r\n" + "Host: " + destaddr + "\r\n\r\n") # We read the response until we get the string "\r\n\r\n" resp = self.recv(1) while resp.find("\r\n\r\n")==-1: resp = resp + self.recv(1) # We just need the first line to check if the connection # was successful statusline = resp.splitlines()[0].split(" ",2) if statusline[0] not in ("HTTP/1.0","HTTP/1.1"): self.close() raise GeneralProxyError((1,_generalerrors[1])) try: statuscode = int(statusline[1]) except ValueError: self.close() raise GeneralProxyError((1,_generalerrors[1])) if statuscode != 200: self.close() raise HTTPError((statuscode,statusline[2])) self.__proxysockname = ("0.0.0.0",0) self.__proxypeername = (addr,destport) | 9c2eaf1c9f74544afe20a86fa591d97eeaa8921c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/13138/9c2eaf1c9f74544afe20a86fa591d97eeaa8921c/socks.py |
start1 = [1, 2*s+3, 2*s+1, size/2-1-3*s, size/2-1, size/2+1] start2 = [1, 2*s-1, 2*s+2, size/2-1-4*s, size/2-1-2*s, size/2-1-s, size/2+1] | start1 = [1, 2*s+3, 2*s+1, size/2-1-3*s, size/2-1, size/2] start2 = [1, 2*s-1, 2*s+2, size/2-1-4*s, size/2-1-2*s, size/2-1-s, size/2] | def slider3_sat(out_type, size, offset): s = size/20 start1 = [1, 2*s+3, 2*s+1, size/2-1-3*s, size/2-1, size/2+1] start2 = [1, 2*s-1, 2*s+2, size/2-1-4*s, size/2-1-2*s, size/2-1-s, size/2+1] ''' print >> sys.stderr, start1 print >> sys.stderr, start2 ''' print "p bdd %d %d" % (size+offset,size+2*offset) print "; automatically generated SAT slider3 with size=%d " % size print "; Disclaimer: no formal analysis was done to verify SAT and UNSAT" #first function print "#define add_state1(1, 2, 3, 5, 4, 6)" print "#equ(xor(1, and(-3, 5), nand(6, 4)), ite(2, or(5, -6), -5)))" for i in range(0, size/2+offset): sys.stdout.write("add_state1") print tuple(start1) for item in range(len(start1)): start1[item] += 1 #second and third function print("#define add_state2(1, 2, 3, 4, 5, 6)") print("#xor(-1, xor(3, and(-4, 5), 4), equ(6, 2))") print("#define add_state3(1, 2, 3, 4, 5, 6)") print("#xor(-1, xor(3, and(-4, 5), 4), equ(6, 2))") for i in range(0, size-size/2+offset): test = (i%2)+2 sys.stdout.write("add_state%d" % test) print tuple(start2[0:5]+start2[6:]) for item in range(len(start2)): start2[item] += 1 | 09b30454c3228247ee87addfc9ee7951b800aa50 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/786/09b30454c3228247ee87addfc9ee7951b800aa50/slider3_base.py |
print(" | print(" | def slider3_sat(out_type, size, offset): s = size/20 start1 = [1, 2*s+3, 2*s+1, size/2-1-3*s, size/2-1, size/2+1] start2 = [1, 2*s-1, 2*s+2, size/2-1-4*s, size/2-1-2*s, size/2-1-s, size/2+1] ''' print >> sys.stderr, start1 print >> sys.stderr, start2 ''' print "p bdd %d %d" % (size+offset,size+2*offset) print "; automatically generated SAT slider3 with size=%d " % size print "; Disclaimer: no formal analysis was done to verify SAT and UNSAT" #first function print "#define add_state1(1, 2, 3, 5, 4, 6)" print "#equ(xor(1, and(-3, 5), nand(6, 4)), ite(2, or(5, -6), -5)))" for i in range(0, size/2+offset): sys.stdout.write("add_state1") print tuple(start1) for item in range(len(start1)): start1[item] += 1 #second and third function print("#define add_state2(1, 2, 3, 4, 5, 6)") print("#xor(-1, xor(3, and(-4, 5), 4), equ(6, 2))") print("#define add_state3(1, 2, 3, 4, 5, 6)") print("#xor(-1, xor(3, and(-4, 5), 4), equ(6, 2))") for i in range(0, size-size/2+offset): test = (i%2)+2 sys.stdout.write("add_state%d" % test) print tuple(start2[0:5]+start2[6:]) for item in range(len(start2)): start2[item] += 1 | 09b30454c3228247ee87addfc9ee7951b800aa50 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/786/09b30454c3228247ee87addfc9ee7951b800aa50/slider3_base.py |
self.materials = materials if materials != None else bpy.data.textures | self.materials = materials if materials != None else bpy.data.materials | def __init__(self, target_file, target_dir, materials = None, textures = None): self.target_file = target_file self.target_dir = target_dir self.exported_materials = [] self.exported_textures = [] self.materials = materials if materials != None else bpy.data.textures self.textures = textures if textures != None else bpy.data.textures | bf21300eb82d9586a816ad1d9b511ee0792271a6 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7410/bf21300eb82d9586a816ad1d9b511ee0792271a6/adjustments.py |
raise Exception('Failed to find material "%s"' % name) | raise Exception('Failed to find material "%s" in "%s"' % (name, str(self.materials))) | def findMaterial(self, name): if name in self.materials: return self.materials[name] else: raise Exception('Failed to find material "%s"' % name) | bf21300eb82d9586a816ad1d9b511ee0792271a6 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7410/bf21300eb82d9586a816ad1d9b511ee0792271a6/adjustments.py |
('composite', 'Compound material', 'Allows creating mixtures of different materials') | ('composite', 'Composite material', 'Allows creating mixtures of different materials') | def dict_merge(*args): vis = {} for vis_dict in args: vis.update(deepcopy(vis_dict)) return vis | 37ed4f400d00e991f17ccf86724305b9fa2ca416 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7410/37ed4f400d00e991f17ccf86724305b9fa2ca416/material.py |
filename = bpy.props.StringProperty(name='Target filename') | filename = bpy.props.StringProperty(name='Target filename', subtype = 'FILE_PATH') | def execute(self, context): pv = [ 'bpy.context.material.mitsuba_material.%s'%v['attr'] for v in bpy.types.mitsuba_material.get_exportable_properties() ] | ebe9ca5abc14ee8e2abf2e23af158b4204b87802 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7410/ebe9ca5abc14ee8e2abf2e23af158b4204b87802/__init__.py |
menu_func = lambda self, context: self.layout.operator("export.mitsuba", text="Export Mitsuba scene...") | def menu_func(self, context): default_path = os.path.splitext(os.path.basename(bpy.data.filepath))[0] + ".xml" self.layout.operator("export.mitsuba", text="Export Mitsuba scene...").filename = default_path | def execute(self, context): try: if self.properties.scene == '': scene = context.scene else: scene = bpy.data.scenes[self.properties.scene] | ebe9ca5abc14ee8e2abf2e23af158b4204b87802 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7410/ebe9ca5abc14ee8e2abf2e23af158b4204b87802/__init__.py |
self.out.write('\n\t\t<luminaire id="%s-light" type="area">\n' % name) | self.out.write('\n\t\t<luminaire id="%s-arealight" type="area">\n' % name) | def exportLamp(self, lamp, idx): ltype = lamp.data.mitsuba_lamp.type name = translate_id(lamp.data.name) if ltype == 'POINT': self.out.write('\t<luminaire id="%s-light" type="point">\n' % name) mult = lamp.data.mitsuba_lamp.intensity self.exportWorldtrafo(lamp.matrix_world) self.out.write('\t\t<rgb name="intensity" value="%f %f %f"/>\n' % (lamp.data.color.r*mult, lamp.data.color.g*mult, lamp.data.color.b*mult)) self.out.write('\t\t<float name="samplingWeight" value="%f"/>\n' % lamp.data.mitsuba_lamp.samplingWeight) self.out.write('\t</luminaire>\n') elif ltype == 'AREA': self.out.write('\t<shape type="obj">\n') size_x = lamp.data.size size_y = lamp.data.size if lamp.data.shape == 'RECTANGLE': size_y = lamp.data.size_y mts_meshes_dir = os.path.join(self.target_dir, 'meshes') filename = "area_luminaire_%d.obj" % idx | 0c01bf9ab1ceebb9f973e3fc51cbd4a26e5b0a5a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7410/0c01bf9ab1ceebb9f973e3fc51cbd4a26e5b0a5a/adjustments.py |
class HardwareContextTests(TestCase): | class HardwareContextTests(unittest.TestCase): | def test_get_json_attr_types(self): self.assertEqual(DashboardBundle.get_json_attr_types(), {'test_runs': [TestRun]}) | ce54aa5c679c13f696fb5cc82e3ec222c5d9d937 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/12617/ce54aa5c679c13f696fb5cc82e3ec222c5d9d937/test_dashboard_bundle_format_1_0.py |
self.assertEqual(context.devices, []) | self.assertEqual(hw_context.devices, []) | def test_construction_1(self): hw_context = HardwareContext() self.assertEqual(context.devices, []) | ce54aa5c679c13f696fb5cc82e3ec222c5d9d937 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/12617/ce54aa5c679c13f696fb5cc82e3ec222c5d9d937/test_dashboard_bundle_format_1_0.py |
self.assertTrue(context.devices is devices) | self.assertTrue(hw_context.devices is devices) | def test_construction_2(self): devices = object() hw_context = HardwareContext(devices) self.assertTrue(context.devices is devices) | ce54aa5c679c13f696fb5cc82e3ec222c5d9d937 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/12617/ce54aa5c679c13f696fb5cc82e3ec222c5d9d937/test_dashboard_bundle_format_1_0.py |
self.assertTrue(context.devices is devices) | self.assertTrue(hw_context.devices is devices) | def test_construction_3(self): devices = object() hw_context = HardwareContext(devices=devices) self.assertTrue(context.devices is devices) | ce54aa5c679c13f696fb5cc82e3ec222c5d9d937 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/12617/ce54aa5c679c13f696fb5cc82e3ec222c5d9d937/test_dashboard_bundle_format_1_0.py |
class HardwareDeviceTests(TestCase): | class HardwareDeviceTests(unittest.TestCase): | def test_get_json_attr_types(self): self.assertEqual(HardwareContext.get_json_attr_types(), {'devices': [HardwareDevice]}) | ce54aa5c679c13f696fb5cc82e3ec222c5d9d937 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/12617/ce54aa5c679c13f696fb5cc82e3ec222c5d9d937/test_dashboard_bundle_format_1_0.py |
class SoftwareContextTests(TestCase): | class SoftwareContextTests(unittest.TestCase): | def test_device_types(self): self.assertEqual(HardwareDevice.DEVICE_CPU, "device.cpu") self.assertEqual(HardwareDevice.DEVICE_MEM, "device.mem") self.assertEqual(HardwareDevice.DEVICE_USB, "device.usb") self.assertEqual(HardwareDevice.DEVICE_PCI, "device.pci") self.assertEqual(HardwareDevice.DEVICE_BOARD, "device.board") | ce54aa5c679c13f696fb5cc82e3ec222c5d9d937 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/12617/ce54aa5c679c13f696fb5cc82e3ec222c5d9d937/test_dashboard_bundle_format_1_0.py |
class SoftwareImageTests(TestCase): | class SoftwareImageTests(unittest.TestCase): | def test_get_json_attr_types(self): self.assertEqual(SoftwareContext.get_json_attr_types(), {'packages': [SoftwarePackage], 'sw_image': SoftwareImage}) | ce54aa5c679c13f696fb5cc82e3ec222c5d9d937 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/12617/ce54aa5c679c13f696fb5cc82e3ec222c5d9d937/test_dashboard_bundle_format_1_0.py |
class SoftwarePackageTests(TestCase): | class SoftwarePackageTests(unittest.TestCase): | def test_get_json_attr_types(self): self.assertRaises(NotImplementedError, SoftwareImage.get_json_attr_types) | ce54aa5c679c13f696fb5cc82e3ec222c5d9d937 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/12617/ce54aa5c679c13f696fb5cc82e3ec222c5d9d937/test_dashboard_bundle_format_1_0.py |
class TestCaseTests(TestCase): | class TestCaseTests(unittest.TestCase): | def test_get_json_attr_types(self): self.assertRaises(NotImplementedError, SoftwarePackage.get_json_attr_types) | ce54aa5c679c13f696fb5cc82e3ec222c5d9d937 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/12617/ce54aa5c679c13f696fb5cc82e3ec222c5d9d937/test_dashboard_bundle_format_1_0.py |
TestResult.RESULT.PASS: 3, | TestResult.RESULT_PASS: 3, | def test_get_stats(self): test_run = TestRun() for result, count in [ [TestResult.RESULT_PASS, 3], [TestResult.RESULT_FAIL, 5], [TestResult.RESULT_SKIP, 2], [TestResult.RESULT_UNKNOWN, 1]]: for i in range(count): test_run.test_results.append(TestResult(None, result)) stats = test_run.get_stats() self.assertEqual(stats, { TestResult.RESULT.PASS: 3, TestResult.RESULT_FAIL: 5, TestResult.RESULT_SKIP: 2, TestResult.RESULT_UNKNOWN: 1}) | 4f3fb64a02073fa50b9ea3c57b4b014cd1b721ba /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/12617/4f3fb64a02073fa50b9ea3c57b4b014cd1b721ba/test_dashboard_bundle_format_1_0.py |
raise ValueError("Test id must be None or a string with reverse domain name") | raise ValueError("Test id must be None or a string with reverse " "domain name") | def _set_test_id(self, test_id): if test_id is not None and not self._TEST_ID_PATTERN.match(test_id): raise ValueError("Test id must be None or a string with reverse domain name") self._test_id = test_id | fe355965b81ab1161004f7f931bf23184b5243f2 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/12617/fe355965b81ab1161004f7f931bf23184b5243f2/sample.py |
slots = [slot[1:] if slot.startswith('_') else slot for slot in self.__slots__] | slots = [s[1:] if s.startswith('_') else s for s in self.__slots__] | def __repr__(self): """ Produce more-less human readable encoding of all fields. | fe355965b81ab1161004f7f931bf23184b5243f2 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/12617/fe355965b81ab1161004f7f931bf23184b5243f2/sample.py |
__slots__ = _Sample.__slots__ + ('_test_result', '_message', '_timestamp', '_duration') | __slots__ = _Sample.__slots__ + ('_test_result', '_message', '_timestamp', '_duration') | def __repr__(self): """ Produce more-less human readable encoding of all fields. | fe355965b81ab1161004f7f931bf23184b5243f2 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/12617/fe355965b81ab1161004f7f931bf23184b5243f2/sample.py |
if timestamp is not None and not isinstance(timestamp, datetime.datetime): raise TypeError("Timestamp must be None or datetime.datetime() instance") | if timestamp is not None and not isinstance(timestamp, datetime.datetime): raise TypeError("Timestamp must be None or datetime.datetime() " "instance") | def _set_timestamp(self, timestamp): if timestamp is not None and not isinstance(timestamp, datetime.datetime): raise TypeError("Timestamp must be None or datetime.datetime() instance") self._timestamp = timestamp | fe355965b81ab1161004f7f931bf23184b5243f2 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/12617/fe355965b81ab1161004f7f931bf23184b5243f2/sample.py |
if duration is not None and not isinstance(duration, datetime.timedelta): raise TypeError("duration must be None or datetime.timedelta() instance") | if duration is not None and not isinstance(duration, datetime.timedelta): raise TypeError("duration must be None or datetime.timedelta() " "instance") | def _set_duration(self, duration): if duration is not None and not isinstance(duration, datetime.timedelta): raise TypeError("duration must be None or datetime.timedelta() instance") if duration is not None and duration.days < 0: raise ValueError("duration cannot be negative") self._duration = duration | fe355965b81ab1161004f7f931bf23184b5243f2 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/12617/fe355965b81ab1161004f7f931bf23184b5243f2/sample.py |
def __cmp__(self, other): return cmp(self.message, other.message) or cmp(self.new_message, self.other_messge) | def __cmp__(self, other): return cmp(self.message, other.message) or cmp(self.new_message, self.other_messge) | 613f728e58b6c876ffb9f65f53d4875500e76afd /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/12617/613f728e58b6c876ffb9f65f53d4875500e76afd/schema.py |
|
self.new_message, self.object_expr, self.schema_expr) | self.new_message, self.object_expr, self.schema_expr) | def __str__(self): return ("ValidationError: {0} " "object_expr={1!r}, " "schema_expr={2!r})").format( self.new_message, self.object_expr, self.schema_expr) | 613f728e58b6c876ffb9f65f53d4875500e76afd /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/12617/613f728e58b6c876ffb9f65f53d4875500e76afd/schema.py |
object_suffix=None, schema_suffix=None): | schema_suffix=None): | def _report_error(self, legacy_message, new_message=None, object_suffix=None, schema_suffix=None): """ Report an error during validation. | 613f728e58b6c876ffb9f65f53d4875500e76afd /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/12617/613f728e58b6c876ffb9f65f53d4875500e76afd/schema.py |
if object_suffix: object_expr += object_suffix | def _report_error(self, legacy_message, new_message=None, object_suffix=None, schema_suffix=None): """ Report an error during validation. | 613f728e58b6c876ffb9f65f53d4875500e76afd /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/12617/613f728e58b6c876ffb9f65f53d4875500e76afd/schema.py |
|
raise ValidationError(legacy_message, new_message, object_expr, schema_expr) | raise ValidationError(legacy_message, new_message, object_expr, schema_expr) | def _report_error(self, legacy_message, new_message=None, object_suffix=None, schema_suffix=None): """ Report an error during validation. | 613f728e58b6c876ffb9f65f53d4875500e76afd /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/12617/613f728e58b6c876ffb9f65f53d4875500e76afd/schema.py |
self.devices = devices or [] | if devices is None: devices = [] self.devices = devices | def __init__(self, devices=None): self.devices = devices or [] | 6385ede938a25746903879126aea6a2bac79dfad /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/12617/6385ede938a25746903879126aea6a2bac79dfad/hw_context.py |
self.subparsers = self.parser.add_subparsers(title="Sub-command to invoke") | self.subparsers = self.parser.add_subparsers( title="Sub-command to invoke") | def __init__(self): self.parser = argparse.ArgumentParser( description=""" Command line tool for interacting with Launch Control """, epilog=""" Please report all bugs using the Launchpad bug tracker: http://bugs.launchpad.net/launch-control/+filebug """, add_help=False) self.subparsers = self.parser.add_subparsers(title="Sub-command to invoke") for command_cls in Command.get_subclasses(): sub_parser = self.subparsers.add_parser( command_cls.get_name(), help=command_cls.get_help()) sub_parser.set_defaults(command_cls=command_cls) command_cls.register_arguments(sub_parser) | e797d1ade647afadd134147664f20e2ee5646523 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/12617/e797d1ade647afadd134147664f20e2ee5646523/dispatcher.py |
def test_construction_1(self): name = object() sw_image = SoftwareImage(name) self.assertTrue(sw_image.name is name) def test_construction_2(self): name = object() sw_image = SoftwareImage(name=name) self.assertTrue(sw_image.name is name) | def test_construction_argument_one_sets_desc(self): desc = object() sw_image = SoftwareImage(desc) self.assertTrue(sw_image.desc is desc) def test_construction_argument_is_called_desc(self): desc = object() sw_image = SoftwareImage(desc=desc) self.assertTrue(sw_image.desc is desc) | def test_construction_1(self): name = object() sw_image = SoftwareImage(name) self.assertTrue(sw_image.name is name) | 731201f7fed0840b158f45d47ba0d62d9193d81b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/12617/731201f7fed0840b158f45d47ba0d62d9193d81b/test_dashboard_bundle_format_1_0.py |
class BundleStreamManagerAllowedForAnyoneTestCase(TestCase): | class BundleStreamManagerAllowedForUserTestCase(TestCase): | def test_allowed_for_anyone(self): with fixtures.created_bundle_streams(self.bundle_streams): pathnames = [bundle_stream.pathname for bundle_stream in BundleStream.objects.allowed_for_anyone().order_by('pathname')] self.assertEqual(pathnames, self.expected_pathnames) | 6dd7d6e77198fb0d6af86d4cabeac6b4bb4698bd /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/12617/6dd7d6e77198fb0d6af86d4cabeac6b4bb4698bd/tests.py |
verbose_name = _(u"Package name")) | verbose_name = _(u"Name")) | def save(self, *args, **kwargs): if self.content: sha1 = hashlib.sha1() for chunk in self.content.chunks(): sha1.update(chunk) self.content_sha1 = sha1.hexdigest() self.content.seek(0) return super(Bundle, self).save(*args, **kwargs) | e6c5f9d8f8f5b7d50c0b8331edcfd74a41084f82 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/12617/e6c5f9d8f8f5b7d50c0b8331edcfd74a41084f82/models.py |
This works with all public attributes: >>> class Person(PlainOldData): ... def __init__(self, name): ... self.name = name >>> joe = Person('Joe') >>> joe.pod_attrs ('name',) | This works with all public attributes:: | def pod_attrs(self): """ Return a list of sorted attributes. | 502ea825dcb552de6dc9667d6db41790219e5866 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/12617/502ea825dcb552de6dc9667d6db41790219e5866/pod.py |
With private attributes exposed as properties: >>> class Person(PlainOldData): ... def __init__(self, name): ... self._name = name ... @property ... def name(self): ... return self._name >>> joe = Person('Joe') >>> joe.pod_attrs ('name',) | >>> class Person(PlainOldData): ... def __init__(self, name): ... self.name = name >>> joe = Person('Joe') >>> joe.pod_attrs ('name',) | ... def __init__(self, name): | 502ea825dcb552de6dc9667d6db41790219e5866 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/12617/502ea825dcb552de6dc9667d6db41790219e5866/pod.py |
And with __slots__: >>> class Person(PlainOldData): ... __slots__ = ('_name',) ... def __init__(self, name): ... self._name = name ... @property ... def name(self): ... return self._name >>> joe = Person('Joe') >>> joe.pod_attrs ('name',) | With private attributes exposed as properties:: >>> class Person(PlainOldData): ... def __init__(self, name): ... self._name = name ... @property ... def name(self): ... return self._name >>> joe = Person('Joe') >>> joe.pod_attrs ('name',) And with __slots__:: >>> class Person(PlainOldData): ... __slots__ = ('_name',) ... def __init__(self, name): ... self._name = name ... @property ... def name(self): ... return self._name >>> joe = Person('Joe') >>> joe.pod_attrs ('name',) | ... def name(self): | 502ea825dcb552de6dc9667d6db41790219e5866 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/12617/502ea825dcb552de6dc9667d6db41790219e5866/pod.py |
This function simply shows all fields in a simple format: >>> class Person(PlainOldData): ... def __init__(self, name): ... self._name = name ... @property ... def name(self): ... return self._name >>> Person("Bob") <Person name:'Bob'> | This function simply shows all fields in a simple format:: >>> class Person(PlainOldData): ... def __init__(self, name): ... self._name = name ... @property ... def name(self): ... return self._name >>> Person("Bob") <Person name:'Bob'> | def __repr__(self): """ Produce more-less human readable encoding of all fields. | 502ea825dcb552de6dc9667d6db41790219e5866 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/12617/502ea825dcb552de6dc9667d6db41790219e5866/pod.py |
self._func. len(self._args), len(args))) | self._func, len(self._args), len(args))) | def _fill_args(self, *args, **kwargs): a_out = [] used_kwargs = set() # Walk through all arguments of the original function. Ff the argument # is present in `args' then use it. If we run out of positional # arguments look for keyword arguments with the same name for i, arg_name in enumerate(self._args): # find the argument if i < len(args): # positional arguments get passed as-is arg = args[i] elif arg_name in kwargs: # keyword arguments take over arg = kwargs[arg_name] # also remember we got it from a keyword argument used_kwargs.add(arg_name) else: # otherwise the function defaults kick in # with a yet another fall-back to special DUMMY value arg = self._args_with_defaults.get(arg_name, self.DUMMY) # resolve the argument if arg is self.DEFAULT: if arg_name not in self._args_with_defaults: import sys print >>sys.stderr, "args:", self._args print >>sys.stderr, "args with defaults:", self._args_with_defaults raise ValueError("You passed DEFAULT argument to %s " "which has no default value" % (arg_name,)) arg = self._args_with_defaults[arg_name] elif arg is self.DUMMY: arg = self._get_dummy_for(arg_name) # store the argument a_out.append(arg) # Now check if we have too many / not enough arguments if len(a_out) != len(self._args): raise TypeError("%s takes exactly %d argument, %d given" % ( self._func. len(self._args), len(args))) # Now check keyword arguments for arg_name in kwargs: # Check for duplicate definitions of positional/keyword arguments if arg_name in self._args and arg_name not in used_kwargs: raise TypeError("%s() got multiple values for keyword " "argument '%s'" % (self._func.func_name, arg_name)) | e492820f8a4b29e05dcfcdd8f362391e19cd360f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/12617/e492820f8a4b29e05dcfcdd8f362391e19cd360f/call_helper.py |
} for bundle in bundle_stream.bundles.all()] | } for bundle in bundle_stream.bundles.all().order_by("uploaded_on")] | def bundles(self, pathname): """ Name ---- `bundles` (`pathname`) | c8f114f8c2cae6fd70409410023b8732b7eaab75 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/12617/c8f114f8c2cae6fd70409410023b8732b7eaab75/xmlrpc.py |
scenarios = [ ('bundle_defaults', { | _TEST_RUN_BOILERPLATE = """ "test_id": "some_test_id", "test_results": [], "analyzer_assigned_uuid": "1ab86b36-c23d-11df-a81b-002163936223", "analyzer_assigned_date": "2010-12-31T23:59:59Z", """ scenarios = [ ('empty_bundle', { | def test_deserialize_clears_old_error_on_success(self): BundleDeserializationError.objects.create( bundle = self.bundle, error_message="not important").save() mock = self.mocker.patch(self.bundle) expect(mock._do_deserialize()) self.mocker.replay() self.bundle.deserialize() # note we cannot check for self.bundle.deserialization_error # directly due to the way django handles operations that affect # existing instances (it does not touch them like storm would # IIRC). self.assertRaises( BundleDeserializationError.DoesNotExist, BundleDeserializationError.objects.get, bundle=self.bundle) | 957b0eab837f40bbe8180ecadeffedaf82ab9311 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/12617/957b0eab837f40bbe8180ecadeffedaf82ab9311/tests.py |
('bundle_format', { 'json_text': '{"format": "text"}', | ('bundle_parsing', { 'json_text': """ { "format": "Dashboard Bundle Format 1.0", "test_runs": [] } """, | def test_deserialize_clears_old_error_on_success(self): BundleDeserializationError.objects.create( bundle = self.bundle, error_message="not important").save() mock = self.mocker.patch(self.bundle) expect(mock._do_deserialize()) self.mocker.replay() self.bundle.deserialize() # note we cannot check for self.bundle.deserialization_error # directly due to the way django handles operations that affect # existing instances (it does not touch them like storm would # IIRC). self.assertRaises( BundleDeserializationError.DoesNotExist, BundleDeserializationError.objects.get, bundle=self.bundle) | 957b0eab837f40bbe8180ecadeffedaf82ab9311 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/12617/957b0eab837f40bbe8180ecadeffedaf82ab9311/tests.py |
selectors.bundle.format, "text"), ] }), ('bundle_test_runs', { 'json_text': '{"test_runs": []}', 'selectors': { 'bundle': lambda bundle: bundle }, 'validators': [ | selectors.bundle.format, "Dashboard Bundle Format 1.0"), | def test_deserialize_clears_old_error_on_success(self): BundleDeserializationError.objects.create( bundle = self.bundle, error_message="not important").save() mock = self.mocker.patch(self.bundle) expect(mock._do_deserialize()) self.mocker.replay() self.bundle.deserialize() # note we cannot check for self.bundle.deserialization_error # directly due to the way django handles operations that affect # existing instances (it does not touch them like storm would # IIRC). self.assertRaises( BundleDeserializationError.DoesNotExist, BundleDeserializationError.objects.get, bundle=self.bundle) | 957b0eab837f40bbe8180ecadeffedaf82ab9311 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/12617/957b0eab837f40bbe8180ecadeffedaf82ab9311/tests.py |
('test_run_defaults', { | ('test_run_parsing', { | def test_deserialize_clears_old_error_on_success(self): BundleDeserializationError.objects.create( bundle = self.bundle, error_message="not important").save() mock = self.mocker.patch(self.bundle) expect(mock._do_deserialize()) self.mocker.replay() self.bundle.deserialize() # note we cannot check for self.bundle.deserialization_error # directly due to the way django handles operations that affect # existing instances (it does not touch them like storm would # IIRC). self.assertRaises( BundleDeserializationError.DoesNotExist, BundleDeserializationError.objects.get, bundle=self.bundle) | 957b0eab837f40bbe8180ecadeffedaf82ab9311 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/12617/957b0eab837f40bbe8180ecadeffedaf82ab9311/tests.py |
selectors.test_run.analyzer_assigned_uuid, None), lambda self, selectors: self.assertEqual( selectors.test_run.analyzer_assigned_date, None), lambda self, selectors: self.assertEqual( selectors.test_run.time_check_performed, False), lambda self, selectors: self.assertEqual( selectors.test_run.attributes, {}), lambda self, selectors: self.assertEqual( selectors.test_run.test_id, None), | selectors.test_run.test_id, "some_test_id"), | def test_deserialize_clears_old_error_on_success(self): BundleDeserializationError.objects.create( bundle = self.bundle, error_message="not important").save() mock = self.mocker.patch(self.bundle) expect(mock._do_deserialize()) self.mocker.replay() self.bundle.deserialize() # note we cannot check for self.bundle.deserialization_error # directly due to the way django handles operations that affect # existing instances (it does not touch them like storm would # IIRC). self.assertRaises( BundleDeserializationError.DoesNotExist, BundleDeserializationError.objects.get, bundle=self.bundle) | 957b0eab837f40bbe8180ecadeffedaf82ab9311 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/12617/957b0eab837f40bbe8180ecadeffedaf82ab9311/tests.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.