rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
while hlist.handler: | while hlist.handler is not None: | def HandlerDispatch(self, req): """ This is the handler dispatcher. """ |
module = apache.import_module(module_name, autoreload=autoreload, log=log, path=[path]) | try: module = apache.import_module(module_name, autoreload=autoreload, log=log, path=[path]) except ImportError: raise et, ev, etb | def handler(req): req.allow_methods(["GET", "POST"]) if req.method not in ["GET", "POST"]: raise apache.SERVER_RETURN, apache.HTTP_METHOD_NOT_ALLOWED func_path = "" if req.path_info: func_path = req.path_info[1:] # skip first / func_path = func_path.replace("/", ".") if func_path[-1:] == ".": func_path = func_path[:-... |
docroot = self._req.document_root() | def make_cookie(self): | |
c.path = dirpath[len(docroot):] | if dirpath: docroot = self._req.document_root() c.path = dirpath[len(docroot):] else: c.path = '/' | def make_cookie(self): |
if not file or (path and not file in path): raise SERVER_RETURN, HTTP_NOT_FOUND | if not file or (path and not os.path.dirname(file) in path): raise SERVER_RETURN, HTTP_NOT_FOUND | def import_module(module_name, req=None, path=None): """ Get the module to handle the request. If autoreload is on, then the module will be reloaded if it has changed since the last import. """ # Get options debug, autoreload = 0, 1 if req: config = req.get_config() debug = config.has_key("PythonDebug") if config.has_... |
phase=filter.name, hname=handler, debug=debug) | phase="ConnectionHandler", hname=handler, debug=debug) | def ConnectionDispatch(self, conn): |
Replace sys.stdin and stdout with an objects that reead/write to | Replace sys.stdin and stdout with an objects that read/write to | def setup_cgi(req): """ Replace sys.stdin and stdout with an objects that reead/write to the socket, as well as substitute the os.environ. Returns (environ, stdin, stdout) which you must save and then use with restore_nocgi(). """ # save env env = os.environ.copy() si = sys.stdin so = sys.stdout env = build_cgi_env(... |
newpath = eval(config["PythonPath"]) if sys.path != newpath: sys.path = newpath | global _path pathstring = config["PythonPath"] if pathstring != _path: _path = pathstring newpath = eval(pathstring) if sys.path != newpath: sys.path = newpath | def Dispatch(self, req, htype): """ This is the handler dispatcher. """ |
s = '\nERROR mod_python: "%s %s"\n\n' % (htype, hname) | s = '\nMod_python error: "%s %s"\n\n' % (htype, hname) | def ReportError(self, etype, evalue, etb, htype="N/A", hname="N/A", debug=0): |
delim = '' lastCharCarried = False last_bound = boundary + '--' roughBoundaryLength = len(last_bound) + 128 line = req.readline(readBlockSize) lineLength = len(line) if lineLength < roughBoundaryLength: sline = line.strip() else: sline = '' while lineLength > 0 and sline != boundary and sline != last_bound: if not last... | previous_delimiter = '' bound_length = len(boundary) while 1: line = req.readline(readBlockSize) if line[:bound_length] == boundary: return line if line[-2:] == '\r\n': if file is not None: file.write(previous_delimiter) file.write(line[:-2]) previous_delimiter = '\r\n' elif line[-1:] == '\r': assert len(li... | def read_to_boundary(self, req, boundary, file): # # Although technically possible for the boundary to be split by the read, this will # not happen because the readBlockSize is set quite high - far longer than any boundary line # will ever contain. # # lastCharCarried is used to detect the situation where the \r\n is s... |
def init(): | _interpreter = None _server = None def register_cleanup(handler,args=None): _apache.register_cleanup(_interpreter,_server,handler,args) def init(name,server): | def init(): """ This function is called by the server at startup time """ return CallBack() |
result = DECLINED | if result != OK: result = DECLINED | def HandlerDispatch(self, req): """ This is the handler dispatcher. """ |
PythonOption('mod_python.session.session_directory "%s"' % TMP_DIR), | PythonOption('mod_python.session.database_directory "%s"' % TMP_DIR), | def test_psp_error_conf(self): |
result = self._dbmtype.open(self._dbmfile, 'c') | result = self._dbmtype.open(self._dbmfile, 'c', stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP) | def _get_dbm(self): result = self._dbmtype.open(self._dbmfile, 'c') if self._dbmtype is anydbm: self._set_dbm_type() return result |
module = apache.import_module(module_name, req.get_config(), [path]) | try: module = apache.import_module(module_name, req.get_config(), [path]) except ImportError: func_path = module_name module_name = "index" module = apache.import_module(module_name, req.get_config(), [path]) | def handler(req): req.allow_methods(["GET", "POST"]) if req.method not in ["GET", "POST"]: raise apache.SERVER_RETURN, apache.HTTP_METHOD_NOT_ALLOWED func_path = "" if req.path_info: func_path = req.path_info[1:] # skip first / func_path = func_path.replace("/", ".") if func_path[-1:] == ".": func_path = func_path[:-... |
self._fast_timeout = timeout | if timeout: self._fast_timeout = timeout else: self._fast_timeout = Session.DFT_TIMEOUT | def __init__(self, req, sid=0, secret=None, timeout=0, lock=1, fast_cleanup=True, verify_cleanup=False): opts = req.get_options() self._sessdir = opts.get('FileSessionDir',tempdir) self._fast_cleanup = fast_cleanup self._verify_cleanup = verify_cleanup # FIXME - what happens to fast_cleanup when timeout = 0??? self._... |
self._req.log_error('lock file %s' % self._sid) | def lock_file(self): # self._lock = 1 indicates that session locking is turned on, # so let BaseSession handle it. # Otherwise, explicitly acquire a lock for the file manipulation. if not self._locked: self._req.log_error('lock file %s' % self._sid) _apache._global_lock(self._req.server, self._sid) self._locked = 1 | |
for m in field.file.__methods__: | for m in dir(field.file): | def __init__(self, field): |
if config["PythonEnablePdb"]: result = pdb.runcall(object, req) | result = pdb.runcall(object, req) | def Dispatch(self, _req, htype): """ This is the handler dispatcher. """ |
print "RRRR", result | def Dispatch(self, _req, htype): """ This is the handler dispatcher. """ | |
return DONE | def ReportError(self, req, etype, evalue, etb, htype="N/A", hname="N/A", debug=0): | |
debug = not config.has_key("PythonDebug") | debug = config.has_key("PythonDebug") | def import_module(module_name, req=None, path=None): """ Get the module to handle the request. If autoreload is on, then the module will be reloaded if it has changed since the last import. """ # get the options autoreload, debug = 1, None if req: config = req.get_config() autoreload = not config.has_key("PythonNoRelo... |
parts = string.split(module_name, '.') for i in range(len(parts)): f, p, d = imp.find_module(parts[i], path) try: mname = string.join(parts[:i+1], ".") module = imp.load_module(mname, f, p, d) finally: if f: f.close() if hasattr(module, "__path__"): path = module.__path__ | module = __import__(module_name) components = string.split(module_name, '.') for cmp in components[1:]: module = getattr(module, cmp) | def import_module(module_name, req=None, path=None): """ Get the module to handle the request. If autoreload is on, then the module will be reloaded if it has changed since the last import. """ # get the options autoreload, debug = 1, None if req: config = req.get_config() autoreload = not config.has_key("PythonNoRelo... |
f = urllib.urlopen(url) print " response: "+f.read() f.close() f = open("%s/logs/error_log" % PARAMS["server_root"]) log = f.read() f.close() if log.find("This is a test message") == -1: self.fail("Could not find test message in error_log") def test_apache_table(self): print "\n* Testing apache.table()" cfg = "... | return apache.OK def req_allow_methods(req): req.allow_methods(["PYTHONIZE"]) return apache.HTTP_METHOD_NOT_ALLOWED def req_get_basic_auth_pw(req): if (req.phase == "PythonAuthenHandler"): if req.user != "spam": return apache.HTTP_UNAUTHORIZED else: req.write("test ok") return apache.OK def req_get_config(req): ... | def test_apache_log_error(self): |
if (rsp != "[('PythonOptionTest2', 'new_value2'), ('PythonOptionTest2', 'new_value2')]"): | if (rsp != "[('PythonOptionTest2', 'new_value2'), ('PythonOptionTest3', 'new_value3')]"): | def test_PythonOption_remove2(self): |
cache.mtime = 0 | def import_module(self, file, autoreload=None, log=None, path=None): | |
if self._frozen or not autoreload: if cache.mtime == 0: return (cache, True) return (cache, False) | if not cache.reload: if self._frozen or not autoreload: return (cache, False) | def _reload_required(self, modules, label, file, autoreload): |
if mtime != cache.mtime: | if cache.reload or mtime != cache.mtime: | def _reload_required(self, modules, label, file, autoreload): |
if current.mtime == 0: | if current.reload: | def _check_module(self, modules, parent, current, visited, ancestors): |
print >> output, 'FirstAccess: %s' % stime | print >> output, 'Created: %s' % stime | def ReportError(self, etype, evalue, etb, conn=None, req=None, filter=None, phase="N/A", hname="N/A", debug=0): try: try: if str(etype) == "exceptions.IOError" \ and str(evalue)[:5] == "Write": # If this is an I/O error while writing to # client, it is probably better not to try to # write to the cleint even if debu... |
if instance == 1 and (not cache.mtime or \ | if instance == 1 and (cache.reload or \ | def ReportError(self, etype, evalue, etb, conn=None, req=None, filter=None, phase="N/A", hname="N/A", debug=0): try: try: if str(etype) == "exceptions.IOError" \ and str(evalue)[:5] == "Write": # If this is an I/O error while writing to # client, it is probably better not to try to # write to the cleint even if debu... |
elif not cache.mtime or generation > modules.generation: | elif cache.reload or generation > modules.generation: | def ReportError(self, etype, evalue, etb, conn=None, req=None, filter=None, phase="N/A", hname="N/A", debug=0): try: try: if str(etype) == "exceptions.IOError" \ and str(evalue)[:5] == "Write": # If this is an I/O error while writing to # client, it is probably better not to try to # write to the cleint even if debu... |
if not cache.mtime: | if cache.reload: | def ReportError(self, etype, evalue, etb, conn=None, req=None, filter=None, phase="N/A", hname="N/A", debug=0): try: try: if str(etype) == "exceptions.IOError" \ and str(evalue)[:5] == "Write": # If this is an I/O error while writing to # client, it is probably better not to try to # write to the cleint even if debu... |
session_cookie_name = req.get_options().get("session_cookie_name",COOKIE_NAME) | def __init__(self, req, sid=None, secret=None, lock=1, timeout=0): | |
self._sessdir = opts.get('session_directory', tempdir) | self._sessdir = os.path.join(opts.get('session_directory', tempdir), 'mp_sess') | def __init__(self, req, sid=0, secret=None, timeout=0, lock=1, fast_cleanup=-1, verify_cleanup=-1): opts = req.get_options() |
boundary = "============"+''.join(random.choice('0123456789') for x in range(10))+'==' | boundary = "------------"+''.join( [ random.choice('0123456789') for x in range(10) ] )+'--' | def vhost_post_multipart_form_data(self, vhost, path="/tests.py",variables={}, files={}): # variables is a { name : value } dict # files is a { name : (filename, content) } dict |
content = ''.join(chr(random.choice(xrange(256))) for x in xrange(1024*1024)) import md5 | content = ''.join( [ chr(random.choice(xrange(256))) for x in xrange(1024*1024) ] ) | def test_fileupload(self): print "\n * Testing 1 MB file upload support" |
self.fail('1 MB file upload failed, its contents was corrupted (%s)'%rsp) print " * Testing tricky file upload support" | self.fail('1 MB file upload failed, its contents were corrupted (%s)'%rsp) def test_fileupload_embedded_cr_conf(self): c = VirtualHost("*", ServerName("test_fileupload"), DocumentRoot(DOCUMENT_ROOT), Directory(DOCUMENT_ROOT, SetHandler("mod_python"), PythonHandler("tests::fileupload"), PythonDebug("On"))) return str... | def test_fileupload(self): print "\n * Testing 1 MB file upload support" |
+ 'b'*(65368-1) + '\r' | + 'b'*(readBlockSize-1) + '\r' | def test_fileupload(self): print "\n * Testing 1 MB file upload support" |
self.fail('tricky file upload failed, its contents was corrupted (%s)'%rsp) | self.fail('file upload embedded \\r test failed, its contents were corrupted (%s)'%rsp) | def test_fileupload(self): print "\n * Testing 1 MB file upload support" |
if ctype == "application/x-www-form-urlencoded": | if ctype.startswith("application/x-www-form-urlencoded"): | def __init__(self, req, keep_blank_values=0, strict_parsing=0, file_callback=None, field_callback=None): # # Whenever readline is called ALWAYS use the max size EVEN when not expecting a long line. # - this helps protect against malformed content from exhausting memory. # |
if ctype[:10] != "multipart/": | if not ctype.startswith("multipart/"): | def __init__(self, req, keep_blank_values=0, strict_parsing=0, file_callback=None, field_callback=None): # # Whenever readline is called ALWAYS use the max size EVEN when not expecting a long line. # - this helps protect against malformed content from exhausting memory. # |
methods = field.file.__methods__ for m in methods: self.__dict__[m] = methods[m] | for m in field.file.__methods__: self.__dict__[m] = getattr(field.file, m) | def __init__(self, field): |
req.cleanup_data = "test ok" req.server.register_cleanup(req, cleanup, req) | req.server.register_cleanup(req, server_cleanup, "test ok") | def srv_register_cleanup(req): req.cleanup_data = "test ok" req.server.register_cleanup(req, cleanup, req) req.write("registered server cleanup that will write to log") return apache.OK |
req.cleanup_data = "test 2 ok" apache.register_cleanup(cleanup, req) | apache.register_cleanup(req.interpreter, req.server, server_cleanup, "test 2 ok") | def apache_register_cleanup(req): req.cleanup_data = "test 2 ok" apache.register_cleanup(cleanup, req) req.write("registered server cleanup that will write to log") return apache.OK |
def __init__(self): self.req = None | def __init__(self): self.req = None | |
req = Request(_req) else: req = _req._Request | _req._Request = Request(_req) req = _req._Request | def Dispatch(self, _req, htype): """ This is the handler dispatcher. """ |
result = self.ReportError(exc_type, exc_value, exc_traceback, | result = self.ReportError(req, exc_type, exc_value, exc_traceback, | def Dispatch(self, _req, htype): """ This is the handler dispatcher. """ |
_apache._global_lock(srv, "pspcache") | _apache._global_lock(srv, None, 0) | def dbm_cache_store(srv, dbmfile, filename, mtime, val): dbm_type = dbm_cache_type(dbmfile) _apache._global_lock(srv, "pspcache") try: dbm = dbm_type.open(dbmfile, 'c') dbm[filename] = "%d %s" % (mtime, code2str(val)) finally: try: dbm.close() except: pass _apache._global_unlock(srv, "pspcache") |
_apache._global_unlock(srv, "pspcache") | _apache._global_unlock(srv, None, 0) | def dbm_cache_store(srv, dbmfile, filename, mtime, val): dbm_type = dbm_cache_type(dbmfile) _apache._global_lock(srv, "pspcache") try: dbm = dbm_type.open(dbmfile, 'c') dbm[filename] = "%d %s" % (mtime, code2str(val)) finally: try: dbm.close() except: pass _apache._global_unlock(srv, "pspcache") |
_apache._global_lock(srv, "pspcache") | _apache._global_lock(srv, None, 0) | def dbm_cache_get(srv, dbmfile, filename, mtime): dbm_type = dbm_cache_type(dbmfile) _apache._global_lock(srv, "pspcache") try: dbm = dbm_type.open(dbmfile, 'c') try: entry = dbm[filename] t, val = entry.split(" ", 1) if long(t) == mtime: return str2code(val) except KeyError: return None finally: try: dbm.close() exce... |
_apache._global_unlock(srv, "pspcache") | _apache._global_unlock(srv, None, 0) | def dbm_cache_get(srv, dbmfile, filename, mtime): dbm_type = dbm_cache_type(dbmfile) _apache._global_lock(srv, "pspcache") try: dbm = dbm_type.open(dbmfile, 'c') try: entry = dbm[filename] t, val = entry.split(" ", 1) if long(t) == mtime: return str2code(val) except KeyError: return None finally: try: dbm.close() exce... |
result = self.ReportError(etype, value, traceback, req=req, | result = self.ReportError(etype, value, traceback, req=req, filter=filter, | def FilterDispatch(self, filter): |
result = self.ReportError(exc_type, exc_value, exc_traceback, req=req, | result = self.ReportError(exc_type, exc_value, exc_traceback, req=req, filter=filter, | def FilterDispatch(self, filter): |
def ReportError(self, etype, evalue, etb, req=None, srv=None, | def ReportError(self, etype, evalue, etb, req=None, filter=None, srv=None, | def ReportError(self, etype, evalue, etb, req=None, srv=None, phase="N/A", hname="N/A", debug=0): |
req.write(s) | if filter: filter.write(s) filter.flush() else: req.write(s) | def ReportError(self, etype, evalue, etb, req=None, srv=None, phase="N/A", hname="N/A", debug=0): |
if isinstance(item.file, FileType): | if isinstance(item.file, FileType) or \ isinstance(getattr(item.file, 'file', None), FileType): | def __getitem__(self, key): """Dictionary style indexing.""" if self.list is None: raise TypeError, "not indexable" found = [] for item in self.list: if item.name == key: if isinstance(item.file, FileType): found.append(item) else: found.append(StringField(item.value)) if not found: raise KeyError, key if len(found) ==... |
if isinstance(item.file, FileType): | if isinstance(item.file, FileType) or \ isinstance(getattr(item.file, 'file', None), FileType): | def getfirst(self, key, default=None): """ return the first value received """ for item in self.list: if item.name == key: if isinstance(item.file, FileType): return item else: return StringField(item.value) return default |
if isinstance(item.file, FileType): | if isinstance(item.file, FileType) or \ isinstance(getattr(item.file, 'file', None), FileType): | def getlist(self, key): """ return a list of received values """ if self.list is None: raise TypeError, "not indexable" found = [] for item in self.list: if item.name == key: if isinstance(item.file, FileType): found.append(item) else: found.append(StringField(item.value)) return found |
req.log_error('FileSession cleanup: another process is already running.', | mtime = os.stat(lockfile).st_mtime if mtime < (time.time() - 3600): req.log_error('FileSession cleanup: stale lockfile found - deleting it', apache.APLOG_NOTICE) os.remove(lockfile) else: req.log_error('FileSession cleanup: another process is already running', | def filesession_cleanup(data): # There is a small chance that a the cleanup for a given session file # may occur at the exact time that the session is being accessed by # another request. It is possible under certain circumstances for that # session file to be saved in another request only to immediately deleted # by t... |
c = Class(key, val) result[key] = c | c = Class(l_key, val) result[l_key] = c | def _parseCookie(str, Class): # XXX problem is we should allow duplicate # strings result = {} # max-age is a problem because of the '-' # XXX there should be a more elegant way valid = Cookie._valid_attr + ("max-age",) c = None matchIter = _cookiePattern.finditer(str) for match in matchIter: key, val = match.grou... |
result, handler = HTTP_INTERNAL_SERVER_ERROR, "" | result = HTTP_INTERNAL_SERVER_ERROR | def HandlerDispatch(self, _req): """ This is the handler dispatcher. """ |
phase=phase, hname=handler, | phase=_req.phase, hname=hlist.handler, | def HandlerDispatch(self, _req): """ This is the handler dispatcher. """ |
phase=phase, hname=handler, debug=debug) | phase=_req.phase, hname=hlist.handler, debug=debug) | def HandlerDispatch(self, _req): """ This is the handler dispatcher. """ |
if not server.timeout in (5000000, 300000000): self.fail("server.timeout should be 5000000 or 300000000") | if not server.timeout in (5.0, 300.0): self.fail("server.timeout should be 5.0 or 300.0") | def test_server_members(self): |
if server.keep_alive_timeout != 15000000: self.fail("server.keep_alive_timeout should be 15000000") | if server.keep_alive_timeout != 15.0: self.fail("server.keep_alive_timeout should be 15.0") | def test_server_members(self): |
if exists(req.filename): path, filename = split(req.filename) if not filename: req.filename = join(path, 'index.py') if not req.path_info or req.path_info=='/': func_path = 'index' | path,module_name = os.path.split(req.filename) if not module_name: module_name = 'index' suffixes = ['py'] suffixes += req.get_addhandler_exts().split() if req.extension: suffixes.append(req.extension[1:]) exp = '\\.' + '$|\\.'.join(suffixes) + '$' suff_matcher = re.compile(exp) module_name = suff_matcher... | def handler(req): req.allow_methods(["GET", "POST", "HEAD"]) if req.method not in ["GET", "POST", "HEAD"]: raise apache.SERVER_RETURN, apache.HTTP_METHOD_NOT_ALLOWED if exists(req.filename): # The file or directory exists, so we have a request of the form : # /directory/[module][/func_path] # we check whether there... |
func_path = req.path_info[1:] else: if isfile(req.filename+'.py'): req.filename += '.py' if not req.path_info or req.path_info=='/': func_path = 'index' else: func_path = req.path_info[1:] else: path, func_path = split(req.filename) req.filename = join(path, 'index.py') if req.path_info: func_pat... | func_path = module_name module_name = 'index' req.filename = path + '/' + module_name + '.py' if not exists(req.filename): raise apache.SERVER_RETURN, apache.HTTP_NOT_FOUND if not func_path: func_path = 'index' func_path = func_path.replace('/', '.') | def handler(req): req.allow_methods(["GET", "POST", "HEAD"]) if req.method not in ["GET", "POST", "HEAD"]: raise apache.SERVER_RETURN, apache.HTTP_METHOD_NOT_ALLOWED if exists(req.filename): # The file or directory exists, so we have a request of the form : # /directory/[module][/func_path] # we check whether there... |
func_path = func_path.replace('/', '.') if func_path[-1:] == ".": func_path = func_path[:-1] | def handler(req): req.allow_methods(["GET", "POST", "HEAD"]) if req.method not in ["GET", "POST", "HEAD"]: raise apache.SERVER_RETURN, apache.HTTP_METHOD_NOT_ALLOWED if exists(req.filename): # The file or directory exists, so we have a request of the form : # /directory/[module][/func_path] # we check whether there... | |
"Return a packed binary string representing an IP packet " "with the IP and transport-layer checksums set." | def ip_checksum(packet): "Return a packed binary string representing an IP packet " "with the IP and transport-layer checksums set." return _dnet.__ip_checksum(packet) | |
show_hide = self.SHOW_HIDE_INSTRUMENTATION | show_hide = self.SHOW_HIDE_INSTRUMENTATION.format( self._prefix[1]) | def _make_table_for_diff(self, diff): """Assumes that we should show the table for the diff""" self._last_collapsed = False table = self.make_table(diff) if self._last_collapsed: show_hide = self.SHOW_HIDE_INSTRUMENTATION table = '{0}{1}{0}'.format(show_hide, table) return table |
if key.startswith("T:"): param=key[2:] f=param.find(":") if f>0: tformat=param[f+1:] param=param[:f] else: tformat="%H:%M" if params.has_key(param): t=params[param] elif param=="now": t=time.localtime() else: format=format.replace("%%(%s)" % key, "%%%%(%s)" % key) continue params=params.copy() params[key]=time.strftime... | if key.find(":")>0: format=self.process_format_param(format,key,params) | def do_format_string(self,format,attr,params): m=attr_sel_re.match(format) if m: format=m.group("before") next_attr=m.group("attr") next=m.group("after") else: next=None |
format=format.replace("%%(%s)" % key,"%%%%(%s)" % key) | val=self.find_format_param(key,params) if not val: format=self.quote_format_param(format,key) | def do_format_string(self,format,attr,params): m=attr_sel_re.match(format) if m: format=m.group("before") next_attr=m.group("attr") next=m.group("after") else: next=None |
if not self.settings["backup_config"]: | if not self.settings["backup_config"] and bakfilename: | def save(self,filename=None): if filename is None: filename=self.config_file if not os.path.split(filename)[0]: filename=os.path.join(self.home_dir,filename) self.info(u"Saving settings to "+filename) tmpfilename=filename+".tmp" try: f=file(tmpfilename,"w") except IOError,e: self.error(u"Couldn't open config file: "+st... |
self.settings={"layout":"plain"} | self.settings={"layout":"plain","disconnect_timeout":10} | def __init__(self): pyxmpp.Client.__init__(self) commands.CommandHandler.__init__(self,global_commands) self.settings={"layout":"plain"} self.available_settings=global_settings self.plugin_dirs=["cjc/plugins"] self.plugins={} self.event_handlers={} self.user_info={} self.info_handlers={} self.exiting=0 self.ui_thread=N... |
raise Exit | reason=args.all() args.finish() self.exit_request(reason) | def cmd_quit(self,args): raise Exit |
while not self.exiting: | while not self.exit_time(): | def ui_loop(self): while not self.exiting: try: self.screen.keypressed() except Exit: self.exiting=1 except KeyboardInterrupt,SystemExit: self.exiting=1 raise |
except Exit: self.exiting=1 except KeyboardInterrupt,SystemExit: self.exiting=1 raise | except (KeyboardInterrupt,SystemExit),e: self.exit_request(str(e)) self.print_exception() print >>logfile,"UI loop exiting" | def ui_loop(self): while not self.exiting: try: self.screen.keypressed() except Exit: self.exiting=1 except KeyboardInterrupt,SystemExit: self.exiting=1 raise |
while not self.exiting: self.stream_cond.acquire() | while not self.exit_time(): self.state_changed.acquire() | def stream_loop(self): while not self.exiting: self.stream_cond.acquire() stream=self.stream if not stream: self.stream_cond.wait(1) stream=self.stream self.stream_cond.release() if not stream: continue try: self.stream.loop_iter(1) except KeyboardInterrupt,SystemExit: self.exiting=1 raise |
self.stream_cond.wait(1) | self.state_changed.wait(1) | def stream_loop(self): while not self.exiting: self.stream_cond.acquire() stream=self.stream if not stream: self.stream_cond.wait(1) stream=self.stream self.stream_cond.release() if not stream: continue try: self.stream.loop_iter(1) except KeyboardInterrupt,SystemExit: self.exiting=1 raise |
self.stream_cond.release() | self.state_changed.release() | def stream_loop(self): while not self.exiting: self.stream_cond.acquire() stream=self.stream if not stream: self.stream_cond.wait(1) stream=self.stream self.stream_cond.release() if not stream: continue try: self.stream.loop_iter(1) except KeyboardInterrupt,SystemExit: self.exiting=1 raise |
except KeyboardInterrupt,SystemExit: self.exiting=1 raise | except (KeyboardInterrupt,SystemExit),e: self.exit_request(unicode(str(e))) self.print_exception() print >>logfile,"Stream loop exiting" | def stream_loop(self): while not self.exiting: self.stream_cond.acquire() stream=self.stream if not stream: self.stream_cond.wait(1) stream=self.stream self.stream_cond.release() if not stream: continue try: self.stream.loop_iter(1) except KeyboardInterrupt,SystemExit: self.exiting=1 raise |
while not self.exiting: try: time.sleep(1) except KeyboardInterrupt,SystemExit: self.exiting=1 raise def loop(self,timeout): while 1: fdlist=[sys.stdin.fileno()] if self.stream and self.stream.socket: fdlist.append(self.stream.socket) id,od,ed=select.select(fdlist,[],fdlist,timeout) if sys.stdin.fileno() in id: while ... | while not self.exit_time(): try: self.state_changed.acquire() self.state_changed.wait(1) self.state_changed.release() except (KeyboardInterrupt,SystemExit),e: self.exit_request(unicode(str(e))) self.print_exception() print >>logfile,"Main loop exiting" | def main_loop(self): while not self.exiting: try: time.sleep(1) except KeyboardInterrupt,SystemExit: self.exiting=1 raise |
"messaage buffer",self) | "message buffer",self) | def __init__(self,plugin,peer,thread): self.plugin=plugin self.peer=peer self.thread=thread if peer: self.buffer=ui.TextBuffer(plugin.cjc.theme_manager,{"peer":self.peer}, "message.descr-per-user","message buffer",self) else: self.buffer=ui.TextBuffer(plugin.cjc.theme_manager,{},"message.descr", "messaage buffer",self)... |
self.win.addstr(0,self.w-2,self.content[self.offset+self.w-2]) | s=self.content[self.offset+self.w-2] self.win.addstr(0,self.w-2,s.encode(self.screen.encoding,"replace")) | def after_del(self): if len(self.content)-self.offset<self.w-1: self.win.move(0,self.pos-self.offset) return self.win.addstr(0,self.w-2,self.content[self.offset+self.w-2]) if len(self.content)-self.offset==self.w-1: self.win.clrtoeol() else: self.right_scroll_mark() self.win.move(0,self.pos-self.offset) |
self.redraw() | self.offset=0 if self.pos>self.offset+self.w-2: self.scroll_right() else: self.redraw() | def key_up(self): if self.history_pos>=len(self.history): curses.beep() return if self.history_pos==0: self.saved_content=self.content self.history_pos+=1 self.content=self.history[-self.history_pos] self.pos=len(self.content) self.redraw() |
self.redraw() | self.offset=0 if self.pos>self.offset+self.w-2: self.scroll_right() else: self.redraw() | def key_down(self): if self.history_pos<=0: curses.beep() return self.history_pos-=1 if self.history_pos==0: if self.saved_content: self.content=self.saved_content else: self.content=u"" else: self.content=self.history[-self.history_pos] self.pos=len(self.content) self.pos=len(self.content) self.redraw() |
self.win.addstr(self.content[self.offset+1:self.offset+self.w-1]) | s=self.content[self.offset+1:self.offset+self.w-1] self.win.addstr(s.encode(self.screen.encoding,"replace")) | def update(self,now=1,refresh=0): self.screen.lock.acquire() try: if refresh: if self.offset>0: self.left_scroll_mark() self.win.addstr(self.content[self.offset+1:self.offset+self.w-1]) else: self.win.addstr(0,0,self.content[:self.w-1]) self.win.clrtoeol() self.right_scroll_mark() self.win.move(0,self.pos-self.offset) ... |
self.win.addstr(0,0,self.content[:self.w-1]) | s=self.content[:self.w-1] self.win.addstr(0,0,s.encode(self.screen.encoding,"replace")) | def update(self,now=1,refresh=0): self.screen.lock.acquire() try: if refresh: if self.offset>0: self.left_scroll_mark() self.win.addstr(self.content[self.offset+1:self.offset+self.w-1]) else: self.win.addstr(0,0,self.content[:self.w-1]) self.win.clrtoeol() self.right_scroll_mark() self.win.move(0,self.pos-self.offset) ... |
"buffer_preference": ("Preference of chat buffers when switching to the next active buffer. If 0 then the buffer is not even shown in active buffer list.",int), | "buffer_preference": ("Preference of roster buffers when switching to the next active buffer. If 0 then the buffer is not even shown in active buffer list.",int), | def __init__(self,app,name): PluginBase.__init__(self,app,name) self.available_settings={ "show": ("Which items show - list of 'available','unavailable','chat'," "'online','away','xa' or 'all'",list,self.set_show), "buffer_preference": ("Preference of chat buffers when switching to the next active buffer. If 0 then the... |
self.cjc.set_user_info(fr,"presence",stanza.copy()) self.compute_current_resource(fr.bare()) self.cjc.send_event("presence changed",fr) | def presence_available(self,stanza): fr=stanza.get_from() p=self.cjc.get_user_info(fr,"presence") if (not p or p!=stanza) and self.settings.get("show_changes"): self.cjc.status_buf.append_themed("presence.available",{"user":fr}) self.cjc.status_buf.update() else: self.debug(fr.as_unicode()+u" is unavailable") self.cjc.... | |
except: | except Exception,e: | def command(self,cmd,args): if self.command_aliases.has_key(cmd): cmd=self.command_aliases[cmd] |
self.__logger.debug("set_user_info(%r,%r,%r)" % (jid, var, val)) | if isinstance(val, pyxmpp.Stanza): self.__logger.debug("set_user_info(%r,%r, stanza:%r)" % (jid, var, val.serialize())) else: self.__logger.debug("set_user_info(%r,%r,%r)" % (jid, var, val)) | def set_user_info(self, jid, var, val): self.__logger.debug("set_user_info(%r,%r,%r)" % (jid, var, val)) if not jid.resource: return self.set_bare_user_info(jid, var, val) bare = jid.bare() if self.user_info.has_key(bare): uinf = self.user_info[bare] if not uinf.has_key("resources"): uinf["resources"] = {} else: uinf =... |
nicks = ','.join(self.room_state.users.keys()) self.buffer.append(nicks) | nicks = u','.join(self.room_state.users.keys()) self.buffer.append(nicks + u"\n") | def cmd_who(self, args): nicks = ','.join(self.room_state.users.keys()) self.buffer.append(nicks) self.buffer.update() |
conv.buffer.update() | conv.buffer.update_info(conv.fparams) | def ev_presence_changed(self,event,arg): key=arg.bare().as_unicode() if not self.conversations.has_key(key): return for conv in self.conversations[key]: if conv.peer==arg or conv.peer==arg.bare(): conv.buffer.update() |
self.__logger.info(u"Authenticating as %s..." % (arg,)) | self.__logger.info(u"Authenticating as %s..." % (unicode(arg),)) | def stream_state_changed(self,state,arg): if state=="resolving": self.__logger.info(u"Resolving %r..." % (arg,)) if state=="resolving srv": self.__logger.info(u"Resolving SRV for %r on %r..." % (arg[1],arg[0])) elif state=="connecting": self.__logger.info(u"Connecting to %s:%i..." % (arg[0],arg[1])) elif state=="connec... |
self.__logger.info(u"Binding to resource %s..." % (arg,)) | self.__logger.info(u"Binding to resource %s..." % (unicode(arg),)) | def stream_state_changed(self,state,arg): if state=="resolving": self.__logger.info(u"Resolving %r..." % (arg,)) if state=="resolving srv": self.__logger.info(u"Resolving SRV for %r on %r..." % (arg[1],arg[0])) elif state=="connecting": self.__logger.info(u"Connecting to %s:%i..." % (arg[0],arg[1])) elif state=="connec... |
self.__logger.info(u"Authorized as %s." % (arg,)) | self.__logger.info(u"Authorized as %s." % (unicode(arg),)) | def stream_state_changed(self,state,arg): if state=="resolving": self.__logger.info(u"Resolving %r..." % (arg,)) if state=="resolving srv": self.__logger.info(u"Resolving SRV for %r on %r..." % (arg[1],arg[0])) elif state=="connecting": self.__logger.info(u"Connecting to %s:%i..." % (arg[0],arg[1])) elif state=="connec... |
self.__logger.info(u"Doing TLS handshake with %s." % (arg,)) | self.__logger.info(u"Doing TLS handshake with %s." % (unicode(arg),)) | def stream_state_changed(self,state,arg): if state=="resolving": self.__logger.info(u"Resolving %r..." % (arg,)) if state=="resolving srv": self.__logger.info(u"Resolving SRV for %r on %r..." % (arg[1],arg[0])) elif state=="connecting": self.__logger.info(u"Connecting to %s:%i..." % (arg[0],arg[1])) elif state=="connec... |
for u in usage: | for u in cmd.usage: | def cmd_help(self,args): cmd=args.shift() if not cmd: self.info("Available commands:") for tb in ui.cmdtable.command_tables: tname=tb.name[0].upper()+tb.name[1:] if tb.active: active="active" else: active="inactive" self.info(" %s commands (%s):" % (tname,active)) for cmd in tb.get_commands(): self.info(u" /"+cmd.n... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.