def start(self): if not isinstance(sys.stderr, OutputSplitter): self.standard_error = sys.stderr sys.stderr = OutputSplitter(sys.stderr) if not isinstance(sys.stdout, OutputSplitter): self.standard_output = sys.stdout sys.stdout = OutputSplitter(sys.stdout) if self.monitor is None: self.monitor = monitor.ChannelMonitor() if self.dispatcher is None: self.dispatcher = ConsoleDispatcher(self) if not self.monitor.is_running(): self.monitor.start_monitor() if not self.dispatcher.is_dispatching(): self.dispatcher.start_dispatching() self.logoutput('%s started.', self, type=msglog.types.INFO) return super(InteractiveService, self).start()
class InteractiveService(CompositeNode): def __init__(self): self.monitor = None self.dispatcher = None self.standard_error = None self.standard_output = None super(InteractiveService, self).__init__() def logoutput(self, message, *args, **kw): logtype = kw.get("type", msglog.types.DB) debuglevel = kw.get("level", 1) if logtype == msglog.types.DB and debuglevel > self.debug: return False msglog.log('broadway', logtype, message % args) return True def configure(self, config): set_attribute(self, 'interface', 'localhost', config) set_attribute(self, 'port', 9666, config, int) set_attribute(self,'debug', 0, config, int) return super(InteractiveService, self).configure(config) def configuration(self): config = super(InteractiveService, self).configuration() get_attribute(self, 'interface', config) get_attribute(self, 'port', config, str) get_attribute(self, 'debug', config, str) return config def start(self): if not isinstance(sys.stderr, OutputSplitter): self.standard_error = sys.stderr sys.stderr = OutputSplitter(sys.stderr) if not isinstance(sys.stdout, OutputSplitter): self.standard_output = sys.stdout sys.stdout = OutputSplitter(sys.stdout) if self.monitor is None: self.monitor = monitor.ChannelMonitor() if self.dispatcher is None: self.dispatcher = ConsoleDispatcher(self) if not self.monitor.is_running(): self.monitor.start_monitor() if not self.dispatcher.is_dispatching(): self.dispatcher.start_dispatching() self.logoutput('%s started.', self, type=msglog.types.INFO) return super(InteractiveService, self).start() def stop(self): if isinstance(sys.stderr, OutputSplitter): sys.stderr = self.standard_error if isinstance(sys.stdout, OutputSplitter): sys.stdout = self.standard_output if self.dispatcher is not None: if self.dispatcher.is_dispatching(): self.dispatcher.stop_dispatching() self.dispatcher = None if self.monitor is not None: if self.monitor.is_running(): self.monitor.stop_monitor() self.monitor = None self.logoutput('%s stopped.', self, type=msglog.types.INFO) return super(InteractiveService, self).stop()
class InteractiveService(CompositeNode): def __init__(self): self.monitor = None self.dispatcher = None self.standard_error = None self.standard_output = None super(InteractiveService, self).__init__() def logoutput(self, message, *args, **kw): logtype = kw.get("type", msglog.types.DB) debuglevel = kw.get("level", 1) if logtype == msglog.types.DB and debuglevel > self.debug: return False msglog.log('broadway', logtype, message % args) return True def configure(self, config): set_attribute(self, 'interface', 'localhost', config) set_attribute(self, 'port', 9666, config, int) set_attribute(self, 'debug', 0, config, int) return super(InteractiveService, self).configure(config) def configuration(self): config = super(InteractiveService, self).configuration() get_attribute(self, 'interface', config) get_attribute(self, 'port', config, str) get_attribute(self, 'debug', config, str) return config def start(self): if not isinstance(sys.stderr, OutputSplitter): self.standard_error = sys.stderr sys.stderr = OutputSplitter(sys.stderr) if not isinstance(sys.stdout, OutputSplitter): self.standard_output = sys.stdout sys.stdout = OutputSplitter(sys.stdout) if self.monitor is None: self.monitor = monitor.ChannelMonitor() if self.dispatcher is None: self.dispatcher = ConsoleDispatcher(self) if not self.monitor.is_running(): self.monitor.start_monitor() if not self.dispatcher.is_dispatching(): self.dispatcher.start_dispatching() self.logoutput('%s started.', self, type=msglog.types.INFO) return super(InteractiveService, self).start() def stop(self): if isinstance(sys.stderr, OutputSplitter): sys.stderr = self.standard_error if isinstance(sys.stdout, OutputSplitter): sys.stdout = self.standard_output if self.dispatcher is not None: if self.dispatcher.is_dispatching(): self.dispatcher.stop_dispatching() self.dispatcher = None if self.monitor is not None: if self.monitor.is_running(): self.monitor.stop_monitor() self.monitor = None self.logoutput('%s stopped.', self, type=msglog.types.INFO) return super(InteractiveService, self).stop()