def stdin_read(self, data): """read Event (on channel ``stdin``) This is the event handler for ``read`` events specifically from the ``stdin`` channel. This is triggered each time stdin has data that it has read. """ data = data.strip().decode("utf-8") self.log("Incoming:", data) if data[0] == "/": cmd = data[1:].upper() args = [] if ' ' in cmd: cmd, args = cmd.split(' ', maxsplit=1) args = args.split(' ') if cmd in self.hooks: self.hooks[cmd](args) if cmd == 'FRONTEND': self.log("Sending %s frontend rebuild event" % ("(forced)" if 'FORCE' in args else '')) self.fireEvent(frontendbuildrequest(force='FORCE' in args, install='INSTALL' in args), "setup") if cmd == 'BACKEND': self.log("Sending backend reload event") self.fireEvent(componentupdaterequest(force=False), "setup") if cmd == 'WHO': self.fireEvent()
def stdin_read(self, data): """read Event (on channel ``stdin``) This is the event handler for ``read`` events specifically from the ``stdin`` channel. This is triggered each time stdin has data that it has read. """ data = data.strip().decode("utf-8") self.log("Incoming:", data, lvl=verbose) if len(data) == 0: return if data[0] == "/": cmd = data[1:].upper() args = [] if ' ' in cmd: cmd, args = cmd.split(' ', maxsplit=1) args = args.split(' ') if cmd in self.hooks: self.log('Firing hooked event:', cmd, args, lvl=debug) self.fireEvent(self.hooks[cmd](args)) # TODO: Move these out, so we get a simple logic here if cmd == 'FRONTEND': self.log("Sending %s frontend rebuild event" % ("(forced)" if 'FORCE' in args else '')) self.fireEvent( frontendbuildrequest(force='FORCE' in args, install='INSTALL' in args), "setup") if cmd == 'BACKEND': self.log("Sending backend reload event") self.fireEvent(componentupdaterequest(force=False), "setup")
def debugrequest(self, event): try: self.log("Event: ", event.__dict__, lvl=critical) if event.action == "storejson": self.log("Storing received object to /tmp", lvl=critical) fp = open( '/tmp/hfosdebugger_' + str(event.user.useruuid) + "_" + str(uuid4()), "w") json.dump(event.data, fp, indent=True) fp.close() if event.action == "memdebug": self.log("Memory hogs:", lvl=critical) objgraph.show_most_common_types(limit=20) if event.action == "growth": self.log("Memory growth since last call:", lvl=critical) objgraph.show_growth() if event.action == "graph": objgraph.show_backrefs([self.root], max_depth=42, filename='backref-graph.png') self.log("Backref graph written.", lvl=critical) if event.action == "exception": class TestException(BaseException): pass raise TestException if event.action == "heap": self.log("Heap log:", self.heapy.heap(), lvl=critical) if event.action == "buildfrontend": self.log("Sending frontend build command") self.fireEvent(frontendbuildrequest(force=True), "setup") if event.action == "logtail": self.fireEvent( logtailrequest(event.user, None, None, event.client), "logger") except Exception as e: self.log("Exception during debug handling:", e, type(e), lvl=critical)
def debugrequest(self, event): try: self.log("Event: ", event.__dict__, lvl=critical) if event.action == "storejson": self.log("Storing received object to /tmp", lvl=critical) fp = open('/tmp/hfosdebugger_' + str( event.user.useruuid) + "_" + str(uuid4()), "w") json.dump(event.data, fp, indent=True) fp.close() if event.action == "memdebug": self.log("Memory hogs:", lvl=critical) objgraph.show_most_common_types(limit=20) if event.action == "growth": self.log("Memory growth since last call:", lvl=critical) objgraph.show_growth() if event.action == "graph": objgraph.show_backrefs([self.root], max_depth=42, filename='backref-graph.png') self.log("Backref graph written.", lvl=critical) if event.action == "exception": class TestException(BaseException): pass raise TestException if event.action == "heap": self.log("Heap log:", self.heapy.heap(), lvl=critical) if event.action == "buildfrontend": self.log("Sending frontend build command") self.fireEvent(frontendbuildrequest(force=True), "setup") if event.action == "logtail": self.fireEvent(logtailrequest(event.user, None, None, event.client), "logger") except Exception as e: self.log("Exception during debug handling:", e, type(e), lvl=critical)