def _loadDeviceModule(self): """Load the device module""" # get the device module string # (a unique device module string identificator) if self.args.d: device = self.args.d else: # no device specified from CLI # try to auto-detect the current device from core import platform_detection device = platform_detection.getBestDeviceModuleId() device = device.lower() # convert to lowercase self.initInfo["device"] = device # get GUI ID from the CLI argument if self.args.u: self.GUIString = self.args.u else: # no ID specified # the N900 device module needs the GUIString # at startup if device == "n900": self.GUIString = "GTK" gs.GUIString = self.GUIString ## load the device specific module # NOTE: other modules need the device and GUI modules # during init deviceModulesPath = os.path.join(modulesFolder, "device_modules") sys.path.append(deviceModulesPath) dmod = self._loadModule("device_%s" % device, "device") if dmod is None: print("modRana: !! device module failed to load !!\n" "loading the Neo device module as fail-safe") device = "neo" dmod = self._loadModule("device_%s" % device, "device") self.dmod = dmod # if no GUIString was specified from CLI, # get preferred GUI module strings from the device module if self.GUIString == "": ids = self.dmod.getSupportedGUIModuleIds() if ids: self.GUIString = ids[0] else: self.GUIString = "GTK" # fallback # export the GUI string gs.GUIString = self.GUIString
def _loadDeviceModule(self): """Load the device module""" if self.dmod: # don't reload the module return # get the device module string # (a unique device module string identificator) if self.args.d: device = self.args.d else: # no device specified from CLI # try to auto-detect the current device from core import platform_detection device = platform_detection.getBestDeviceModuleId() device = device.lower() # convert to lowercase self.initInfo["device"] = device # get GUI ID from the CLI argument if self.args.u: try: self.GUIString = self.args.u.split(":")[0].upper() except Exception: log.exception('splitting the GUI string failed') else: # no ID specified # the N900 device module needs the GUIString # at startup if device == "n900": self.GUIString = "GTK" # set the pre-import-visible GUIString # for the device module gs.GUIString = self.GUIString ## load the device specific module # NOTE: other modules need the device and GUI modules # during init deviceModulesPath = os.path.join(MAIN_MODULES_FOLDER, "device_modules") sys.path.append(deviceModulesPath) dmod_instance = self._loadModule("device_%s" % device, "device") if dmod_instance is None: log.critical("!! device module failed to load !!\n" "loading the Neo device module as fail-safe") device = "neo" dmod_instance = self._loadModule("device_%s" % device, "device") self.dmod = dmod_instance # if no GUIString was specified from CLI, # get preferred GUI module strings from the device module if self.GUIString == "": ids = self.dmod.getSupportedGUIModuleIds() if ids: self.GUIString = ids[0] else: self.GUIString = "GTK" # fallback # export the GUI string # set the pre-import visible GUI string and subtype splitGUIString = self.GUIString.split(":") gs.GUIString = splitGUIString[0] if len(splitGUIString) >= 2: gs.GUISubtypeString = splitGUIString[1]