def __init__(self): """ Initializes Exaile. """ self.quitting = False self.loading = True # NOTE: This automatically exits on --help. self.options = create_argument_parser().parse_args() if self.options.ShowVersion: self.version() return _do_heavy_imports() if self.options.UseDataDir: xdg.data_dirs.insert(1, self.options.UseDataDir) # this is useful on Win32, because you cannot set these directories # via environment variables if self.options.UseAllDataDir: xdg.data_home = self.options.UseAllDataDir xdg.data_dirs.insert(0, xdg.data_home) xdg.config_home = self.options.UseAllDataDir xdg.config_dirs.insert(0, xdg.config_home) xdg.cache_home = self.options.UseAllDataDir try: xdg._make_missing_dirs() except OSError as e: print >> sys.stderr, 'ERROR: Could not create configuration directories: %s' % e return # Make event debug imply debug if self.options.DebugEventFull: self.options.DebugEvent = True if self.options.DebugEvent: self.options.Debug = True try: logger_setup.start_logging(self.options.Debug, self.options.Quiet, self.options.DebugThreads, self.options.ModuleFilter, self.options.LevelFilter) except OSError as e: print >> sys.stderr, 'ERROR: could not setup logging: %s' % e return global logger import logging logger = logging.getLogger(__name__) try: # Late import ensures xl.event uses correct logger from xl import event if self.options.EventFilter: event.EVENT_MANAGER.logger_filter = self.options.EventFilter self.options.DebugEvent = True if self.options.DebugEvent: event.EVENT_MANAGER.use_logger = True if self.options.DebugEventFull: event.EVENT_MANAGER.use_verbose_logger = True # initial mainloop setup. The actual loop is started later, # if necessary self.mainloop_init() #initialize DbusManager if self.options.StartGui and self.options.Dbus: from xl import xldbus exit = xldbus.check_exit(self.options, self.options.locs) if exit == "exit": sys.exit(0) elif exit == "command": if not self.options.StartAnyway: sys.exit(0) self.dbus = xldbus.DbusManager(self) # import version, see note above global __version__ from xl.version import __version__ #load the rest. self.__init() #handle delayed commands if self.options.StartGui and self.options.Dbus and \ self.options.StartAnyway and exit == "command": xldbus.run_commands(self.options, self.dbus) #connect dbus signals if self.options.StartGui and self.options.Dbus: self.dbus._connect_signals() # On SIGTERM, quit normally. import signal signal.signal(signal.SIGTERM, (lambda sig, stack: self.quit())) # run the GUIs mainloop, if needed if self.options.StartGui: import xlgui xlgui.mainloop() except KeyboardInterrupt: logger.exception("User exited program") except: logger.exception("Unhandled exception")
def __init__(self): """ Initializes Exaile. """ self.quitting = False self.loading = True # NOTE: This automatically exits on --help. self.options = create_argument_parser().parse_args() if self.options.ShowVersion: self.version() return _do_heavy_imports() if self.options.UseDataDir: xdg.data_dirs.insert(1, self.options.UseDataDir) # this is useful on Win32, because you cannot set these directories # via environment variables if self.options.UseAllDataDir: if not os.path.supports_unicode_filenames: alldatadir = self.options.UseAllDataDir try: alldatadir.decode('ascii') except UnicodeDecodeError: # if we don't do this here, os.path.join() will fail later. alldatadir = alldatadir.decode('utf-8').encode('ascii', 'replace') print( "WARNING : converted non-ASCII data dir %s to ascii: %s" % (self.options.UseAllDataDir, alldatadir) ) xdg.data_home = alldatadir xdg.data_dirs.insert(0, xdg.data_home) xdg.config_home = alldatadir xdg.config_dirs.insert(0, xdg.config_home) xdg.cache_home = alldatadir try: xdg._make_missing_dirs() except OSError as e: print( 'ERROR: Could not create configuration directories: %s' % e, file=sys.stderr, ) return # Make event debug imply debug if self.options.DebugEventFull: self.options.DebugEvent = True if self.options.DebugEvent: self.options.Debug = True try: logger_setup.start_logging( self.options.Debug, self.options.Quiet, self.options.DebugThreads, self.options.ModuleFilter, self.options.LevelFilter, ) except OSError as e: print('ERROR: could not setup logging: %s' % e, file=sys.stderr) return global logger import logging logger = logging.getLogger(__name__) try: # Late import ensures xl.event uses correct logger from xl import event if self.options.EventFilter: event.EVENT_MANAGER.logger_filter = self.options.EventFilter self.options.DebugEvent = True if self.options.DebugEvent: event.EVENT_MANAGER.use_logger = True if self.options.DebugEventFull: event.EVENT_MANAGER.use_verbose_logger = True # initial mainloop setup. The actual loop is started later, # if necessary self.mainloop_init() # initialize DbusManager if self.options.StartGui and self.options.Dbus: from xl import xldbus exit = xldbus.check_exit(self.options, self.options.locs) if exit == "exit": sys.exit(0) elif exit == "command": if not self.options.StartAnyway: sys.exit(0) self.dbus = xldbus.DbusManager(self) # import version, see note above global __version__ from xl.version import __version__ # load the rest. self.__init() # handle delayed commands if ( self.options.StartGui and self.options.Dbus and self.options.StartAnyway and exit == "command" ): xldbus.run_commands(self.options, self.dbus) # connect dbus signals if self.options.StartGui and self.options.Dbus: self.dbus._connect_signals() # On SIGTERM, quit normally. import signal signal.signal(signal.SIGTERM, (lambda sig, stack: self.quit())) # run the GUIs mainloop, if needed if self.options.StartGui: # Handle keyboard interruptions with InterruptibleLoopContext(self.quit): Gtk.main() # mainloop except Exception: logger.exception("Unhandled exception")
def __init__(self): """ Initializes Exaile. """ self.quitting = False self.loading = True # NOTE: This automatically exits on --help. self.options = create_argument_parser().parse_args() if self.options.ShowVersion: self.version() return _do_heavy_imports() if self.options.UseDataDir: xdg.data_dirs.insert(1, self.options.UseDataDir) # this is useful on Win32, because you cannot set these directories # via environment variables if self.options.UseAllDataDir: xdg.data_home = self.options.UseAllDataDir xdg.data_dirs.insert(0, xdg.data_home) xdg.config_home = self.options.UseAllDataDir xdg.config_dirs.insert(0, xdg.config_home) xdg.cache_home = self.options.UseAllDataDir try: xdg._make_missing_dirs() except OSError as e: print('ERROR: Could not create configuration directories: %s' % e, file=sys.stderr) return # Make event debug imply debug if self.options.DebugEventFull: self.options.DebugEvent = True if self.options.DebugEvent: self.options.Debug = True try: logger_setup.start_logging(self.options.Debug, self.options.Quiet, self.options.DebugThreads, self.options.ModuleFilter, self.options.LevelFilter) except OSError as e: print('ERROR: could not setup logging: %s' % e, file=sys.stderr) return global logger import logging logger = logging.getLogger(__name__) try: # Late import ensures xl.event uses correct logger from xl import event if self.options.EventFilter: event.EVENT_MANAGER.logger_filter = self.options.EventFilter self.options.DebugEvent = True if self.options.DebugEvent: event.EVENT_MANAGER.use_logger = True if self.options.DebugEventFull: event.EVENT_MANAGER.use_verbose_logger = True # initial mainloop setup. The actual loop is started later, # if necessary self.mainloop_init() #initialize DbusManager if self.options.StartGui and self.options.Dbus: from xl import xldbus exit = xldbus.check_exit(self.options, self.options.locs) if exit == "exit": sys.exit(0) elif exit == "command": if not self.options.StartAnyway: sys.exit(0) self.dbus = xldbus.DbusManager(self) # import version, see note above global __version__ from xl.version import __version__ #load the rest. self.__init() #handle delayed commands if self.options.StartGui and self.options.Dbus and \ self.options.StartAnyway and exit == "command": xldbus.run_commands(self.options, self.dbus) #connect dbus signals if self.options.StartGui and self.options.Dbus: self.dbus._connect_signals() # On SIGTERM, quit normally. import signal signal.signal(signal.SIGTERM, (lambda sig, stack: self.quit())) # run the GUIs mainloop, if needed if self.options.StartGui: import xlgui xlgui.mainloop() except KeyboardInterrupt: logger.exception("User exited program") except: logger.exception("Unhandled exception")