def get_sources(self): sources = remotes.searchSites() sites = [] if sources: for name, desc, req, methods in sources: # determine if bot is running if "IRC" in methods: status = self._get_status(name) if status == "off": statusimage = "on.png" startstopmsg = "Start IRC" startstop = "start" else: statusimage = "off.png" startstopmsg = "Stop IRC" startstop = "stop" # fetch filters s = self.STORE.getRemoteByName(name) if s: req_ = [] for r in req: if r[0] in s.keys(): req_.append((r[0], s[r[0]])) else: req_.append(r) req = req_ filters = self.get_filters(name, internal=True) filters = self._fmt_filters(filters) botcontrol = """ <button class="bot_button" id="%(startstop)s_%(name)s"> <img src="images/%(statusimage)s" width=20 height=20> <span>%(startstopmsg)s</span> </button> """ % { "statusimage": statusimage, "startstop": startstop, "startstopmsg": startstopmsg, "name": name } else: filters = "" botcontrol = "" sites.append({ "row": self._fmt_source(name, desc, status), "requirements": req, "req_row": self._fmt_keys(name, req, filters, botcontrol), }) return self._response(None, "get_sources", sites, None)
def get_source_single(self, select): sources = remotes.searchSites() if sources: for name, desc, req, methods in sources: if name.upper() != select.upper(): continue #determine if bot is running if "IRC" in methods: status = self._get_status(name) if status == "off": statusimage = "on.png" startstopmsg = "Start IRC" startstop = "start" else: statusimage = "off.png" startstopmsg = "Stop IRC" startstop = "stop" s = self.STORE.getRemoteByName(name) if s: req_ = [] for r in req: if r[0] in s.keys(): req_.append( (r[0], s[r[0]]) ) else: req_.append(r) req = req_ filters = self.get_filters(name, internal=True) filters = self._fmt_filters(filters) botcontrol = """ <button class="bot_button" id="%(startstop)s_%(name)s"> <img src="/images/%(statusimage)s" width=20 height=20> <span>%(startstopmsg)s</span> </button> """ % { "statusimage" : statusimage, "startstop" : startstop, "startstopmsg" : startstopmsg, "name" : name } else: filters = "" botcontrol = "" return self._response(name, "get_source_single", { "row" : self._fmt_source(name, desc, status), "requirements" : req, "req_row" : self._fmt_keys(name, req, filters, botcontrol), }, None) else: return self._response(name, "get_source_single", "ERROR", "IRC not specified as a valid method") return self._response(select, "get_source_single", "ERROR", "Remote name '%r' not known" % select) return self._response(select, "get_source_single", "ERROR", "No remotes defined")
def get_sources(self): sources = remotes.searchSites() sites = [] if sources: for name, desc, req, methods in sources: #determine if bot is running if "IRC" in methods: status = self._get_status(name) if status == "off": statusimage = "on.png" startstopmsg = "Start IRC" startstop = "start" else: statusimage = "off.png" startstopmsg = "Stop IRC" startstop = "stop" #fetch filters s = self.STORE.getRemoteByName(name) if s: req_ = [] for r in req: if r[0] in s.keys(): req_.append( (r[0], s[r[0]]) ) else: req_.append(r) req = req_ filters = self.get_filters(name, internal=True) filters = self._fmt_filters(filters) botcontrol = """ <button class="bot_button" id="%(startstop)s_%(name)s"> <img src="/images/%(statusimage)s" width=20 height=20> <span>%(startstopmsg)s</span> </button> """ % { "statusimage" : statusimage, "startstop" : startstop, "startstopmsg" : startstopmsg, "name" : name } else: filters = "" botcontrol = "" sites.append({ "row" : self._fmt_source(name, desc, status), "requirements" : req, "req_row" : self._fmt_keys(name, req, filters, botcontrol), }) return self._response(None, "get_sources", sites, None)