def PruneCache_t(self): cacheDir = blue.paths.ResolvePath(u'cache:/') for d in self.autoPruneDirectories: rootPath = os.path.join(cacheDir, d.directory) uthread.CallOnThread(ProcessCacheDirectory, args=(self, rootPath, RemoveFileFromCache, d))
def PruneCache_t(self): """ Prune files from the cache folders that are watched immediately """ cacheDir = blue.paths.ResolvePath(u'cache:/') for d in self.autoPruneDirectories: rootPath = os.path.join(cacheDir, d.directory) uthread.CallOnThread(ProcessCacheDirectory, args=(self, rootPath, RemoveFileFromCache, d))
def HandleRequestFile(self, request, response, filename, files): if filename[-3:] == '.py': self.HandlePython(request, response, filename, files) else: resFile = files[-1][1] response.contentType = httputils.get_mimetype(filename) response.header['Cache-Control'] = 'max-age=31536000000, public' if request.method == 'HEAD': log.LogInfo('Got a HEAD request, not returning body...') else: s = resFile.size if s > 1048576: data = uthread.CallOnThread(resFile.Read) else: data = resFile.Read() response.WriteBinary(data)
def HandleRequestFile(self, request, response, filename, files): if filename[-3:] == '.py': self.HandlePython(request, response, filename, files) else: resFile = files[-1][1] extidx = filename.rfind('.') if extidx == -1: response.contentType = 'application/x-dunno' else: ext = filename[extidx + 1:] if mime.has_key(ext): response.contentType = mime[ext] else: response.contentType = 'application/octet-stream' response.header['Cache-Control'] = 'max-age=31536000000, public' if request.method == 'HEAD': log.LogInfo('Got a HEAD request, not returning body...') else: s = resFile.size if s > 1048576: data = uthread.CallOnThread(resFile.Read) else: data = resFile.Read() response.WriteBinary(data)
# Credits to wibiti import sys import code import threading import stackless import uthread class wConsole(code.InteractiveConsole): def __init__(self, *args, **kwds): self.__input = stackless.channel() code.InteractiveConsole.__init__(self, *args, **kwds) def interact(self, banner=None): threading.Thread(target=self.__input_loop).start() code.InteractiveConsole.interact(self, banner) def __input_loop(self): while 1: self.__input.send(raw_input()) def raw_input(self, prompt=None): if prompt: sys.stdout.write(prompt) return self.__input.receive() uthread.new(code.interact, readfunc=lambda p: uthread.CallOnThread(raw_input, args=(p, )))