def initialize(themeName): """Initialize Miro. This sets up things like logging and the config system and should be called as early as possible. """ # set debugmode if it hasn't already been set if app.debugmode == None: app.debugmode = app.config.get(prefs.APP_VERSION).endswith("-git") # this is platform specific setup_logging() # this is portable general util.setup_logging() app.controller = controller.Controller() config.set_theme(themeName)
def launch(): # Make all output flush immediately. # Don't add extra import statements here. If there's a problem importing # something we want to see the error in the log. import logging import sys import os from miro import util sys.stdout = util.AutoFlushingStream(sys.stdout) sys.stderr = sys.stdout override_modules() from miro.plat.utils import setup_logging, initialize_locale setup_logging(in_downloader=True) util.setup_logging() initialize_locale() if os.environ.get('DEMOCRACY_DOWNLOADER_FIRST_LAUNCH') != '1': logging.info("Starting new downloader log") else: logging.info("Launching Downloader Daemon") log_versions() # Start of normal imports import threading from miro.dl_daemon import daemon from miro import httpclient addr = os.environ['DEMOCRACY_DOWNLOADER_ADDR'] port = int(os.environ['DEMOCRACY_DOWNLOADER_PORT']) short_app_name = os.environ['DEMOCRACY_SHORT_APP_NAME'] httpclient.start_thread() server = daemon.DownloaderDaemon(addr, port, short_app_name) # setup config for the downloader from miro import eventloop config.load(config.DownloaderConfig()) app.downloader_config_watcher = config.ConfigWatcher( lambda foo, *args: eventloop.add_idle(foo, "config watcher", args=args)) # start things up eventloop.startup()
def initialize(themeName): """Initialize Miro. This sets up things like logging and the config system and should be called as early as possible. """ # set debugmode if it hasn't already been set if app.debugmode == None: if app.config.get(prefs.APP_FINAL_RELEASE) == u"0": # if it's not a final release, then we're in debugmode app.debugmode = True else: # if it is a final release, then we're not in debugmode app.debugmode = False # this is platform specific setup_logging() # this is portable general util.setup_logging() app.controller = controller.Controller() config.set_theme(themeName)
def _subprocess_setup(stdin, stdout): """Does initial setup for a subprocess. Returns a SubprocessHandler to use for the subprocess raises the same exceptions that _load_obj does, namely: :raises IOError: low-level error while reading from the pipe :raises LoadError: data read was corrupted """ global logging_setup # disable warnings so we don't get too much junk on stderr warnings.filterwarnings("ignore") # setup MessageHandler for messages going to the main process msg_handler = PipeMessageProxy(stdout) SubprocessResponse.install_handler(msg_handler) # load startup info msg = _load_obj(stdin) if not isinstance(msg, StartupInfo): raise LoadError("first message must a StartupInfo obj") # setup some basic modules like config and gtcache utils.initialize_locale() config.load(config.ManualConfig()) app.config.set_dictionary(msg.config_dict) gtcache.init() if not msg.in_unit_tests: utils.setup_logging(app.config.get(prefs.HELPER_LOG_PATHNAME)) util.setup_logging() logging_setup = True logging.info("Logging Started") # setup our handler msg = _load_obj(stdin) if not isinstance(msg, HandlerInfo): raise LoadError("second message must a HandlerInfo obj") try: return msg.handler_class(*msg.handler_args) except StandardError, e: # log this exception for easier debugging. send_subprocess_error_for_exception() raise LoadError("Exception while constructing handler: %s" % e)
def launch(): # Make all output flush immediately. # Don't add extra import statements here. If there's a problem importing # something we want to see the error in the log. from miro import util sys.stdout = util.AutoFlushingStream(sys.stdout) sys.stderr = sys.stdout override_modules() from miro.plat.utils import setup_logging, initialize_locale setup_logging(in_downloader=True) util.setup_logging() initialize_locale() if os.environ.get('DEMOCRACY_DOWNLOADER_FIRST_LAUNCH') != '1': logging.info("Starting new downloader log") else: logging.info("Launching Downloader Daemon") log_versions() # Start of normal imports from miro.dl_daemon import daemon from miro import httpclient addr = os.environ['DEMOCRACY_DOWNLOADER_ADDR'] port = int(os.environ['DEMOCRACY_DOWNLOADER_PORT']) short_app_name = os.environ['DEMOCRACY_SHORT_APP_NAME'] httpclient.start_thread() daemon.DownloaderDaemon(addr, port, short_app_name) # setup config for the downloader from miro import eventloop config.load(config.ManualConfig()) app.downloader_config_watcher = config.ConfigWatcher( lambda foo, *args: eventloop.add_idle(foo, "config watcher", args=args )) # start things up eventloop.startup()