def serve(self, args): # List of processors which have been started if not hasattr(self, "_processors"): self._processors = [] debug = args.verbose background = args.background timeout = args.timeout client = self.ctx.conn(args) who = [self._parse_who(w) for w in args.who] if not who: who = [] # Official scripts only # Similar to omero.util.Server starting here import logging original = list(logging._handlerList) roots = list(logging.getLogger().handlers) logging._handlerList = [] logging.getLogger().handlers = [] from omero.util import configure_logging from omero.processor import usermode_processor lvl = debug and 10 or 20 configure_logging(loglevel=lvl) try: try: impl = usermode_processor(client, serverid="omero.scripts.serve", accepts_list=who, omero_home=self.ctx.dir) self._processors.append(impl) except Exception as e: self.ctx.die(100, "Failed initialization: %s" % e) if background: def cleanup(): impl.cleanup() logging._handlerList = original logging.getLogger().handlers = roots atexit.register(cleanup) else: if self._isWindows(): self.foreground_win(impl, timeout) else: self.foreground_nix(impl, timeout) finally: if not background: logging._handlerList = original logging.getLogger().handlers = roots return impl
def serve(self, args): # List of processors which have been started if not hasattr(self, "_processors"): self._processors = [] debug = args.verbose background = args.background timeout = args.timeout client = self.ctx.conn(args) sf = client.sf who = [self._parse_who(w) for w in args.who] if not who: who = [] # Official scripts only # Similar to omero.util.Server starting here import logging original = list(logging._handlerList) roots = list(logging.getLogger().handlers) logging._handlerList = [] logging.getLogger().handlers = [] from omero.util import configure_logging from omero.processor import usermode_processor lvl = debug and 10 or 20 configure_logging(loglevel=lvl) try: try: impl = usermode_processor(client, serverid = "omer.scripts.serve", accepts_list = who, omero_home=self.ctx.dir) self._processors.append(impl) except exceptions.Exception, e: self.ctx.die(100, "Failed initialization: %s" % e) if background: def cleanup(): impl.cleanup() logging._handlerList = original logging.getLogger().handlers = roots atexit.register(cleanup) else: try: def handler(signum, frame): raise SystemExit() old = signal.signal(signal.SIGALRM, handler) signal.alarm(timeout) self.ctx.input("Press any key to exit...\n") signal.alarm(0) finally: self.ctx.dbg("DONE") signal.signal(signal.SIGTERM, old) impl.cleanup()
def serve(self, args): # List of processors which have been started if not hasattr(self, "_processors"): self._processors = [] debug = args.verbose background = args.background timeout = args.timeout client = self.ctx.conn(args) who = [self._parse_who(w) for w in args.who] if not who: who = [] # Official scripts only # Similar to omero.util.Server starting here import logging original = list(logging._handlerList) roots = list(logging.getLogger().handlers) logging._handlerList = [] logging.getLogger().handlers = [] from omero.util import configure_logging from omero.processor import usermode_processor lvl = debug and 10 or 20 configure_logging(loglevel=lvl) try: try: impl = usermode_processor( client, serverid="omero.scripts.serve", accepts_list=who, omero_home=self.ctx.dir) self._processors.append(impl) except Exception, e: self.ctx.die(100, "Failed initialization: %s" % e) if background: def cleanup(): impl.cleanup() logging._handlerList = original logging.getLogger().handlers = roots atexit.register(cleanup) else: if self._isWindows(): self.foreground_win(impl, timeout) else: self.foreground_nix(impl, timeout)