def _getSession(self, name): """Check NAME is valid and a known session. If yes, returns the session data, otherwise None. Locks the session before returning it, making sure all other threads have released the session. The caller _MUST_ release the session lock before the HTTP request handling returns, or the next access to the session will hang.""" s = None if re.match("^[-A-Za-z0-9_]+$", name): self.lock.acquire() if name not in self.sessions: path = "%s/%s" % (self.sessiondir, name) if os.path.exists(path): try: self.sessions[name] = pickle.load(file(path, "r")) except Exception, e: _logerr("FAILURE: cannot load session data: " + str(e)) s = self.sessions.get(name, None) self.lock.release() if s: current = self._sessionClientData() if s['core.clientid'] == current and s['core.name'] == name: if 'core.lock' not in s: s['core.lock'] = Lock() s['core.lock'].acquire() s['core.stamp'] = time.time() else: s = None
def __init__(self,gui,rank,category,name,*args): _loginfo("FILELIGHT_W: Workspace created") CompWorkspace.__init__(self, gui, rank, category, 'filelight', name, [self.FileLightSiteView(self),self.FileLightGroupView(self)]) gui._addJSFragment("%s/javascript/Overview/FileLight.js" % gui.contentpath) self.source = None for s in gui.sources: if s.plothook=='filelight': self.source = s if self.source==None: _logerr("FILELIGHT_W: Couldn't find FileLightSource") raise Exception, "FILELIGHT_W Couldn't find source"
def __init__(self,gui,rank,category,name,*args): """ Create a new ProdMonWorkspace instance. Note that we need to find ProdMonSource in the server source list, or we'll exit ingloriously. TODO: good mechanism for finding sources TODO: SiteDB source integration TODO: ProdRequest integration """ _loginfo("PRODMON_W: Workspace created") CompWorkspace.__init__(self, gui, rank, category, 'prodmon', name, [ProdMonWorkspace.ProdMonSummary(self),ProdMonWorkspace.ProdMonPlot(self)]) gui._addJSFragment("%s/javascript/Overview/ProdMon.js" % gui.contentpath) gui._addCSSFragment("%s/css/Overview/ProdMon.css" % gui.contentpath) self.source = None for s in gui.sources: if s.plothook=='prodmon': self.source = s if self.source==None: _logerr("PRODMON_W: Couldn't find ProdMonSource") raise Exception, "PW: Failed to find prodmon source. Fatal."
def _error(self, code, message, detail=None): _logerr("code=%d, message=%s, detail=%s" % (code, message, detail)) self._status(code, message, detail) raise HTTPError(500, message)