Пример #1
0
 def _loadOptions(self):
     """load the persistent options (for usage by early tasks)"""
     from core import paths
     # options needs the paths class to know from where to load the options
     self.modrana.paths = paths.Paths(self.modrana)
     self.modrana._load_options()
Пример #2
0
    def __init__(self):
        singleton.modrana = self

        self.timing = []
        self.addCustomTime("modRana start", startTimestamp)
        self.addCustomTime("imports done", importsDoneTimestamp)

        # constants & variable initialization
        self.dmod = None  # device specific module
        self.gui = None
        self.GUIString = ""
        self.optLoadingOK = None

        self.d = {}  # persistent dictionary of data
        self.m = {}  # dictionary of loaded modules
        self.watches = {}  # List of data change watches
        self.maxWatchId = 0

        self.initInfo = {
            'modrana': self,
            'device': None,  # TODO: do this directly
            'name': ""
        }

        # signals
        self.notificationTriggered = Signal()
        self.shutdown_signal = Signal()

        self.mapRotationAngle = 0  # in radians
        self.notMovingSpeed = 1  # in m/s

        # per mode options
        # NOTE: this variable is automatically saved by the
        # options module
        self.keyModifiers = {}

        # initialize threading
        threads.initThreading()

        # start timing modRana launch
        self.addTime("GUI creation")

        # add the startup handling core module
        self.startup = startup.Startup(self)
        self.args = self.startup.getArgs()

        # handle any early tasks specified from CLI
        self.startup.handleEarlyTasks()

        # early CLI tasks might need a "silent" modRana
        # so the startup announcement is here
        log.info(" == modRana Starting == ")
        # load the version string (needs to be done here
        # as PWD might change after the paths module is
        # imported, for example when running
        # with the Qt 5 GUI)
        paths.load_version_string()
        version = paths.VERSION_STRING
        if version is None:
            version = "unknown version"
        log.info("  %s" % version)
        log.info("  Python %s" % platform.python_version())
        os_release = self._get_os_release()
        if os_release:
            log.info("  %s", os_release)

        # load the device module now as it might override
        # the default profile directory, so it needs to be
        # before ve init the core paths module
        self._load_device_module()

        # initialize the paths handling core module
        self.paths = paths.Paths(self)

        # add the configs handling core module
        self.configs = configs.Configs(configs_dir=self.paths.profile_path)

        # load persistent options
        self.optLoadingOK = self._load_options()
        self._options_loaded()

        # check if upgrade took place

        if self.optLoadingOK:
            savedVersionString = self.get('modRanaVersionString', "")
            versionStringFromFile = paths.VERSION_STRING
            if savedVersionString != versionStringFromFile:
                log.info("possible upgrade detected")
                self._post_upgrade_check()

        # save current version string
        self.set('modRanaVersionString', paths.VERSION_STRING)

        # load all configuration files
        self.configs.load_all()

        # start loading other modules

        # handle tasks that require the device
        # module but not GUI
        self.startup.handle_non_gui_tasks()

        # then the GUI module
        self._load_gui_module()

        # and all other modules
        self._load_modules()

        # startup done, log some statistics
        self._startup_done()