rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
log.debug('Caching trace to {0}'.format(dst)) | log.debug('Caching {0}'.format(key_hr)) | def cache_trace(dst, trace=None): if isinstance(dst, types.StringTypes): dst = unpack(b'!i', socket.inet_aton(dst))[0] cur = geoip_db.cursor() if trace is None: cur.execute('SELECT trace, ts FROM trace_cache WHERE dst = ?', (dst,)) # exit() try: trace, ts = next(cur) except StopIteration: raise KeyError if ts < time() ... |
' INTO trace_cache (dst, trace, ts) VALUES (?, ?, ?)', (dst, buffer(pickle.dumps(trace, -1)), int(time())) ) | ' INTO object_cache (key, value, ts) VALUES (?, ?, ?)', (key, buffer(pickle.dumps(value, -1)), int(time())) ) | def cache_trace(dst, trace=None): if isinstance(dst, types.StringTypes): dst = unpack(b'!i', socket.inet_aton(dst))[0] cur = geoip_db.cursor() if trace is None: cur.execute('SELECT trace, ts FROM trace_cache WHERE dst = ?', (dst,)) # exit() try: trace, ts = next(cur) except StopIteration: raise KeyError if ts < time() ... |
cur.execute('SELECT COUNT(*) FROM trace_cache') log.debug('GC - trace_cache oversaturation: {0}'.format(clean_count)) clean_count = next(cur)[0] - optz.trace_cache_max_size | cur.execute('SELECT COUNT(*) FROM object_cache') log.debug('GC - object_cache oversaturation: {0}'.format(clean_count)) clean_count = next(cur)[0] - optz.cache_max_size | def cache_trace(dst, trace=None): if isinstance(dst, types.StringTypes): dst = unpack(b'!i', socket.inet_aton(dst))[0] cur = geoip_db.cursor() if trace is None: cur.execute('SELECT trace, ts FROM trace_cache WHERE dst = ?', (dst,)) # exit() try: trace, ts = next(cur) except StopIteration: raise KeyError if ts < time() ... |
cur.execute( 'DELETE FROM trace_cache' | cur.execute( 'DELETE FROM object_cache' | def cache_trace(dst, trace=None): if isinstance(dst, types.StringTypes): dst = unpack(b'!i', socket.inet_aton(dst))[0] cur = geoip_db.cursor() if trace is None: cur.execute('SELECT trace, ts FROM trace_cache WHERE dst = ?', (dst,)) # exit() try: trace, ts = next(cur) except StopIteration: raise KeyError if ts < time() ... |
except TypeError: _cache_gc_counter = countdown(optz.trace_cache_max_size / 10, 'trace_cache') | def cache_trace(dst, trace=None): if isinstance(dst, types.StringTypes): dst = unpack(b'!i', socket.inet_aton(dst))[0] cur = geoip_db.cursor() if trace is None: cur.execute('SELECT trace, ts FROM trace_cache WHERE dst = ?', (dst,)) # exit() try: trace, ts = next(cur) except StopIteration: raise KeyError if ts < time() ... | |
return trace | return value | def cache_trace(dst, trace=None): if isinstance(dst, types.StringTypes): dst = unpack(b'!i', socket.inet_aton(dst))[0] cur = geoip_db.cursor() if trace is None: cur.execute('SELECT trace, ts FROM trace_cache WHERE dst = ?', (dst,)) # exit() try: trace, ts = next(cur) except StopIteration: raise KeyError if ts < time() ... |
try: return defer.succeed((ip, port, cache_trace(ip))) | cache = ft.partial(cache_object, ip, ext='trace') try: return defer.succeed((ip, port, cache())) | def trace(ip, port): try: return defer.succeed((ip, port, cache_trace(ip))) except KeyError: tracer = optz.trace_pool.run(_trace, ip) tracer.addCallback(ft.partial(cache_trace, ip)) tracer.addCallback(lambda res,ip=ip,port=port: (ip,port,res)) return tracer |
tracer.addCallback(ft.partial(cache_trace, ip)) | tracer.addCallback(cache) | def trace(ip, port): try: return defer.succeed((ip, port, cache_trace(ip))) except KeyError: tracer = optz.trace_pool.run(_trace, ip) tracer.addCallback(ft.partial(cache_trace, ip)) tracer.addCallback(lambda res,ip=ip,port=port: (ip,port,res)) return tracer |
dst, '"{0}" color={1}'.format(ip, color) ))) | dst, '"{0}" color={1}'.format(label, color) ))) | def generate_overlay(self, traces): arcs, markers = list(), list() markers.append(' '.join(str_cat( optz.home_lat, optz.home_lon, '"{0}"'.format(optz.home_label) ))) for ip,port,trace in it.imap(op.itemgetter(1), it.ifilter(op.itemgetter(0), traces)): if not trace: log.debug('Dropped completely unresolved trace to {0}'... |
parser.add_option('--trace-cache-obsoletion', action='store', default=3600, type='int', help='Time, after which cache entry considered obsolete (default: %default).') parser.add_option('--trace-cache-max-size', action='store', default=50000, type='int', help='Max number of cached traces to keep (default: %default).') | def geoip_db_var(var, cur=None): if cur is None: cur = geoip_db.cursor() cur.execute('SELECT val FROM meta WHERE var = ?', (var,)) try: return next(cur)[0] except StopIteration: raise KeyError(var) | |
geoip_db_ver = 2 if os.path.exists(geoip_db_path) and optz.maxmind_db: ts = os.stat(optz.maxmind_db).st_mtime | geoip_db_ver = 3 if os.path.exists(geoip_db_path): | def geoip_db_var(var, cur=None): if cur is None: cur = geoip_db.cursor() cur.execute('SELECT val FROM meta WHERE var = ?', (var,)) try: return next(cur)[0] except StopIteration: raise KeyError(var) |
ts_chk = geoip_db_var('mmdb_timestamp', cur) + 1 if ts_chk < ts: log.debug( 'MaxMind archive seem to be newer' ' than sqlite db ({0} > {1})'.format(ts_chk, ts) ) raise KeyError ts_chk = geoip_db_var('db_version', cur) if ts_chk < geoip_db_ver: build_geoip_db(from_version=ts_chk, link=link, cur=cur) | if optz.maxmind_db: ts = os.stat(optz.maxmind_db).st_mtime ts_chk = geoip_db_var('mmdb_timestamp', cur) + 1 if ts_chk < ts: log.debug( 'MaxMind archive seem to be newer' ' than sqlite db ({0} > {1})'.format(ts_chk, ts) ) raise KeyError | def geoip_db_var(var, cur=None): if cur is None: cur = geoip_db.cursor() cur.execute('SELECT val FROM meta WHERE var = ?', (var,)) try: return next(cur)[0] except StopIteration: raise KeyError(var) |
else: render_task = LoopingCall(optz.refresh, planetscape.snap) | else: render_task = LoopingCall(planetscape.snap) render_task.start(optz.refresh) log.debug('Starting eventloop') | def geoip_db_var(var, cur=None): if cur is None: cur = geoip_db.cursor() cur.execute('SELECT val FROM meta WHERE var = ?', (var,)) try: return next(cur)[0] except StopIteration: raise KeyError(var) |
def build_geoip_db(spool_path, mmdb_zip, from_version=0, link=None, cur=None): | def build_geoip_db(geoip_db_path, spool_path, mmdb_zip, from_version=0, link=None, cur=None): | def build_geoip_db(spool_path, mmdb_zip, from_version=0, link=None, cur=None): if from_version < 1: # i.e. from scratch ## Unzip CSVs unzip_root = os.path.join(spool_path, 'mmdb_tmp') log.debug('Unpacking MaxMind db (to: {0})'.format(unzip_root)) if os.path.exists(unzip_root): shutil.rmtree(unzip_root) os.mkdir(unzip_r... |
import sqlite3 | def initialize(optz): 'Prepare necessary paths, locks and geoip_db. Must be run before event-loop.' optz = AttrDict._from_optz(optz) ### Logging logging.basicConfig( level=logging.DEBUG if optz.debug else logging.WARNING ) ### Check/expand paths os.umask(077) # no need to share cache w/ someone if optz.maxmind_db: ... | |
geoip_db_build = ft.partial(build_geoip_db, optz.spool_path, optz.maxmind_db) | geoip_db_build = ft.partial( build_geoip_db, geoip_db_path, optz.spool_path, optz.maxmind_db ) | def initialize(optz): 'Prepare necessary paths, locks and geoip_db. Must be run before event-loop.' optz = AttrDict._from_optz(optz) ### Logging logging.basicConfig( level=logging.DEBUG if optz.debug else logging.WARNING ) ### Check/expand paths os.umask(077) # no need to share cache w/ someone if optz.maxmind_db: ... |
print "Generated prefs" print "URL", settings.url | def main(): settings = preferences.Preferences() print "Generated prefs" print "URL", settings.url dialog = preferences.ConfigDialog(None, "settings", settings) print "Creating dialog" dialog.show() app.exec_() | |
print "Creating dialog" | def main(): settings = preferences.Preferences() print "Generated prefs" print "URL", settings.url dialog = preferences.ConfigDialog(None, "settings", settings) print "Creating dialog" dialog.show() app.exec_() | |
if st.getPlayer().isNoble() and count > REQUESTED_AMOUNT: | if st.getPlayer().isNoble() and count >= REQUESTED_AMOUNT: | def onEvent(self,event,st): htmltext = "<html><head><body>I have nothing to say you</body></html>" count=st.getQuestItemsCount(REQUESTED_ITEM) if event == "66667-clanOk.htm" : if st.getPlayer().isClanLeader() and st.getPlayer().getClan().getLevel()<8: if st.getPlayer().isNoble() and count > REQUESTED_AMOUNT: htmltext=e... |
st.getPlayer().getClan().setReputationScore(NEW_REP_SCORE, true); | st.getPlayer().getClan().setReputationScore(NEW_REP_SCORE, 1); | def onEvent(self,event,st): htmltext = "<html><head><body>I have nothing to say you</body></html>" count=st.getQuestItemsCount(REQUESTED_ITEM) if event == "66667-clanOk.htm" : if st.getPlayer().isClanLeader() and st.getPlayer().getClan().getLevel()<8: if st.getPlayer().isNoble() and count > REQUESTED_AMOUNT: htmltext=e... |
htmltext = "<html><head><body>This quest has already been completed.</body></html>" | htmltext = "<html><head><body>This quest have already been completed.</body></html>" | def onTalk (self,npc,player): htmltext = "<html><head><body>I have nothing to say you</body></html>" st = player.getQuestState(qn) if not st : return htmltext npcId = npc.getNpcId() id = st.getState() if id == CREATED : htmltext="66667-1.htm" elif id == COMPLETED : htmltext = "<html><head><body>This quest has already b... |
except getopt.GetoptError: | except getopt.GetoptError, e: | def main(): try: opts, args = getopt.getopt(sys.argv[1:], "l", ["list"]) except getopt.GetoptError: usage(e) if not args: usage() srcpath = args[0] if not isdir(srcpath): fatal("no such directory `%s'" % srcpath) for opt, val in opts: if opt == '-h': usage() if opt in ('-l', '--list'): return list(srcpath) try: ve... |
commits = self._getoutput("git-rev-list", "--all").split("\n") | branch = basename(self.verseek_head or self.head) commits = self._getoutput("git-rev-list", branch).split("\n") | def list(self): commits = self._getoutput("git-rev-list", "--all").split("\n") return self._getoutput("autoversion", *commits).split("\n") |
lines = (line.strip() for line in file(path).readlines()) | lines = (line.rstrip() for line in file(path).readlines() if not line.startswith(" ")) | def parse_control(path): lines = (line.strip() for line in file(path).readlines()) return dict([ re.split("\s*:\s*", line, 1) for line in lines if line and not line.startswith(" ") ]) |
if line and not line.startswith(" ") ]) | if line ]) | def parse_control(path): lines = (line.strip() for line in file(path).readlines()) return dict([ re.split("\s*:\s*", line, 1) for line in lines if line and not line.startswith(" ") ]) |
if version and deb_get_version(path) != version: | if version and deb_get_version(self.path) != version: | def seek(self, version=None): if version and deb_get_version(path) != version: raise Error("can't seek to nonexistent version `%s'" % version) |
self._is_changed = self.check_real_change(instance, mapper, connection) if not self.revisioning_disabled(instance) and self._is_changed: | self._is_changed[instance] = self.check_real_change(instance, mapper, connection) if not self.revisioning_disabled(instance) and self._is_changed[instance]: | def before_update(self, mapper, connection, instance): self._is_changed = self.check_real_change(instance, mapper, connection) if not self.revisioning_disabled(instance) and self._is_changed: logger.debug('before_update: %s' % instance) self.set_revision(instance) self._is_changed = self.check_real_change(instance, map... |
self._is_changed = self.check_real_change(instance, mapper, connection) | self._is_changed[instance] = self.check_real_change( instance, mapper, connection) | def before_update(self, mapper, connection, instance): self._is_changed = self.check_real_change(instance, mapper, connection) if not self.revisioning_disabled(instance) and self._is_changed: logger.debug('before_update: %s' % instance) self.set_revision(instance) self._is_changed = self.check_real_change(instance, map... |
self._is_changed = self.check_real_change(instance, mapper, connection) if not self.revisioning_disabled(instance) and self._is_changed: | self._is_changed[instance] = self.check_real_change(instance, mapper, connection) if not self.revisioning_disabled(instance) and self._is_changed[instance]: | def before_insert(self, mapper, connection, instance): self._is_changed = self.check_real_change(instance, mapper, connection) if not self.revisioning_disabled(instance) and self._is_changed: logger.debug('before_insert: %s' % instance) self.set_revision(instance) return EXT_CONTINUE |
if not self.revisioning_disabled(instance) and self._is_changed: | if not self.revisioning_disabled(instance) and self._is_changed[instance]: | def after_update(self, mapper, connection, instance): if not self.revisioning_disabled(instance) and self._is_changed: logger.debug('after_update: %s' % instance) self.make_revision(instance, mapper, connection) return EXT_CONTINUE |
if not self.revisioning_disabled(instance) and self._is_changed: | if not self.revisioning_disabled(instance) and self._is_changed[instance]: | def after_insert(self, mapper, connection, instance): if not self.revisioning_disabled(instance) and self._is_changed: logger.debug('after_insert: %s' % instance) self.make_revision(instance, mapper, connection) return EXT_CONTINUE |
print get_editor_name_as_list() | def get_string_from_editor(base_string, prefix='idli-'): tf = tempfile.NamedTemporaryFile('w+b',prefix=prefix) tf.write(base_string) tf.seek(0) print get_editor_name_as_list() exit_status = subprocess.call(get_editor_name_as_list() + [tf.name]) result = tf.read() return (result, exit_status) | |
Virtual Spectrophotometric Measurements for Biologically and Physically-Based Rendering The Visual Computer, Volume 17, Issue 8, pp. 506-518, 2001. | Virtual spectrophotometric Measurements for biologically and physically-based rendering \textit{The Visual Computer}, Volume 17, Issue 8, pp. 506-518, 2001. | def latexBody(self): return r""" These are the results of your model run of \textbf{ABM-B} for the Natural Phenomenon Simulation Group (NPSG) at the University of Waterloo. |
Remote Sensing of Environment, 100(3):335-347, 2006 | \textit{Remote Sensing of Environment}, 100(3):335-347, 2006 | def latexBody(self): return r""" These are the results of your model run of \textbf{ABM-B} for the Natural Phenomenon Simulation Group (NPSG) at the University of Waterloo. |
An investigation on sieve and detour effects affecting the interaction of collimated and diffuse infrared radiation (750 to 2500 nm) with plant leaves IEEE Transactions on Geoscience and Remote Sensing, 45 (8):2593-2599, 2007 | An investigation on sieve and detour effects affecting the interaction of collimated and diffuse infrared radiation (750 to 2500 nm) with plant leaves \textit{IEEE Transactions on Geoscience and Remote Sensing}, 45 (8):2593-2599, 2007 | def latexBody(self): return r""" These are the results of your model run of \textbf{ABM-B} for the Natural Phenomenon Simulation Group (NPSG) at the University of Waterloo. |
Improving the Reliability/Cost Ratio of Goniophotometric Comparisons Journal of Graphics Tools, Volume 9, Number 3, pp. 1-20, 2004. | Improving the reliability/cost ratio of goniophotometric comparisons \textit{Journal of Graphics Tools}, Volume 9, Number 3, pp. 1-20, 2004. | def latexBody(self): return r""" These are the results of your model run of \textbf{ABM-B} for the Natural Phenomenon Simulation Group (NPSG) at the University of Waterloo. |
def executableParameters(self): return [ "-d", os.path.join(os.path.dirname(self.executable), "data"), "-n", str(self.nSamples.value), "-p", str(self.angleOfIncidence.value), "-s", str(5), "-w", str(self.wavelengths.value[0]), "-e", str(self.wavelengths.value[1]), "sample.json", "spectral_distribution.csv" ] | def executableParameters(self): return [ "-d", os.path.join(os.path.dirname(self.executable), "data"), "-n", str(self.nSamples.value), "-p", str(self.angleOfIncidence.value), "-s", str(5), #step "-w", str(self.wavelengths.value[0]), "-e", str(self.wavelengths.value[1]), "sample.json", "spectral_distribution.csv" ] | |
"palisadeCellCapsAspectRatio": 0.0, | "palisadeCellCapsAspectRatio": self.palisadeCellCapsAspectRatio.value, | def prepareExecution(self): with open(os.path.join(self.workingDirectory, "sample.json"), 'w') as f: f.write(json.dumps({ "wholeLeafThickness": self.wholeLeafThickness.value, "cuticleUndulationsAspectRatio": self.cuticleUndulationsAspectRatio.value, "epidermisCellCapsAspectRatio": self.epidermisCellCapsAspectRatio.valu... |
def prepareGraphs(self): wavelengths, reflectance, transmittance, absorptance = ([], [], [], []) with open(os.path.join(self.workingDirectory, "spectral_distribution.csv"), 'r') as f: spectralReader = csv.reader(f) headers = [e.strip() for e in spectralReader.next()] wIndex = headers.index("wavelength") rIndex = heade... | def prepareGraphs(self): wavelengths, reflectance, transmittance, absorptance = ([], [], [], []) | |
This is the results of your model run of \textbf{ABM-U} for the | This is the results of your model run of \textbf{ABM-B} for the | def latexBody(self): return r""" This is the results of your model run of \textbf{ABM-U} for the Natural Phenomenon Simulation Group (NPSG) at University of Waterloo. |
The ABM-U employs an algorithmic Monte Carlo formulation to simulate light interactions with unifacial plant leaves (e.g., corn and sugar cane). More specifically, radiation propagation | The ABM-B employs an algorithmic Monte Carlo formulation to simulate light interactions with bifacial plant leaves (e.g., soybean and maple). More specifically, radiation propagation | def latexBody(self): return r""" This is the results of your model run of \textbf{ABM-U} for the Natural Phenomenon Simulation Group (NPSG) at University of Waterloo. |
to the main tissue interfaces found in these leaves. For more details about this model, please refer to our related publications~\cite{Ba06,Ba07}. Although the ABM-U provides bidirectional readings, | to the main tissue interfaces found in these leaves. For more details about this model, please refer to our related publications~\cite{Ba06,Ba07}. Although the ABM-B provides bidirectional readings, | def latexBody(self): return r""" This is the results of your model run of \textbf{ABM-U} for the Natural Phenomenon Simulation Group (NPSG) at University of Waterloo. |
\caption{Reflectance Curve} | \caption{Directional-hemispherical Reflectance} | def latexBody(self): return r""" This is the results of your model run of \textbf{ABM-U} for the Natural Phenomenon Simulation Group (NPSG) at University of Waterloo. |
\caption{Transmittance Curve} | \caption{Directional-hemispherical Transmittance} | def latexBody(self): return r""" This is the results of your model run of \textbf{ABM-U} for the Natural Phenomenon Simulation Group (NPSG) at University of Waterloo. |
\caption{Absorptance Curve} | \caption{Directional-hemispherical Absorptance} | def latexBody(self): return r""" This is the results of your model run of \textbf{ABM-U} for the Natural Phenomenon Simulation Group (NPSG) at University of Waterloo. |
def __recvall(self, bytes): """__recvall(bytes) -> data | def __recvall(self, count): """__recvall(count) -> data | def __recvall(self, bytes): """__recvall(bytes) -> data Receive EXACTLY the number of bytes requested from the socket. Blocks until the required number of bytes have been received. """ data = "" while len(data) < bytes: d = self.recv(bytes-len(data)) if not d: raise GeneralProxyError("connection closed unexpectedly") d... |
data = "" while len(data) < bytes: d = self.recv(bytes-len(data)) if not d: raise GeneralProxyError("connection closed unexpectedly") | data = bytes("") while len(data) < count: d = self.recv(count-len(data)).decode() if not d: raise GeneralProxyError((0,"connection closed unexpectedly")) | def __recvall(self, bytes): """__recvall(bytes) -> data Receive EXACTLY the number of bytes requested from the socket. Blocks until the required number of bytes have been received. """ data = "" while len(data) < bytes: d = self.recv(bytes-len(data)) if not d: raise GeneralProxyError("connection closed unexpectedly") d... |
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 # setpr... |
req = req + struct.pack(">H",destport) | req = req + struct.pack(">H",destport).decode() | 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 # setpr... |
boundport = struct.unpack(">H",self.__recvall(2))[0] | boundport = struct.unpack(">H",bytes(self.__recvall(2), 'utf8'))[0] | 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 # setpr... |
req = "\x04\x01" + struct.pack(">H",destport) + ipaddr | req = "\x04\x01" + struct.pack(">H",destport).decode() + 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 sh... |
self.__proxysockname = (socket.inet_ntoa(resp[4:]),struct.unpack(">H",resp[2:4])[0]) | self.__proxysockname = (socket.inet_ntoa(resp[4:]),struct.unpack(">H",bytes(resp[2:4],'utf8'))[0]) | 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 sh... |
boundaddr = self.__recvall(resp[4]) | boundaddr = self.__recvall(ord(resp[4])) | 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 # setpr... |
"""This puts a character at the current cursor position. cursor position if moved forward with wrap-around, but no scrolling is done if | """This puts a character at the current cursor position. The cursor position is moved forward with wrap-around, but no scrolling is done if | def write_ch (self, ch): |
self.put_abs(self.cur_r, self.cur_c, ' ') | def write_ch (self, ch): | |
data = data + self.recv(bytes-len(data)) | d = self.recv(bytes-len(data)) if not d: raise GeneralProxyError("connection closed unexpectedly") data = data + d | def __recvall(self, bytes): """__recvall(bytes) -> data Receive EXACTLY the number of bytes requested from the socket. Blocks until the required number of bytes have been received. """ data = "" while len(data) < bytes: data = data + self.recv(bytes-len(data)) return data |
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 # setpr... |
raise Socks5Error(ord(resp[1]),_generalerrors[ord(resp[1])]) else: raise Socks5Error(9,_generalerrors[9]) | 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 # setpr... |
bytes = bytes.encode() | try: bytes = bytes.encode() except Exception: pass | def sendall(self, bytes): if 'encode' in dir(bytes): bytes = bytes.encode() socket.socket.sendall(self, bytes) |
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)).decode() if not d: raise GeneralProxyError((0,"connection clos... | def __decode(self, bytes): if 'decode' in dir(bytes): try: bytes = bytes.decode() except Exception: pass return bytes def __encode(self, bytes): | 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)).decode() if not d: raise GeneralProxyError((0,"connection clos... |
socket.socket.sendall(self, bytes) | return bytes 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... | def sendall(self, bytes): if 'encode' in dir(bytes): try: bytes = bytes.encode() except Exception: pass socket.socket.sendall(self, bytes) |
req = req + struct.pack(">H",destport).decode() | 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 # setpr... |
req = "\x04\x01" + struct.pack(">H",destport).decode() + 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 sh... |
ops, 'Virtual(node_vtable)', None) | ops, ops) | def test_invalid_loop_1(self): ops = """ [p1] guard_isnull(p1) [] # p2 = new_with_vtable(ConstClass(node_vtable)) jump(p2) """ py.test.raises(InvalidLoop, self.optimize_loop, ops, 'Virtual(node_vtable)', None) |
py.test.skip("this would fail if we had Fixed again in the specnodes") | def test_invalid_loop_2(self): py.test.skip("this would fail if we had Fixed again in the specnodes") ops = """ [p1] guard_class(p1, ConstClass(node_vtable2)) [] # p2 = new_with_vtable(ConstClass(node_vtable)) escape(p2) # prevent it from staying Virtual jump(p2) """ py.test.raises(InvalidLoop, self.optimize_loop,... | |
ops, '...', None) | ops, ops) | def test_invalid_loop_2(self): py.test.skip("this would fail if we had Fixed again in the specnodes") ops = """ [p1] guard_class(p1, ConstClass(node_vtable2)) [] # p2 = new_with_vtable(ConstClass(node_vtable)) escape(p2) # prevent it from staying Virtual jump(p2) """ py.test.raises(InvalidLoop, self.optimize_loop,... |
py.test.raises(InvalidLoop, self.optimize_loop, ops, 'Virtual(node_vtable, nextdescr=Virtual(node_vtable))', None) | py.test.raises(InvalidLoop, self.optimize_loop, ops, ops) | def test_invalid_loop_3(self): ops = """ [p1] p2 = getfield_gc(p1, descr=nextdescr) guard_isnull(p2) [] # p3 = new_with_vtable(ConstClass(node_vtable)) p4 = new_with_vtable(ConstClass(node_vtable)) setfield_gc(p3, p4, descr=nextdescr) jump(p3) """ py.test.raises(InvalidLoop, self.optimize_loop, ops, 'Virtual(node_vtabl... |
if self._precision = -1: | if self._precision == -1: | def _format_float(self, w_float): space = self.space if self._alternate: msg = "alternate form not allowed in float formats" raise OperationError(space.w_ValueError, space.wrap(msg)) tp = self._type if tp == "\0": tp = "g" value = space.float_w(w_float) if tp == "%": tp = "f" value *= 100 if self._precision = -1: self.... |
for x in testmap: | for x in self.fspath.listdir(): | def collect(self): l = [] for x in testmap: name = x.basename regrtest = self.get(name) if regrtest is not None: #if option.extracttests: # l.append(InterceptedRunModule(name, self, regrtest)) #else: l.append(RunFileExternal(name, parent=self, regrtest=regrtest)) return l |
if regrtest is not None: | if regrtest is not None: if bool(we_are_in_modified) ^ regrtest.ismodified(): continue | def collect(self): l = [] for x in testmap: name = x.basename regrtest = self.get(name) if regrtest is not None: #if option.extracttests: # l.append(InterceptedRunModule(name, self, regrtest)) #else: l.append(RunFileExternal(name, parent=self, regrtest=regrtest)) return l |
return RegrDirectory(path, parent) | if path in (modregrtestdir, regrtestdir): return RegrDirectory(path, parent) def pytest_ignore_collect(path): if path.check(file=1): return True | def pytest_collect_directory(parent, path): return RegrDirectory(path, parent) |
os.putenv('PYTHONPATH', old_pythonpath) | if old_pythonpath is not None: os.putenv('PYTHONPATH', old_pythonpath) | def chdir_and_unset_pythonpath(new_cwd): old_cwd = new_cwd.chdir() old_pythonpath = os.getenv('PYTHONPATH') os.unsetenv('PYTHONPATH') try: yield finally: old_cwd.chdir() os.putenv('PYTHONPATH', old_pythonpath) |
assert isinstance(hashlib.new('sha1', u'xxx'), _hashlib.hash) | assert isinstance(hashlib.new('sha256', u'xxx'), _hashlib.hash) | def test_unicode(): assert isinstance(hashlib.new('sha1', u'xxx'), _hashlib.hash) |
for _ in range((self.mc.size_of_gen_load_int+WORD)//WORD): | for _ in range(size//WORD): | def _prepare_sp_patch_location(self): """Generate NOPs as placeholder to patch the instruction(s) to update the sp according to the number of spilled variables""" l = self.mc.curraddr() for _ in range((self.mc.size_of_gen_load_int+WORD)//WORD): self.mc.MOV_rr(r.r0.value, r.r0.value) return l |
def gettext(msg): """gettext(msg) -> string Return translation of msg.""" return _gettext(msg) def dgettext(domain, msg): """dgettext(domain, msg) -> string Return translation of msg in domain.""" return _dgettext(domain, msg) def dcgettext(domain, msg, category): """dcgettext(domain, msg, category) -> string Return ... | if HAS_LIBINTL: def gettext(msg): """gettext(msg) -> string Return translation of msg.""" return _gettext(msg) def dgettext(domain, msg): """dgettext(domain, msg) -> string Return translation of msg in domain.""" return _dgettext(domain, msg) def dcgettext(domain, msg, category): """dcgettext(domain, msg, category) -... | def gettext(msg): """gettext(msg) -> string Return translation of msg.""" return _gettext(msg) |
'gettext', 'dgettext', 'dcgettext', 'textdomain', 'bindtextdomain', | def bind_textdomain_codeset(domain, codeset): """bind_textdomain_codeset(domain, codeset) -> string Bind the C library's domain to codeset.""" codeset = _bind_textdomain_codeset(domain, codeset) if codeset: return codeset return None | |
if _bind_textdomain_codeset: __all__ += ('bind_textdomain_codeset',) | if HAS_LIBINTL: __all__ += ('gettext', 'dgettext', 'dcgettext', 'textdomain', 'bindtextdomain') if HAS_BIND_TEXTDOMAIN_CODESET: __all__ += ('bind_textdomain_codeset',) | def bind_textdomain_codeset(domain, codeset): """bind_textdomain_codeset(domain, codeset) -> string Bind the C library's domain to codeset.""" codeset = _bind_textdomain_codeset(domain, codeset) if codeset: return codeset return None |
def unpack_float(data,index,size,le): bytes = [ord(b) for b in data[index:index+size]] if len(bytes) != size: raise StructError,"Not enough data to unpack" if max(bytes) == 0: return 0.0 if le == 'big': bytes.reverse() if size == 4: bias = 127 exp = 8 prec = 23 else: bias = 1023 exp = 11 prec = 52 mantissa = long(bytes... | def unpack_float(data,index,size,le): bytes = [ord(b) for b in data[index:index+size]] if len(bytes) != size: raise StructError,"Not enough data to unpack" if max(bytes) == 0: return 0.0 if le == 'big': bytes.reverse() if size == 4: bias = 127 exp = 8 prec = 23 else: bias = 1023 exp = 11 prec = 52 mantissa = long(bytes... | |
def pack_float(number, size, le): if size == 4: bias = 127 exp = 8 prec = 23 else: bias = 1023 exp = 11 prec = 52 if isnan(number): sign = 0x80 man, e = 1.5, bias + 1 else: if number < 0: sign = 0x80 number *= -1 elif number == 0.0: return '\x00' * size else: sign = 0x00 if isinf(number): man, e = 1.0, bias + 1 else: ... | def pack_float(x, size, le): unsigned = float_pack(x, size) | def pack_float(number, size, le): if size == 4: bias = 127 exp = 8 prec = 23 else: bias = 1023 exp = 11 prec = 52 if isnan(number): sign = 0x80 man, e = 1.5, bias + 1 else: if number < 0: sign = 0x80 number *= -1 elif number == 0.0: return '\x00' * size else: sign = 0x00 if isinf(number): man, e = 1.0, bias + 1 else: ... |
if 0.5 <= man and man < 1.0: man *= 2 e -= 1 man -= 1 e += bias power_of_two = 1 << prec mantissa = int(power_of_two * man + 0.5) if mantissa >> prec : mantissa = 0 e += 1 for i in range(size-2): result.append(chr(mantissa & 0xff)) mantissa >>= 8 x = (mantissa & ((1<<(15-exp))-1)) | ((e & ((1<<(exp-7))-1))<<(15-exp)) ... | for i in range(8): result.append(chr((unsigned >> (i * 8)) & 0xFF)) if le == "big": | def pack_float(number, size, le): if size == 4: bias = 127 exp = 8 prec = 23 else: bias = 1023 exp = 11 prec = 52 if isnan(number): sign = 0x80 man, e = 1.5, bias + 1 else: if number < 0: sign = 0x80 number *= -1 elif number == 0.0: return '\x00' * size else: sign = 0x00 if isinf(number): man, e = 1.0, bias + 1 else: ... |
raise NotImplementedError | raise KeyError | def m(self): raise NotImplementedError |
except NotImplementedError: pass | except KeyError: assert 0 | def f(n): if n > 3: o = A() else: o = B() try: o.m() except NotImplementedError: pass return B().m() |
self.interpret_raises(NotImplementedError, f, [7]) | self.interpret_raises(KeyError, f, [7]) | def f(n): if n > 3: o = A() else: o = B() try: o.m() except NotImplementedError: pass return B().m() |
w_result = space.wrap(result[0]) | if lltyp is rffi.FLOAT: w_result = space.wrap(rffi.cast(rffi.DOUBLE, result[0])) else: w_result = space.wrap(result[0]) | def PyMember_GetOne(space, obj, w_member): addr = rffi.cast(ADDR, obj) addr += w_member.c_offset member_type = rffi.cast(lltype.Signed, w_member.c_type) for converter in integer_converters: typ, lltyp, _ = converter if typ == member_type: result = rffi.cast(rffi.CArrayPtr(lltyp), addr) w_result = space.wrap(result[0])... |
"guard_class", "guard_nonnull", "guard_isnull", | def main(n): s = 0 for i in range(n): s += g(n)[i] return s | |
array = arraybox.getref_base() | array = arraybox.getint() | def do_getarrayitem_raw(cpu, _, arraybox, indexbox, arraydescr): array = arraybox.getref_base() index = indexbox.getint() assert not arraydescr.is_array_of_pointers() if arraydescr.is_array_of_floats(): return BoxFloat(cpu.bh_getarrayitem_raw_f(arraydescr, array, index)) else: return BoxInt(cpu.bh_getarrayitem_raw_i(ar... |
self.encode32(mem, 0, regalloc.frame_manager.frame_depth-1) | self.encode32(mem, 0, regalloc.frame_manager.frame_depth) | def _gen_path_to_exit_path(self, op, args, regalloc, fcond=c.AL): """ types: \xEE = REF \xEF = INT location: \xFC = stack location \xFD = imm location \xFE = Empty arg """ |
n = (regalloc.frame_manager.frame_depth - 1)*WORD | n = (regalloc.frame_manager.frame_depth)*WORD | def _patch_sp_offset(self, addr, regalloc): cb = ARMv7InMemoryBuilder(addr, ARMv7InMemoryBuilder.size_of_gen_load_int) if regalloc.frame_manager.frame_depth == 1: return n = (regalloc.frame_manager.frame_depth - 1)*WORD self._adjust_sp(n, cb) |
self.check_loops(getfield_gc=1, setfield_gc=1, everywhere=True) | self.check_loops(getfield_gc=0, setfield_gc=1) self.check_loops(getfield_gc=1, setfield_gc=2, everywhere=True) | def f(n): xy = self.setup() xy.inst_x = 10 other = self.setup() other.inst_x = 15 while n > 0: myjitdriver.can_enter_jit(xy=xy, n=n, other=other) myjitdriver.jit_merge_point(xy=xy, n=n, other=other) promote_virtualizable(other, 'inst_x') value = other.inst_x # getfield_gc other.inst_x = value + 1 # setfield... |
imm_a0 = isinstance(a0, ConstInt) and (a0.getint() <= 0xFF or -1 * a0.getint() <= 0xFF) imm_a1 = isinstance(a1, ConstInt) and (a1.getint() <= 0xFF or -1 * a1.getint() <= 0xFF) l0 = regalloc.make_sure_var_in_reg(a0, imm_fine=imm_a0) l1 = regalloc.make_sure_var_in_reg(a1, [a0], imm_fine=imm_a1) res = regalloc.force_alloc... | boxes = [a0, a1] imm_a0 = self._check_imm_arg(a0) imm_a1 = self._check_imm_arg(a1) if not imm_a0 and imm_a1: l0, box = self._ensure_value_is_boxed(a0, regalloc) l1 = regalloc.make_sure_var_in_reg(a1, [a0]) boxes.append(box) elif imm_a0 and not imm_a1: l0 = regalloc.make_sure_var_in_reg(a0) l1, box = self._ensure_value_... | def emit_op_int_sub(self, op, regalloc, fcond): # assuming only one argument is constant a0 = op.getarg(0) a1 = op.getarg(1) imm_a0 = isinstance(a0, ConstInt) and (a0.getint() <= 0xFF or -1 * a0.getint() <= 0xFF) imm_a1 = isinstance(a1, ConstInt) and (a1.getint() <= 0xFF or -1 * a1.getint() <= 0xFF) l0 = regalloc.make_... |
if value < 0: self.mc.ADD_ri(res.value, l1.value, -1 * value, s=1) self.mc.MVN_rr(res.value, l1.value, s=1) else: self.mc.RSB_ri(res.value, l1.value, value, s=1) elif imm_a1: | assert value >= 0 self.mc.RSB_ri(res.value, l1.value, value, s=1) elif l1.is_imm(): | def emit_op_int_sub(self, op, regalloc, fcond): # assuming only one argument is constant a0 = op.getarg(0) a1 = op.getarg(1) imm_a0 = isinstance(a0, ConstInt) and (a0.getint() <= 0xFF or -1 * a0.getint() <= 0xFF) imm_a1 = isinstance(a1, ConstInt) and (a1.getint() <= 0xFF or -1 * a1.getint() <= 0xFF) l0 = regalloc.make_... |
if value < 0: self.mc.ADD_ri(res.value, l0.value, -1 * value, s=1) else: self.mc.SUB_ri(res.value, l0.value, value, s=1) | assert value >= 0 self.mc.SUB_ri(res.value, l0.value, value, s=1) | def emit_op_int_sub(self, op, regalloc, fcond): # assuming only one argument is constant a0 = op.getarg(0) a1 = op.getarg(1) imm_a0 = isinstance(a0, ConstInt) and (a0.getint() <= 0xFF or -1 * a0.getint() <= 0xFF) imm_a1 = isinstance(a1, ConstInt) and (a1.getint() <= 0xFF or -1 * a1.getint() <= 0xFF) l0 = regalloc.make_... |
regalloc.possibly_free_var(a0) regalloc.possibly_free_var(a1) | regalloc.possibly_free_vars(boxes) | def emit_op_int_sub(self, op, regalloc, fcond): # assuming only one argument is constant a0 = op.getarg(0) a1 = op.getarg(1) imm_a0 = isinstance(a0, ConstInt) and (a0.getint() <= 0xFF or -1 * a0.getint() <= 0xFF) imm_a1 = isinstance(a1, ConstInt) and (a1.getint() <= 0xFF or -1 * a1.getint() <= 0xFF) l0 = regalloc.make_... |
l1 = regalloc.make_sure_var_in_reg(ConstInt(-1), [arg], imm_fine=False) | self.mc.MVN_ri(r.ip.value, imm=~-1) | def emit_op_int_neg(self, op, regalloc, fcond): arg = op.getarg(0) resbox = op.result l0 = regalloc.make_sure_var_in_reg(arg) l1 = regalloc.make_sure_var_in_reg(ConstInt(-1), [arg], imm_fine=False) resloc = regalloc.force_allocate_reg(resbox, [arg]) self.mc.MUL(resloc.value, l0.value, l1.value) regalloc.possibly_free_v... |
self.mc.MUL(resloc.value, l0.value, l1.value) | self.mc.MUL(resloc.value, l0.value, r.ip.value) | def emit_op_int_neg(self, op, regalloc, fcond): arg = op.getarg(0) resbox = op.result l0 = regalloc.make_sure_var_in_reg(arg) l1 = regalloc.make_sure_var_in_reg(ConstInt(-1), [arg], imm_fine=False) resloc = regalloc.force_allocate_reg(resbox, [arg]) self.mc.MUL(resloc.value, l0.value, l1.value) regalloc.possibly_free_v... |
if isinstance(res, BorrowedPair): | if res is None: return res elif isinstance(res, BorrowedPair): | def unwrapper(space, *args): from pypy.module.cpyext.pyobject import Py_DecRef from pypy.module.cpyext.pyobject import make_ref, from_ref from pypy.module.cpyext.pyobject import BorrowedPair newargs = () to_decref = [] assert len(args) == len(api_function.argtypes) for i, (ARG, is_wrapped) in types_names_enum_ui: input... |
T_KEY_MASK = 0xFF000000 T_KEY_VALUE = 0x7A000000 | T_KEY_MASK = intmask(0xFF000000) T_KEY_VALUE = intmask(0x7A000000) | def set_query_functions(self, gc): gc.set_query_functions( self.q_is_varsize, self.q_has_gcptr_in_varsize, self.q_is_gcarrayofgcptr, self.q_finalizer, self.q_offsets_to_gc_pointers, self.q_fixed_size, self.q_varsize_item_sizes, self.q_varsize_offset_to_variable_part, self.q_varsize_offset_to_length, self.q_varsize_offs... |
while n > 0: | action.reset_ticker(n) while True: | def f(n): x = X() while n > 0: myjitdriver.can_enter_jit(n=n, x=x) myjitdriver.jit_merge_point(n=n, x=x) x.foo = n n -= 1 if action.get() != 0: break action.set(0) return 42 |
if action.get() != 0: | if action.decrement_ticker(1) < 0: | def f(n): x = X() while n > 0: myjitdriver.can_enter_jit(n=n, x=x) myjitdriver.jit_merge_point(n=n, x=x) x.foo = n n -= 1 if action.get() != 0: break action.set(0) return 42 |
action.set(0) | def f(n): x = X() while n > 0: myjitdriver.can_enter_jit(n=n, x=x) myjitdriver.jit_merge_point(n=n, x=x) x.foo = n n -= 1 if action.get() != 0: break action.set(0) return 42 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.