rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
"final" or not (overrides -f and -i options)
"final" or not
def usage (with_help = False): print >> sys.stderr, "Usage: %s [OPTIONS] [XMLFILE]..." % (sys.argv[0]) if (with_help): print >> sys.stderr, """
tmp = dtd.serialize()
tmp = dtd.serialize('utf-8')
def normalizeString(text, ignorewhitespace = 1): """Normalizes string to be used as key for gettext lookup. Removes all unnecessary whitespace.""" if not ignorewhitespace: return text try: # Lets add document DTD so entities are resolved dtd = doc.intSubset() tmp = dtd.serialize() tmp = tmp + '<norm>%s</norm>' % text ...
text = node.serialize()
text = node.serialize('utf-8')
def stringForEntity(node): """Replaces entities in the node.""" text = node.serialize() try: # Lets add document DTD so entities are resolved dtd = node.doc.intSubset() tmp = dtd.serialize() + '<norm>%s</norm>' % text next = 1 except: tmp = '<norm>%s</norm>' % text next = 0 ctxt = libxml2.createDocParserCtxt(tmp) if e...
tmp = dtd.serialize() + '<norm>%s</norm>' % text
tmp = dtd.serialize('utf-8') + '<norm>%s</norm>' % text
def stringForEntity(node): """Replaces entities in the node.""" text = node.serialize() try: # Lets add document DTD so entities are resolved dtd = node.doc.intSubset() tmp = dtd.serialize() + '<norm>%s</norm>' % text next = 1 except: tmp = '<norm>%s</norm>' % text next = 0 ctxt = libxml2.createDocParserCtxt(tmp) if e...
return gt.gettext(text)
return gt.gettext(text.decode('utf-8'))
def getTranslation(text, spacepreserve = 0): """Returns a translation via gettext for specified snippet. text should be a string to look for, spacepreserve set to 1 when spaces should be preserved. """ text = normalizeString(text, not spacepreserve) if (text.strip() == ''): return text file = open(mofile, "rb") if fil...
params += p.serialize()
params += p.serialize('utf-8')
def startTagForNode(node): if not node: return 0 result = node.name params = '' if node.properties: for p in node.properties: if p.type == 'attribute': # FIXME: This part sucks params += p.serialize() return result+params
tmp = dtd.serialize()
tmp = dtd.serialize('utf-8')
def replaceNodeContentsWithText(node,text): """Replaces all subnodes of a node with contents of text treated as XML.""" if node.children: starttag = node.name #startTagForNode(node) endtag = endTagForNode(node) try: # Lets add document DTD so entities are resolved dtd = doc.intSubset() tmp = '' if expand_entities: # FI...
return node.serialize("utf-8")
return node.serialize('utf-8')
def doSerialize(node): """Serializes a node and its children, emitting PO messages along the way. node is the node to serialize, first indicates whether surrounding tags should be emitted as well. """ if ignoreNode(node): return '' elif not node.children: return node.serialize("utf-8") elif node.type == 'entity_ref':...
params += p.serialize('utf-8')
try: nsprop = p.ns().name + ":" + p.name except: nsprop = p.name params += " %s=\"%s\"" % (nsprop, p.doc.encodeEntitiesReentrant(p.content))
def startTagForNode(node): if not node: return 0 result = node.name params = '' if node.properties: for p in node.properties: if p.type == 'attribute': # FIXME: This part sucks params += p.serialize('utf-8') return result+params
starttag = node.name
starttag = startTagForNode(node)
def replaceNodeContentsWithText(node,text): """Replaces all subnodes of a node with contents of text treated as XML.""" if node.children: starttag = node.name #startTagForNode(node) endtag = endTagForNode(node) # Lets add document DTD so entities are resolved tmp = '<?xml version="1.0" encoding="utf-8" ?>' try: dtd =...
add = newelem.children
def replaceNodeContentsWithText(node,text): """Replaces all subnodes of a node with contents of text treated as XML.""" if node.children: starttag = node.name #startTagForNode(node) endtag = endTagForNode(node) # Lets add document DTD so entities are resolved tmp = '<?xml version="1.0" encoding="utf-8" ?>' try: dtd =...
tmp = dtd.serialize() + '<norm>%s</norm>' % text
tmp = '' if expand_entities: tmp = dtd.serialize() tmp = tmp + '<norm>%s</norm>' % text
def normalizeString(text, ignorewhitespace = 1): """Normalizes string to be used as key for gettext lookup. Removes all unnecessary whitespace.""" if not ignorewhitespace: return text try: # Lets add document DTD so entities are resolved dtd = doc.intSubset() tmp = dtd.serialize() + '<norm>%s</norm>' % text except: tm...
ctxt.replaceEntities(1)
if expand_entities: ctxt.replaceEntities(1)
def stringForEntity(node): """Replaces entities in the node.""" text = node.serialize() try: # Lets add document DTD so entities are resolved dtd = node.doc.intSubset() tmp = dtd.serialize() + '<norm>%s</norm>' % text next = 1 except: tmp = '<norm>%s</norm>' % text next = 0 ctxt = libxml2.createDocParserCtxt(tmp) ctxt...
return node.serialize()
return node.serialize('utf-8')
def doSerialize(node): """Serializes a node and its children, emitting PO messages along the way. node is the node to serialize, first indicates whether surrounding tags should be emitted as well. """ if ignoreNode(node): return '' elif not node.children: return node.serialize("utf-8") elif node.type == 'entity_ref': ...
opts, args = getopt.getopt(args, 'avhm:t:o:p:u:r:', ['automatic-tags','version', 'help', 'mode=', 'translation=',
opts, args = getopt.getopt(args, 'avhkm:t:o:p:u:r:', ['automatic-tags','version', 'help', 'keep-entities', 'mode=', 'translation=',
def xml_error_handler(arg, ctxt): pass
print "turn socket",num,"off" print "/usr/local/bin/sispmctl -f "+str(num) os.system("/usr/local/bin/sispmctl -f "+str(num))
os.system("/usr/local/bin/sispmctl -q -f "+str(num))
def socket_off(num): print "turn socket",num,"off" print "/usr/local/bin/sispmctl -f "+str(num) os.system("/usr/local/bin/sispmctl -f "+str(num))
print "turn socket",num,"on" os.system("/usr/local/bin/sispmctl -o "+str(num))
os.system("/usr/local/bin/sispmctl -q -o "+str(num))
def socket_on(num): print "turn socket",num,"on" os.system("/usr/local/bin/sispmctl -o "+str(num))
print "get state of socket",num
def socket_get_state(num): print "get state of socket",num #fd=os.popen("/usr/local/bin/sispmctl -g "+str(num)) result=0 for line in os.popen("/usr/local/bin/sispmctl -q -n -g "+str(num)).readlines(): print "line: ",line if line[0]=="0": result=1 elif line[0]=="1": result=0 return result
print "line: ",line
def socket_get_state(num): print "get state of socket",num #fd=os.popen("/usr/local/bin/sispmctl -g "+str(num)) result=0 for line in os.popen("/usr/local/bin/sispmctl -q -n -g "+str(num)).readlines(): print "line: ",line if line[0]=="0": result=1 elif line[0]=="1": result=0 return result
print "socket1 clicked"
def socket1_clicked(self): print "socket1 clicked" if self.s1==0: socket_off(1) self.led1.setColor(QColor(255,0,0)) else: socket_on(1) self.led1.setColor(QColor(0,255,0)) self.s1=1-self.s1
print "socket1 clicked"
def socket2_clicked(self): print "socket1 clicked" if self.s2==0: socket_off(2) self.led2.setColor(QColor(255,0,0)) else: socket_on(2) self.led2.setColor(QColor(0,255,0)) self.s2=1-self.s2
print "socket1 clicked"
def socket3_clicked(self): print "socket1 clicked" if self.s3==0: socket_off(3) self.led1.setColor(QColor(255,0,0)) else: socket_on(3) self.led1.setColor(QColor(0,255,0)) self.s3=1-self.s3
print "socket4 clicked"
def socket4_clicked(self): print "socket4 clicked" if self.s4==0: socket_off(4) self.led4.setColor(QColor(255,0,0)) else: socket_on(4) self.led4.setColor(QColor(0,255,0)) self.s4=1-self.s4
if len(sys.argv) == 0 or (len(sys.argv) > 1 and sys.argv[1] != "-remove"):
if len(sys.argv) == 1 or (len(sys.argv) > 1 and sys.argv[1] != "-remove"):
def askForApacheDir(apachediroptions): # try to ask for Apache directory if len(apachediroptions) > 0: # get the most recent version... versionnames = apachediroptions.keys() versionnames.sort() initialdir = apachediroptions[versionnames[-1]] else: initialdir="C:/Program Files/Apache Group/Apache2" # TODO: let the user...
if not req.headers_out.has_key("Set-Cookie"): Cookie.add_cookie(self._req, Cookie.Cookie(session_cookie_name, self._sid))
def __init__(self, req, sid=None, secret=None, lock=1, timeout=0):
exec code in globals(), {"req":req, "session":session, "form":form, "psp":psp}
global_scope = globals().copy() global_scope.update({"req":req, "session":session, "form":form, "psp":psp}) exec code in global_scope
def run_psp(req): dbmcache = None opts = req.get_options() if opts.has_key("PSPDbmCache"): dbmcache = opts["PSPDbmCache"] dir, fname = path_split(req.filename) if not fname: # this is a directory return apache.DECLINED code = load_file(dir, fname, dbmcache, srv=req.server) session = None if "session" in code.co_na...
def parse(filename): return _psp.parse(filename)
class psp: def parse(self, filename): return _psp.parse(filename)
def parse(filename): return _psp.parse(filename)
def __init__(self, req, keep_blank_values=0, strict_parsing=0): self.list = [] if req.args: pairs = parse_qsl(req.args, keep_blank_values) for pair in pairs: file = cStringIO.StringIO(pair[1]) self.list.append(Field(pair[0], file, "text/plain", {}, None, {})) if req.method == "POST": try: clen = int(req.headers_in...
def __init__(self, req, keep_blank_values=0, strict_parsing=0, file_callback=None, field_callback=None): self.list = [] if req.args: pairs = parse_qsl(req.args, keep_blank_values) for pair in pairs: file = cStringIO.StringIO(pair[1]) self.list.append(Field(pair[0], file, "text/plain", {}, None, {})) if req.meth...
def __init__(self, req, keep_blank_values=0, strict_parsing=0):
if os.name == 'nt' and c.path[-1] == '\\': c.path = c.path[:-1]
def make_cookie(self):
return regkey(self.key, subkeyname)
try: return regkey(self.key, subkeyname) except win32api.error: return nullregkey()
def childkey(self, subkeyname): return regkey(self.key, subkeyname)
return win32api.RegQueryValueEx(self.key, valuename)
try: return win32api.RegQueryValueEx(self.key, valuename) except win32api.error: raise AttributeError("Cannot access registry value %r" % (valuename))
def getvalue(self, valuename): return win32api.RegQueryValueEx(self.key, valuename)
win32api.RegCloseKey(self.key)
if hasattr(self, "key"): win32api.RegCloseKey(self.key)
def __del__(self): win32api.RegCloseKey(self.key)
apachekey = regkey(win32con.HKEY_LOCAL_MACHINE, "Software").childkey("Apache Group").childkey("Apache") for versionname in apachekey.subkeynames(): serverroot = apachekey.childkey(versionname).getvalue("ServerRoot") versions[versionname] = serverroot[0]
hklm_key = regkey(win32con.HKEY_LOCAL_MACHINE, "Software").childkey("Apache Group").childkey("Apache") hkcu_key = regkey(win32con.HKEY_CURRENT_USER, "Software").childkey("Apache Group").childkey("Apache") for apachekey in (hklm_key, hkcu_key): for versionname in apachekey.subkeynames(): try: serverroot = apachekey.chil...
def __del__(self): win32api.RegCloseKey(self.key)
if len(sys.argv) == 0 or sys.argv[1] != "-remove":
if len(sys.argv) == 0 or (len(sys.argv) > 1 and sys.argv[1] != "-remove"):
def askForApacheDir(apachediroptions): # try to ask for Apache directory if len(apachediroptions) > 0: # get the most recent version... versionnames = apachediroptions.keys() versionnames.sort() initialdir = apachediroptions[versionnames[-1]] else: initialdir="C:/Program Files/Apache Group/Apache2" # TODO: let the user...
fp = file(filename)
fp = file(filename,'rb')
def do_load(self): self.lock_file() try: try: # TODO : why does this load fails sometimes with an EOFError ? filename = os.path.join(self._sessdir, 'mp_sess_%s' % self._sid) fp = file(filename) try: data = cPickle.load(fp) if (time.time() - data["_accessed"]) <= data["_timeout"]: # Change the file access time to the cu...
fp = file(os.path.join(self._sessdir, 'mp_sess_%s' % self._sid), 'w+')
filename = os.path.join(self._sessdir, 'mp_sess_%s' % self._sid) fp = file(filename, 'wb')
def do_save(self, dict): self.lock_file() try: try: fp = file(os.path.join(self._sessdir, 'mp_sess_%s' % self._sid), 'w+') try: cPickle.dump(dict, fp, 2) finally: fp.close() except: s = cStringIO.StringIO() traceback.print_exc(file=s) s = s.getvalue() self._req.log_error('Error while saving a session : %s'%s) finally: ...
if session:
if session is not None:
def run(self, vars={}):
req.log_error('FileSession cleanup: another process is already running.' % (fast_cleanup,verify_cleanup),
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...
status_file.write('%s %d %d %d %f %d\n' % (stat_version,next_i,expired_file_count,total_file_count, total_time))
status_file.write('%s %d %d %d %f\n' % (stat_version, next_i, expired_file_count, total_file_count, total_time))
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...
print 1
def HandlerDispatch(self, _req): """ This is the handler dispatcher. """ print 1 # be cautious result = HTTP_INTERNAL_SERVER_ERROR
print "here"
def HandlerDispatch(self, _req): """ This is the handler dispatcher. """ print 1 # be cautious result = HTTP_INTERNAL_SERVER_ERROR
filter.flush()
if not filter.closed: filter.flush()
def FilterDispatch(self, filter):
for field in fs.list: if field.filename: val = field else: val = field.value args.setdefault(field.name, []).append(val) for arg in args: if ((type(args[arg]) is ListType) and (len(args[arg]) == 1)): args[arg] = args[arg][0]
def apply_fs_data(object, fs, **args): """ Apply FieldStorage data to an object - the object must be callable. Examine the args, and match then with fs data, then call the object, return the result. """ # add form data to args for field in fs.list: if field.filename: val = field else: val = field.value args.setdefault...
fc = object.__call__.im_func.func_code expected = fc.co_varnames[1:fc.co_argcount]
if type(object.__call__) is MethodType: fc = object.__call__.im_func.func_code expected = fc.co_varnames[1:fc.co_argcount] else: return apply_fs_data(object.__call__, fs, **args) for field in fs.list: if field.filename: val = field else: val = field.value args.setdefault(field.name, []).append(val) for arg in args...
def apply_fs_data(object, fs, **args): """ Apply FieldStorage data to an object - the object must be callable. Examine the args, and match then with fs data, then call the object, return the result. """ # add form data to args for field in fs.list: if field.filename: val = field else: val = field.value args.setdefault...
for sid in sdict: dict = sdict[sid] if (time.time() - dict["_accessed"]) > dict["_timeout"]: del sdict[sid]
for sid in sdict.keys(): try: session = sdict[sid] if (time.time() - session["_accessed"]) > session["_timeout"]: del sdict[sid] except: pass
def mem_cleanup(sdict): for sid in sdict: dict = sdict[sid] if (time.time() - dict["_accessed"]) > dict["_timeout"]: del sdict[sid]
cached = strcache.get(string)
cached = mem_scache.get(string)
def __init__(self, req, filename=None, string=None, vars={}):
self.code = _psp.parsestring(string) strcache.store(string)
source = _psp.parsestring(string) code = compile(source, "__psp__", "exec") mem_scache.store(string,code) self.code = code
def __init__(self, req, filename=None, string=None, vars={}):
hist, val = self.cache[key] self.cache[key] = (hits+1, code)
hits, val = self.cache[key] self.cache[key] = (hits+1, val)
def get(self, key): if self.cache.has_key(key): hist, val = self.cache[key] self.cache[key] = (hits+1, code) return val else: return None
self._sessdir = opts.get('FileSessionDir',tempdir) self._fast_cleanup = fast_cleanup self._verify_cleanup = verify_cleanup self._grace_period = grace_period
self._sessdir = os.path.join(opts.get('session_directory', tempdir), 'mp_sess') self._cleanup_time_limit = int(opts.get('session_cleanup_time_limit',DFT_CLEANUP_TIME_LIMIT)) self._fast_cleanup = true_or_false(opts.get('fast_cleanup', DFT_FAST_CLEANUP)) self._verify_cleanup = true_or_false(opts.get('verify_cleanup', DFT...
def __init__(self, req, sid=0, secret=None, timeout=0, lock=1, fast_cleanup=True, verify_cleanup=False, grace_period=240): opts = req.get_options() self._sessdir = opts.get('FileSessionDir',tempdir) self._fast_cleanup = fast_cleanup self._verify_cleanup = verify_cleanup self._grace_period = grace_period if timeout: s...
'grace_period':self._grace_period}
'grace_period':self._grace_period, 'cleanup_time_limit': self._cleanup_time_limit, }
def do_cleanup(self): data = {'req':self._req, 'sessdir':self._sessdir, 'fast_cleanup':self._fast_cleanup, 'verify_cleanup':self._verify_cleanup, 'timeout':self._cleanup_timeout, 'grace_period':self._grace_period}
filename = os.path.join(self._sessdir, 'mp_sess_%s' % self._sid)
path = os.path.join(self._sessdir, self._sid[0:2]) filename = os.path.join(path, self._sid)
def do_load(self): self.lock_file() try: try: filename = os.path.join(self._sessdir, 'mp_sess_%s' % self._sid) fp = file(filename,'rb') try: data = cPickle.load(fp) if (time.time() - data["_accessed"]) <= data["_timeout"]: # Change the file access time to the current time so the # cleanup does not delete this file befo...
filename = os.path.join(self._sessdir, 'mp_sess_%s' % self._sid)
path = os.path.join(self._sessdir, self._sid[0:2]) if not os.path.exists(path): make_filesession_dirs(self._sessdir) filename = os.path.join(path, self._sid)
def do_save(self, dict): self.lock_file() try: try: filename = os.path.join(self._sessdir, 'mp_sess_%s' % self._sid) fp = file(filename, 'wb') try: cPickle.dump(dict, fp, 2) finally: fp.close() except: s = cStringIO.StringIO() traceback.print_exc(file=s) s = s.getvalue() self._req.log_error('Error while saving a sessio...
os.unlink(os.path.join(self._sessdir, 'mp_sess_%s' % self._sid))
path = os.path.join(self._sessdir, self._sid[0:2]) filename = os.path.join(path, self._sid) os.unlink(filename)
def do_delete(self): self.lock_file() try: try: os.unlink(os.path.join(self._sessdir, 'mp_sess_%s' % self._sid)) except Exception: pass finally: self.unlock_file()
FS_STAT_VERSION = 'MPFS_3.2'
def unlock_file(self): if self._locked and not self._lock: _apache._global_unlock(self._req.server, self._sid) self._locked = 0
req.log_error('Sessions cleanup (fast=%s, verify=%s) ...' % (fast_cleanup,verify_cleanup), apache.APLOG_NOTICE)
cleanup_time_limit = data['cleanup_time_limit'] req.log_error('FileSession cleanup: (fast=%s, verify=%s) ...' % (fast_cleanup,verify_cleanup), apache.APLOG_NOTICE)
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...
req.log_error('filesession_cleanup: another process is already running.')
req.log_error('FileSession cleanup: another process is already running.' % (fast_cleanup,verify_cleanup), apache.APLOG_NOTICE)
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...
count = 0 i = 0 for f in filelist: if not f.startswith('mp_sess_'):
dir_index = range(0,256)[next_i:] for i in dir_index: path = '%s/%s' % (sessdir,'%02x' % i) if not os.path.exists(path):
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...
try: filename = os.path.join(sessdir, f) if fast_cleanup: accessed = os.stat(filename).st_mtime if time.time() - accessed < (timeout + grace_period): continue if fast_cleanup and not verify_cleanup: delete_session = True else: try: fp = file(filename) dict = cPickle.load(fp) if (time.time() - dict['_accessed']) > (dic...
filelist = os.listdir(path) total_file_count += len(filelist) for f in filelist: try: filename = os.path.join(path,f) if fast_cleanup: accessed = os.stat(filename).st_mtime if time.time() - accessed < (timeout + grace_period): continue if fast_cleanup and not verify_cleanup: delete_session = True else: try: fp = file...
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...
if (rsp[3:5] != "=="):
if (rsp[0:2] != "
def test_trans(self):
if cookies.has_key(COOKIE_NAME): self._sid = cookies[COOKIE_NAME].value
session_cookie_name = req.get_options().get("session_cookie_name",COOKIE_NAME) if cookies.has_key(session_cookie_name): self._sid = cookies[session_cookie_name].value
def __init__(self, req, sid=None, secret=None, lock=1, timeout=0):
c = Cookie.SignedCookie(COOKIE_NAME, self._sid,
c = Cookie.SignedCookie(session_cookie_name, self._sid,
def make_cookie(self):
c = Cookie.Cookie(COOKIE_NAME, self._sid)
c = Cookie.Cookie(session_cookie_name, self._sid)
def make_cookie(self):
if sys.modules.has_key(module_name): module = sys.modules[module_name] file = module.__dict__.get("__file__") if not file or (path and not filter(file.startswith, path)):
imp.acquire_lock() try: if sys.modules.has_key(module_name): module = sys.modules[module_name] file = module.__dict__.get("__file__") if not file or (path and not filter(file.startswith, path)): mtime, oldmtime = 0, -1 elif autoreload: oldmtime = module.__dict__.get("__mtime__", 0) mtime = module_mtime(mod...
def import_module(module_name, autoreload=1, log=0, 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. """ # (Re)import if sys.modules.has_key(module_name): # The module has been imported already module = sys.modules[mod...
elif autoreload: oldmtime = module.__dict__.get("__mtime__", 0) mtime = module_mtime(module) else: mtime, oldmtime = 0, 0 else: mtime, oldmtime = 0, -1 if mtime > oldmtime: if log: if path: s = "mod_python: (Re)importing module '%s' with path set to '%s'" % (module_name, path) else: s = "mod_python: (Re)importing m...
if mtime > oldmtime: if log: if path: s = "mod_python: (Re)importing module '%s' with path set to '%s'" % (module_name, path) else: s = "mod_python: (Re)importing module '%s'" % module_name _apache.log_error(s, APLOG_NOERRNO|APLOG_NOTICE) parts = module_name.split('.') for i in range(len(parts)): f, p, d = imp.find_...
def import_module(module_name, autoreload=1, log=0, 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. """ # (Re)import if sys.modules.has_key(module_name): # The module has been imported already module = sys.modules[mod...
raise apache.SERVER_RETURN, apache.HTTP_FORBIDDEN
raise apache.SERVER_RETURN, apache.HTTP_NOTFOUND
def handler(req): # use direct access to _req for speed _req = req._req args = {} # get the path PATH_INFO (everthing after script) if not _req.subprocess_env.has_key("PATH_INFO"): raise apache.SERVER_RETURN, apache.HTTP_NOT_FOUND func_path = _req.subprocess_env["PATH_INFO"][1:] # skip fist / func_path = string.rep...
self._cleanup_timeout = Session.DFT_TIMEOUT
self._cleanup_timeout = DFT_TIMEOUT
def __init__(self, req, sid=0, secret=None, timeout=0, lock=1, fast_cleanup=True, verify_cleanup=False, grace_period=240): opts = req.get_options() self._sessdir = opts.get('FileSessionDir',tempdir) self._fast_cleanup = fast_cleanup self._verify_cleanup = verify_cleanup self._grace_period = grace_period if timeout: s...
if (rsp != "[('PythonOptionTest', 'new_value')]"):
if (rsp != "[('PythonOptionTest', 'new_value'), ('PythonOptionTest2', 'new_value2')]"):
def test_PythonOption_override(self):
if (rsp != "[]"):
if (rsp != "[('PythonOptionTest2', 'new_value2')]"): self.fail(`rsp`) def test_PythonOption_remove2_conf(self): c = VirtualHost("*", ServerName("test_PythonOption_remove2"), DocumentRoot(DOCUMENT_ROOT), Directory(DOCUMENT_ROOT, SetHandler("mod_python"), PythonHandler("tests::PythonOption_items"), PythonOption('Python...
def test_PythonOption_remove(self):
if mtime > oldmtime:
if mtime != oldmtime:
def import_module(module_name, autoreload=1, log=0, 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. """ # nlehuen: this is a big lock, we'll have to refine it later to get better performance. # For now, we'll concentra...
AddHandler("mod_python .py"), DirectoryIndex("/tests.py"),
SetHandler("mod_python"),
def test_req_headers_out_conf(self):
PythonAccessHandler("tests::req_headers_out_access"),
def test_req_headers_out_conf(self):
conn.putrequest("GET", "/", skip_host=1)
conn.putrequest("GET", "/test.py", skip_host=1)
def test_req_headers_out(self):
for k in osenv:
for k in osenv.keys():
def restore_nocgi(sav_env, si, so): """ see setup_cgi() """ osenv = os.environ # restore env for k in osenv: del osenv[k] for k in sav_env: osenv[k] = env[k] sys.stdout = si sys.stdin = so
valid = Cookie._valid_attr + ("max-age",) c = None
def _parse_cookie(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.gro...
if not c: c = Class(key, val) result[key] = c l_key = key.lower() if (l_key in valid or key[0] == '$'): if l_key == "max-age": l_key = "max_age" setattr(c, l_key, val) else: c = Class(l_key, val) result[l_key] = c
if key[0]!='$': result[key] = Class(key, val)
def _parse_cookie(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.gro...
if "__auth__" in func_code.co_names: i = list(func_code.co_names).index("__auth__") __auth__ = func_code.co_consts[i+1] if hasattr(__auth__, "co_name"): __auth__ = new.function(__auth__, func_globals) found_auth = 1 if "__access__" in func_code.co_names: i = list(func_code.co_names).index("__access__") __access__ = f...
def lookup(name): i = None if name in func_code.co_names: i = list(func_code.co_names).index(name) elif func_code.co_argcount < len(func_code.co_varnames): names = func_code.co_varnames[func_code.co_argcount:] if name in names: i = list(names).index(name) if i is not None: return (1, func_code.co_consts[i+1]) return (0...
def process_auth(req, object, realm="unknown", user=None, passwd=None): found_auth, found_access = 0, 0 if hasattr(object, "__auth_realm__"): realm = object.__auth_realm__ func_object = None if type(object) is FunctionType: func_object = object elif type(object) == types.MethodType: func_object = object.im_func if...
path, func_path = os.path.split(req.filename) req.filename = os.path.join(path,'index.py') if req.path_info: func_path = func_path + req.path_info
if os.path.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 = os.path.split(req.filename) req.filename = os.path.join(path,'index.py') if req.path_info: func_path = func_path + r...
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 the file exists, req.finfo is not None if req.finfo: # The file exists, so we have a request of the form : # /directory/[module][/func_path] # we...
f.close()
def test_psp_parser(self):
if os.path.exists(filepath): mod = os.stat(filepath) mtime = mod[stat.ST_MTIME] if os.path.exists(filepath[:-1]) : mod = os.stat(filepath[:-1]) mtime = max(mtime, mod[stat.ST_MTIME])
try: if os.path.exists(filepath): mod = os.stat(filepath) mtime = mod[stat.ST_MTIME] if os.path.exists(filepath[:-1]) : mod = os.stat(filepath[:-1]) mtime = max(mtime, mod[stat.ST_MTIME]) except OSError: pass
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() if config.has_key("PythonAutoReload"): autore...
if int(config.get("PythonEnablePdb", 0)): result = pdb.runcall(object, conn)
pdb_debug = int(config.get("PythonEnablePdb", "0")) one_process = exists_config_define("ONE_PROCESS") if pdb_debug and one_process: debugger = pdb.Pdb() debugger.reset() sys.settrace(debugger.trace_dispatch) try: result = object(conn) finally: debugger.quitting = 1 sys.settrace(None)
def ConnectionDispatch(self, conn):
if int(config.get("PythonEnablePdb", 0)): pdb.runcall(object, filter)
pdb_debug = int(config.get("PythonEnablePdb", "0")) one_process = exists_config_define("ONE_PROCESS") if pdb_debug and one_process: debugger = pdb.Pdb() debugger.reset() sys.settrace(debugger.trace_dispatch) try: result = object(filter) finally: debugger.quitting = 1 sys.settrace(None)
def FilterDispatch(self, filter):
object(filter)
result = object(filter)
def FilterDispatch(self, filter):
if int(config.get("PythonEnablePdb", 0)): result = pdb.runcall(object, req)
pdb_debug = int(config.get("PythonEnablePdb", "0")) one_process = exists_config_define("ONE_PROCESS") if pdb_debug and one_process: debugger = pdb.Pdb() debugger.reset() sys.settrace(debugger.trace_dispatch) try: result = object(req) finally: debugger.quitting = 1 sys.settrace(None)
def HandlerDispatch(self, req): """ This is the handler dispatcher. """
user, passwd = string.split(s, ":")
user, passwd = string.split(s, ":", 1)
def process_auth(req, object, realm="unknown", user=None, passwd=None): found_auth, found_access = 0, 0 # because ap_get_basic insists on making sure that AuthName and # AuthType directives are specified and refuses to do anything # otherwise (which is technically speaking a good thing), we # have to do base64 decodi...
if not hasattr(modules, 'generation'):
if modules.ctime == 0:
def import_module(self, file, autoreload=None, log=None, path=None):
modules.stime = time.time()
modules.ctime = time.time()
def import_module(self, file, autoreload=None, log=None, path=None):
if hasattr(modules, 'generation'): stime = time.asctime(time.localtime(modules.stime))
if modules.ctime != 0: accessed = time.asctime(time.localtime(modules.ctime))
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...
print >> output, 'Accessed: %s' % stime
print >> output, 'Accessed: %s' % accessed
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 len(path): i = 0 print >> output, ' ModulePath: ', for entry in path: if i == 0: if i == (len(path) - 1): print >> output, '%s' % `entry`, else: print >> output, '%s,' % `entry`, else: print >> output print >> output, ' %s' % `entry`, i += 1 print >> output
if path: text = ',\n '.join(map(repr, path)) print >> output, ' ModulePath: %s' % text
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...
children = module.__mp_info__.children
for child in module.__mp_info__.children: entry = modules[child].__mp_info__.file children.append(entry)
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...
children = module.__mp_info__.cache.children dependents = module.__mp_info__.children for entry in dependents: if entry not in children: friends.append(entry) if len(children): i = 0 print >> output, ' Children: ', for child_name in children: child_cache = modules[child_name] entry = child_cache.__mp_info__.file i...
for child in module.__mp_info__.cache.children: entry = modules[child].__mp_info__.file children.append(entry) for child in module.__mp_info__.children: if child not in module.__mp_info__.cache.children:
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...
entry = apache.module_info(child_name).file
entry = modules[child].__mp_info__.file friends.append(entry)
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...
entry = child_name if i == 0: if i == (len(friends) - 1): print >> output, '%s' % `entry`, else: print >> output, '%s,' % `entry`, else: print >> output print >> output, ' %s' % `entry`, i += 1 print >> output
try: entry = apache.module_info(child).file friends.append(entry) except: pass children.sort() friends.sort() if children: text = ',\n '.join(map(repr, children)) print >> output, ' Children: %s' % text if friends: text = ',\n '.join(map(repr, friends)) print >> output, ' Friends:...
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 self.req or (self.req._req != _req): self.req = Request(_req)
if not _req._Request: req = Request(_req) else: req = _req._Request
def Dispatch(self, _req, htype): """ This is the handler dispatcher. """
object = resolve_object(self.req, module, object_str, silent)
object = resolve_object(req, module, object_str, silent)
def Dispatch(self, _req, htype): """ This is the handler dispatcher. """
result = pdb.runcall(object, self.req)
result = pdb.runcall(object, req)
def Dispatch(self, _req, htype): """ This is the handler dispatcher. """
result = object(self.req)
result = object(req)
def Dispatch(self, _req, htype): """ This is the handler dispatcher. """
result = self.ReportError(etype, value, traceback,
result = self.ReportError(req, etype, value, traceback,
def Dispatch(self, _req, htype): """ This is the handler dispatcher. """
def ReportError(self, etype, evalue, etb, htype="N/A", hname="N/A", debug=0):
def ReportError(self, req, etype, evalue, etb, htype="N/A", hname="N/A", debug=0):
def ReportError(self, etype, evalue, etb, htype="N/A", hname="N/A", debug=0):
req = self.req._req
def ReportError(self, etype, evalue, etb, htype="N/A", hname="N/A", debug=0):