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)
import os import sys import logging from django.core.management import execute_from_command_line logger = logging.getLogger(__name__) if __name__ == "__main__": os.environ.setdefault("DJANGO_SETTINGS_MODULE", "omeroweb.settings") import settings from omero.util import configure_logging if settings.DEBUG: configure_logging(settings.LOGDIR, 'OMEROweb.log', loglevel=logging.DEBUG) logger.info("Application Starting...") # Monkeypatch Django development web server to always run in single thread # even if --nothreading is not specified on command line def force_nothreading(addr, port, wsgi_handler, ipv6=False, threading=False): django_core_servers_basehttp_run(addr, port, wsgi_handler, ipv6, False) import django.core.servers.basehttp if django.core.servers.basehttp.run.__module__ != 'settings': django_core_servers_basehttp_run = django.core.servers.basehttp.run django.core.servers.basehttp.run = force_nothreading execute_from_command_line(sys.argv)
import os import sys import atexit import logging import tempfile import threading import traceback import portalocker from path import path from omero.util import get_user_dir, get_user # Activating logging at a static level if "DEBUG" in os.environ: from omero.util import configure_logging configure_logging(loglevel=logging.DEBUG) # TODO: # - locking for command-line cleanup # - plugin for cleaning unlocked files # - plugin for counting sizes, etc. # - decorator class TempFileManager(object): """ Creates temporary files and folders and makes a best effort to remove them on exit (or sooner). Typically only a single instance of this class will exist ("manager" variable in this module below) """
from builtins import object from past.utils import old_div import os import sys import atexit import logging import tempfile from omero.util import get_omero_userdir, get_user from omero_ext import portalocker from omero_ext.path import path # Activating logging at a static level if "DEBUG" in os.environ: from omero.util import configure_logging configure_logging(loglevel=logging.DEBUG) # TODO: # - locking for command-line cleanup # - plugin for cleaning unlocked files # - plugin for counting sizes, etc. # - decorator class TempFileManager(object): """ Creates temporary files and folders and makes a best effort to remove them on exit (or sooner). Typically only a single instance of this class will exist ("manager" variable in this module below)
import os import sys import logging from django.core.management import execute_from_command_line logger = logging.getLogger(__name__) if __name__ == "__main__": os.environ.setdefault("DJANGO_SETTINGS_MODULE", "omeroweb.settings") import settings from omero.util import configure_logging if settings.DEBUG: configure_logging(settings.LOGDIR, 'OMEROweb.log', loglevel=logging.DEBUG) logger.info("Application Starting...") # Monkeypatch Django development web server to always run in single thread # even if --nothreading is not specified on command line def force_nothreading(addr, port, wsgi_handler, ipv6=False, threading=False): django_core_servers_basehttp_run(addr, port, wsgi_handler, ipv6, False) import django.core.servers.basehttp if django.core.servers.basehttp.run.__module__ != 'settings':