Hackfut Security File Manager
Current Path:
/opt/alt/python27/lib/python2.7/site-packages/paste
opt
/
alt
/
python27
/
lib
/
python2.7
/
site-packages
/
paste
/
📁
..
📁
auth
📄
cascade.py
(4.4 KB)
📄
cascade.pyc
(4.37 KB)
📄
cascade.pyo
(4.37 KB)
📄
cgiapp.py
(9.37 KB)
📄
cgiapp.pyc
(8.35 KB)
📄
cgiapp.pyo
(8.14 KB)
📄
cgitb_catcher.py
(3.66 KB)
📄
cgitb_catcher.pyc
(3.76 KB)
📄
cgitb_catcher.pyo
(3.76 KB)
📄
config.py
(4.21 KB)
📄
config.pyc
(5.16 KB)
📄
config.pyo
(5.16 KB)
📁
cowbell
📁
debug
📄
errordocument.py
(13.45 KB)
📄
errordocument.pyc
(12.77 KB)
📄
errordocument.pyo
(12.77 KB)
📁
evalexception
📁
exceptions
📄
fileapp.py
(13.29 KB)
📄
fileapp.pyc
(13.04 KB)
📄
fileapp.pyo
(12.91 KB)
📄
fixture.py
(56.63 KB)
📄
fixture.py.stdlib
(56.71 KB)
📄
fixture.pyc
(59.3 KB)
📄
fixture.pyo
(57.08 KB)
📄
flup_session.py
(3.85 KB)
📄
flup_session.pyc
(3.87 KB)
📄
flup_session.pyo
(3.87 KB)
📄
gzipper.py
(3.61 KB)
📄
gzipper.pyc
(4.47 KB)
📄
gzipper.pyo
(4.47 KB)
📄
httpexceptions.py
(23.65 KB)
📄
httpexceptions.pyc
(27.71 KB)
📄
httpexceptions.pyo
(26.98 KB)
📄
httpheaders.py
(42.08 KB)
📄
httpheaders.pyc
(44.21 KB)
📄
httpheaders.pyo
(42.94 KB)
📄
httpserver.py
(54.36 KB)
📄
httpserver.pyc
(47.52 KB)
📄
httpserver.pyo
(46.87 KB)
📄
lint.py
(14.65 KB)
📄
lint.pyc
(17.47 KB)
📄
lint.pyo
(13.45 KB)
📄
modpython.py
(7.79 KB)
📄
modpython.pyc
(8.74 KB)
📄
modpython.pyo
(8.74 KB)
📄
pony.py
(2.23 KB)
📄
pony.pyc
(2.69 KB)
📄
pony.pyo
(2.69 KB)
📄
progress.py
(7.97 KB)
📄
progress.pyc
(9.2 KB)
📄
progress.pyo
(9.2 KB)
📄
proxy.py
(9.94 KB)
📄
proxy.pyc
(8.58 KB)
📄
proxy.pyo
(8.58 KB)
📄
recursive.py
(14.32 KB)
📄
recursive.pyc
(17.72 KB)
📄
recursive.pyo
(17.4 KB)
📄
registry.py
(21.67 KB)
📄
registry.pyc
(22.4 KB)
📄
registry.pyo
(22.4 KB)
📄
reloader.py
(5.87 KB)
📄
reloader.pyc
(5.99 KB)
📄
reloader.pyo
(5.99 KB)
📄
request.py
(13.81 KB)
📄
request.pyc
(13.74 KB)
📄
request.pyo
(13.64 KB)
📄
response.py
(7.48 KB)
📄
response.pyc
(9.25 KB)
📄
response.pyo
(9.16 KB)
📄
session.py
(11.07 KB)
📄
session.pyc
(11.77 KB)
📄
session.pyo
(11.77 KB)
📄
transaction.py
(4.26 KB)
📄
transaction.pyc
(5.72 KB)
📄
transaction.pyo
(5.72 KB)
📄
translogger.py
(4.7 KB)
📄
translogger.pyc
(4.27 KB)
📄
translogger.pyo
(4.27 KB)
📄
url.py
(14.28 KB)
📄
url.pyc
(18.15 KB)
📄
url.pyo
(18.15 KB)
📄
urlmap.py
(8.82 KB)
📄
urlmap.pyc
(9.54 KB)
📄
urlmap.pyo
(9.4 KB)
📄
urlparser.py
(25.8 KB)
📄
urlparser.pyc
(22.14 KB)
📄
urlparser.pyo
(21.97 KB)
📁
util
📄
wsgilib.py
(19.66 KB)
📄
wsgilib.pyc
(21.71 KB)
📄
wsgilib.pyo
(21.66 KB)
📄
wsgiwrappers.py
(21.65 KB)
📄
wsgiwrappers.pyc
(23.88 KB)
📄
wsgiwrappers.pyo
(23.88 KB)
Editing: progress.py
# (c) 2005 Ian Bicking and contributors; written for Paste (http://pythonpaste.org) # Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php # (c) 2005 Clark C. Evans # This module is part of the Python Paste Project and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php # This code was written with funding by http://prometheusresearch.com """ Upload Progress Monitor This is a WSGI middleware component which monitors the status of files being uploaded. It includes a small query application which will return a list of all files being uploaded by particular session/user. >>> from paste.httpserver import serve >>> from paste.urlmap import URLMap >>> from paste.auth.basic import AuthBasicHandler >>> from paste.debug.debugapp import SlowConsumer, SimpleApplication >>> # from paste.progress import * >>> realm = 'Test Realm' >>> def authfunc(username, password): ... return username == password >>> map = URLMap({}) >>> ups = UploadProgressMonitor(map, threshold=1024) >>> map['/upload'] = SlowConsumer() >>> map['/simple'] = SimpleApplication() >>> map['/report'] = UploadProgressReporter(ups) >>> serve(AuthBasicHandler(ups, realm, authfunc)) serving on... .. note:: This is experimental, and will change in the future. """ import time from paste.wsgilib import catch_errors DEFAULT_THRESHOLD = 1024 * 1024 # one megabyte DEFAULT_TIMEOUT = 60*5 # five minutes ENVIRON_RECEIVED = 'paste.bytes_received' REQUEST_STARTED = 'paste.request_started' REQUEST_FINISHED = 'paste.request_finished' class _ProgressFile(object): """ This is the input-file wrapper used to record the number of ``paste.bytes_received`` for the given request. """ def __init__(self, environ, rfile): self._ProgressFile_environ = environ self._ProgressFile_rfile = rfile self.flush = rfile.flush self.write = rfile.write self.writelines = rfile.writelines def __iter__(self): environ = self._ProgressFile_environ riter = iter(self._ProgressFile_rfile) def iterwrap(): for chunk in riter: environ[ENVIRON_RECEIVED] += len(chunk) yield chunk return iter(iterwrap) def read(self, size=-1): chunk = self._ProgressFile_rfile.read(size) self._ProgressFile_environ[ENVIRON_RECEIVED] += len(chunk) return chunk def readline(self): chunk = self._ProgressFile_rfile.readline() self._ProgressFile_environ[ENVIRON_RECEIVED] += len(chunk) return chunk def readlines(self, hint=None): chunk = self._ProgressFile_rfile.readlines(hint) self._ProgressFile_environ[ENVIRON_RECEIVED] += len(chunk) return chunk class UploadProgressMonitor(object): """ monitors and reports on the status of uploads in progress Parameters: ``application`` This is the next application in the WSGI stack. ``threshold`` This is the size in bytes that is needed for the upload to be included in the monitor. ``timeout`` This is the amount of time (in seconds) that a upload remains in the monitor after it has finished. Methods: ``uploads()`` This returns a list of ``environ`` dict objects for each upload being currently monitored, or finished but whose time has not yet expired. For each request ``environ`` that is monitored, there are several variables that are stored: ``paste.bytes_received`` This is the total number of bytes received for the given request; it can be compared with ``CONTENT_LENGTH`` to build a percentage complete. This is an integer value. ``paste.request_started`` This is the time (in seconds) when the request was started as obtained from ``time.time()``. One would want to format this for presentation to the user, if necessary. ``paste.request_finished`` This is the time (in seconds) when the request was finished, canceled, or otherwise disconnected. This is None while the given upload is still in-progress. TODO: turn monitor into a queue and purge queue of finished requests that have passed the timeout period. """ def __init__(self, application, threshold=None, timeout=None): self.application = application self.threshold = threshold or DEFAULT_THRESHOLD self.timeout = timeout or DEFAULT_TIMEOUT self.monitor = [] def __call__(self, environ, start_response): length = environ.get('CONTENT_LENGTH', 0) if length and int(length) > self.threshold: # replace input file object self.monitor.append(environ) environ[ENVIRON_RECEIVED] = 0 environ[REQUEST_STARTED] = time.time() environ[REQUEST_FINISHED] = None environ['wsgi.input'] = \ _ProgressFile(environ, environ['wsgi.input']) def finalizer(exc_info=None): environ[REQUEST_FINISHED] = time.time() return catch_errors(self.application, environ, start_response, finalizer, finalizer) return self.application(environ, start_response) def uploads(self): return self.monitor class UploadProgressReporter(object): """ reports on the progress of uploads for a given user This reporter returns a JSON file (for use in AJAX) listing the uploads in progress for the given user. By default, this reporter uses the ``REMOTE_USER`` environment to compare between the current request and uploads in-progress. If they match, then a response record is formed. ``match()`` This member function can be overriden to provide alternative matching criteria. It takes two environments, the first is the current request, the second is a current upload. ``report()`` This member function takes an environment and builds a ``dict`` that will be used to create a JSON mapping for the given upload. By default, this just includes the percent complete and the request url. """ def __init__(self, monitor): self.monitor = monitor def match(self, search_environ, upload_environ): if search_environ.get('REMOTE_USER', None) == \ upload_environ.get('REMOTE_USER', 0): return True return False def report(self, environ): retval = { 'started': time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(environ[REQUEST_STARTED])), 'finished': '', 'content_length': environ.get('CONTENT_LENGTH'), 'bytes_received': environ[ENVIRON_RECEIVED], 'path_info': environ.get('PATH_INFO',''), 'query_string': environ.get('QUERY_STRING','')} finished = environ[REQUEST_FINISHED] if finished: retval['finished'] = time.strftime("%Y:%m:%d %H:%M:%S", time.gmtime(finished)) return retval def __call__(self, environ, start_response): body = [] for map in [self.report(env) for env in self.monitor.uploads() if self.match(environ, env)]: parts = [] for k, v in map.items(): v = str(v).replace("\\", "\\\\").replace('"', '\\"') parts.append('%s: "%s"' % (k, v)) body.append("{ %s }" % ", ".join(parts)) body = "[ %s ]" % ", ".join(body) start_response("200 OK", [('Content-Type', 'text/plain'), ('Content-Length', len(body))]) return [body] __all__ = ['UploadProgressMonitor', 'UploadProgressReporter'] if "__main__" == __name__: import doctest doctest.testmod(optionflags=doctest.ELLIPSIS)
Upload File
Create Folder