def __init__(self): Thread.__init__(self, name = "Task") self._cv = Condition() self._status = {} self._stopme = False engine.subscribe("stop", self.stop) if engine.state == process.wspbus.states.STOPPED: engine.subscribe("start", self.start) else: self.start()
def __init__(self): Thread.__init__(self, name="Task") self._cv = Condition() self._status = {} self._stopme = False engine.subscribe("stop", self.stop) if engine.state == process.wspbus.states.STOPPED: engine.subscribe("start", self.start) else: self.start()
def __init__(self,gui,interval=3,sizelimit=100000000,itemlimit=1000,wait_expiry=120,wait_interval=5): """ Create a new ProdmonCache. Note that it is not started until the .start() method is called. @param interval: interval in seconds between the main loop running (3) @param cachesize: maximum size in bytes before old entries start getting culled. Note that this is done *imprecisely* and will not be strictly adhered to! (100MB) """ _loginfo("CACHE: Creating new Overview cache interval=%s sec, sizelimit=%s bytes, itemlimit=%s"%(interval,sizelimit,itemlimit)) Thread.__init__(self,name="OverviewCache") self.lock = Lock() self.stopme = False self.cachesize = 0 self.cache = {} # objkey: tuple (expiry, size, data) self.interval = interval self.sizelimit = sizelimit self.itemlimit = itemlimit self.cacheevents = {} self.wait_expiry = wait_expiry self.wait_interval = wait_interval engine.subscribe('stop',self.stop) self.start()
def __init__(self, cfgfile, cfg, modules): modules = map(import_module, modules) self.instrument = cfg.instrument self.checksums = [] self.stamp = time.time() self.lock = Lock() self.services = cfg.services self.serviceName = cfg.serviceName self.templates = {} self.css = [] self.js = [] monitor_root = os.getenv("MONITOR_ROOT") if os.access("%s/xdata/templates/index.tmpl" % monitor_root, os.R_OK): self.contentpath = "%s/xdata" % monitor_root else: self.contentpath = "%s/data" % monitor_root self.baseUrl = cfg.baseUrl self.sessiondir = cfg.serverDir + '/sessions' self.logdir = cfg.logFile.rsplit('/', 1)[0] self.title = cfg.title for file in os.listdir(self.contentpath + "/templates"): m = re.match(r'(.*)\.tmpl$', file) if m: (base,) = m.groups() filename = "%s/templates/%s" % (self.contentpath, file) self.templates[base] = [ filename, os.stat(filename)[ST_MTIME], open(filename).read() ] self._yui = os.getenv("YUI_ROOT") + "/build" self._extjs = os.getenv("EXTJS_ROOT") self._addCSSFragment("%s/css/Core/style.css" % self.contentpath) self._addJSFragment("%s/yahoo/yahoo.js" % self._yui) self._addJSFragment("%s/event/event.js" % self._yui) self._addJSFragment("%s/connection/connection.js" % self._yui) self._addJSFragment("%s/dom/dom.js" % self._yui) self._addJSFragment("%s/javascript/Core/sprintf.js" % self.contentpath) self._addJSFragment("%s/javascript/Core/Utils.js" % self.contentpath) self._addJSFragment("%s/javascript/Core/Core.js" % self.contentpath) self.sessions = {} self.sessionthread = SessionThread(self.sessiondir) self.extensions = [extension(modules, e[0], self, *e[1]) for e in cfg.extensions] self.sources = [extension(modules, s[0] + "Source", self, cfg.serverDir + '/' + s[1], *s[2]) for s in cfg.sources] self.workspaces = [extension(modules, w[0] + "Workspace", self, *w[1]) for w in cfg.workspaces] for w in self.workspaces: if getattr(w, 'customise', None): w.customise() self._addJSFragment("%s/javascript/Core/End.js" % self.contentpath) self._addChecksum(None, cfgfile, open(cfgfile).read()) for name, m in sys.modules.iteritems(): if ((name.startswith("Monitoring.") and name.count(".") % 2 == 0 and name.rsplit(".", 1)[-1][0].isupper()) or name == "__main__") \ and m and m.__dict__.has_key('__file__'): self._addChecksum(name, inspect.getsourcefile(m) \ or inspect.getabsfile(m) or name, inspect.getsource(m)) self.sessionthread.start() engine.subscribe('stop', self.sessionthread.stop)
def __init__(self, plothook, images): self.plothook = plothook self.images = images self.scraper = WebImageScraper(300, self.images) engine.subscribe('exit', self.scraper.stop, priority=100) self.scraper.start()
def __init__(self, cfgfile, cfg, modules): modules = map(import_module, modules) self.instrument = cfg.instrument self.checksums = [] self.stamp = time.time() self.lock = Lock() self.services = cfg.services self.serviceName = cfg.serviceName self.templates = {} self.css = [] self.js = [] monitor_root = os.getenv("MONITOR_ROOT") if os.access("%s/xdata/templates/index.tmpl" % monitor_root, os.R_OK): self.contentpath = "%s/xdata" % monitor_root else: self.contentpath = "%s/data" % monitor_root self.baseUrl = cfg.baseUrl self.sessiondir = cfg.serverDir + '/sessions' self.logdir = cfg.logFile.rsplit('/', 1)[0] self.title = cfg.title for file in os.listdir(self.contentpath + "/templates"): m = re.match(r'(.*)\.tmpl$', file) if m: (base, ) = m.groups() filename = "%s/templates/%s" % (self.contentpath, file) self.templates[base] = [ filename, os.stat(filename)[ST_MTIME], open(filename).read() ] self._yui = os.getenv("YUI_ROOT") + "/build" self._extjs = os.getenv("EXTJS_ROOT") self._addCSSFragment("%s/css/Core/style.css" % self.contentpath) self._addJSFragment("%s/yahoo/yahoo.js" % self._yui) self._addJSFragment("%s/event/event.js" % self._yui) self._addJSFragment("%s/connection/connection.js" % self._yui) self._addJSFragment("%s/dom/dom.js" % self._yui) self._addJSFragment("%s/javascript/Core/sprintf.js" % self.contentpath) self._addJSFragment("%s/javascript/Core/Utils.js" % self.contentpath) self._addJSFragment("%s/javascript/Core/Core.js" % self.contentpath) self.sessions = {} self.sessionthread = SessionThread(self.sessiondir) self.extensions = [ extension(modules, e[0], self, *e[1]) for e in cfg.extensions ] self.sources = [ extension(modules, s[0] + "Source", self, cfg.serverDir + '/' + s[1], *s[2]) for s in cfg.sources ] self.workspaces = [ extension(modules, w[0] + "Workspace", self, *w[1]) for w in cfg.workspaces ] for w in self.workspaces: if getattr(w, 'customise', None): w.customise() self._addJSFragment("%s/javascript/Core/End.js" % self.contentpath) self._addChecksum(None, cfgfile, open(cfgfile).read()) for name, m in sys.modules.iteritems(): if ((name.startswith("Monitoring.") and name.count(".") % 2 == 0 and name.rsplit(".", 1)[-1][0].isupper()) or name == "__main__") \ and m and m.__dict__.has_key('__file__'): self._addChecksum(name, inspect.getsourcefile(m) \ or inspect.getabsfile(m) or name, inspect.getsource(m)) self.sessionthread.start() engine.subscribe('stop', self.sessionthread.stop)
import sqlite3 import json from cherrypy import engine, expose, quickstart, response, thread_data from markdown import markdown from jinja2 import Environment, FileSystemLoader from models import Post from views import PostsView # Database callbacks def connect(thread_id): # Store a connection to our database in each thread thread_data.db = sqlite3.connect('db/test.db') engine.subscribe('start_thread', connect) # Jinja2 filter callbacks def filter_markdown(text): return markdown(text) def filter_monthname(month): names = [ "January", "February", "March", "April", "May", "June", "July",
def __init__(self, server, statedir, *rxlist): self.thread = CAFDataProvider(*rxlist) engine.subscribe("exit", self.thread.stop, priority=100) self.thread.start()
def __init__(self, server, statedir, *rxlist): self.thread = CAFDataProvider(*rxlist) engine.subscribe('exit', self.thread.stop, priority=100) self.thread.start()