Пример #1
0
    def main():
        # when the -d/--debug flag is set, Kivy sets log level to debug
        level = Logger.getEffectiveLevel()
        in_debug = level == LOG_LEVELS.get('debug')

        reset()
        MainApp().run()
        print("Returned from run")
Пример #2
0
    def LoadFonts(self, *, uDefinitionName: str,
                  fSplashScreenPercentageStartValue: float) -> None:
        """ Load the fonts for a single definition """

        aCommands: List[Dict[str, str]]

        if uDefinitionName == "":
            fSplashScreenPercentageRange: float = 10.0
            fPercentage: float = fSplashScreenPercentageStartValue
            fPercentageStep: float = fSplashScreenPercentageRange / (
                len(self) + 1)

            # Scheduling Loading Definition Fonts
            aActions: List[cAction] = Globals.oEvents.CreateSimpleActionList(
                aActions=[{
                    'name': 'Show Message we load Fonts',
                    'string': 'showsplashtext',
                    'maintext': 'Loading Definition Fonts'
                }])

            #for definition
            for uDefinitionKey in reversed(self):
                oDefinition = self[uDefinitionKey]
                fPercentage += fPercentageStep
                if Logger.getEffectiveLevel() != logging.DEBUG:
                    aCommands = []
                else:
                    aCommands = [{
                        'name': 'Update Percentage and Definition Name',
                        'string': 'showsplashtext',
                        'subtext': oDefinition.uDefPublicTitle,
                        'percentage': str(fPercentage)
                    }]
                aCommands.append({
                    'name': 'Load Fonts for Definition',
                    'string': 'loaddefinitionfonts',
                    'definitionname': oDefinition.uAlias
                })

                Globals.oEvents.AddToSimpleActionList(aActionList=aActions,
                                                      aActions=aCommands)

            Globals.oEvents.ExecuteActionsNewQueue(aActions=aActions,
                                                   oParentWidget=None)
        elif uDefinitionName == "ORCA":
            aFontsFolders: List[str] = Globals.oPathFonts.GetFolderList(
                bFullPath=True)
            for uFontFolder in aFontsFolders:
                oFnFontDefinition: cFileName = cFileName('').ImportFullPath(
                    uFnFullName=uFontFolder + u"/fonts.xml")
                if not oFnFontDefinition.string in aLoadedFontFiles:
                    Logger.info(u'Loading Global Fonts: ' + uFontFolder)
                    aLoadedFontFiles.append(oFnFontDefinition.string)
                    LoadFontFromXML(oET_Root=LoadXMLFile(
                        oFile=oFnFontDefinition))
        else:
            self[uDefinitionName].LoadFonts()
        return None
Пример #3
0
def main():
    # when the -d/--debug flag is set, Kivy sets log level to debug
    level = Logger.getEffectiveLevel()
    in_debug = level == LOG_LEVELS.get('debug')
    client = configure_sentry(in_debug)
    try:
        MainApp().run()
    except Exception:
        if type(client) == Client:
            Logger.info(
                'Errors will be sent to Sentry, run with "--debug" if you '
                'are a developper and want to the error in the shell.')
        client.captureException()
Пример #4
0
    def LogAction(self,uTxt,oAction,uAddText=''):
        """ Logs an action """

        if Logger.getEffectiveLevel()!=logging.DEBUG:
            return
        uTemp=self.CreateDebugLine(oAction,uTxt=uTxt)

        if uAddText:
            uTemp+=u"| "+uAddText
        try:
            Logger.debug (uTemp)
        except:
            Logger.error ("Cant Create Debugline")
Пример #5
0
    def RegisterFonts(self, *, uFontName: str,
                      fSplashScreenPercentageStartValue: float) -> None:
        """ Register the a specific font, or schedules the registration of all fonts """

        fPercentage: float
        fSplashScreenPercentageRange: float = 10.0
        uFontIndex: str
        aCommands: List[Dict]
        oFont: cFontDef

        if not uFontName:
            Logger.debug(u'TheScreen: Register Fonts')
            fPercentage = fSplashScreenPercentageStartValue
            fPercentageStep = fSplashScreenPercentageRange / len(self.dFonts)

            # Scheduling Loading Fonts
            aActions: List[cAction] = Globals.oEvents.CreateSimpleActionList(
                aActions=[{
                    'name': 'Show Message the we register the fonts',
                    'string': 'showsplashtext',
                    'maintext': '$lvar(417)'
                }])

            for uFontIndex in self.dFonts:
                oFont = self.dFonts[uFontIndex]
                fPercentage += fPercentageStep
                if Logger.getEffectiveLevel() != logging.DEBUG:
                    aCommands = []
                else:
                    aCommands = [{
                        'name': 'Update Percentage and Font Name',
                        'string': 'showsplashtext',
                        'subtext': oFont.uName,
                        'percentage': str(fPercentage)
                    }]
                aCommands.append({
                    'name': 'Register the Font',
                    'string': 'registerfonts',
                    'fontname': oFont.uName
                })
                Globals.oEvents.AddToSimpleActionList(aActionList=aActions,
                                                      aActions=aCommands)
                Globals.oEvents.ExecuteActionsNewQueue(aActions=aActions,
                                                       oParentWidget=None)
        else:
            oFont = self.dFonts[uFontName]
            # todo: either we always load all fonts, or we need to check in widget if font is required in case we load elements as runtime
            if oFont.uName in self.dUsedFonts or True:
                oFont.Register()
Пример #6
0
def Orca_include(oElem, pLoader: Callable, uFileName: str = "") -> None:
    """  heavily customized loader for includes in xml files"""
    uAlias = oElem.get('definitionalias')
    oDef = None
    if uAlias is not None:
        oDef = Globals.oDefinitions[uAlias]

    oElem.set('linefilename', ShortenFileName(uFnFile=uFileName))

    Orca_includesub(oElem=oElem,
                    pLoader=pLoader,
                    uOrgDefinitionContext=Globals.uDefinitionContext,
                    oDef=oDef,
                    uFileName=uFileName)
    if Logger.getEffectiveLevel() == logging.DEBUG:
        AddFileNames(oElem=oElem, uFnFile=uFileName)
    RestoreDefinitionContext()
Пример #7
0
    def LoadGestures(self, *, uDefinitionName: str,
                     fSplashScreenPercentageStartValue: float) -> None:
        """ Loads the gestures for a single definition, or creates the queue entries """

        aCommands: List[Dict[str, str]]

        if uDefinitionName == "":
            fSplashScreenPercentageRange: float = 10.0
            fPercentage: float = fSplashScreenPercentageStartValue
            fPercentageStep: float = fSplashScreenPercentageRange / len(self)

            # Scheduling Loading Definition Gestures
            aActions: List[cAction] = Globals.oEvents.CreateSimpleActionList(
                aActions=[{
                    'name': 'Show Message we load Gestures',
                    'string': 'showsplashtext',
                    'maintext': '$lvar(404)'
                }])
            for uDefinitionKey in reversed(self):
                oDefinition = self[uDefinitionKey]
                fPercentage += fPercentageStep
                if Logger.getEffectiveLevel() != logging.DEBUG:
                    aCommands = []
                else:
                    aCommands = [{
                        'name': 'Update Percentage and Definition Name',
                        'string': 'showsplashtext',
                        'subtext': oDefinition.uDefPublicTitle,
                        'percentage': str(fPercentage)
                    }]
                aCommands.append({
                    'name': 'Load Gestures for Definition',
                    'string': 'loaddefinitiongestures',
                    'definitionname': oDefinition.uAlias
                })

                if oDefinition.bImportActions:
                    Globals.oEvents.AddToSimpleActionList(aActionList=aActions,
                                                          aActions=aCommands)
            Globals.oEvents.ExecuteActionsNewQueue(aActions=aActions,
                                                   oParentWidget=None)
        else:
            self[uDefinitionName].LoadGestures()
        return None
Пример #8
0
    def ParseXmlFiles(self, *, uDefinitionName: str,
                      fSplashScreenPercentageStartValue: float) -> None:
        """ Parses the definition file for a single definition """
        aCommands: List[Dict[str, str]]
        fSplashScreenPercentageRange: float = 10.0

        if not uDefinitionName:
            fPercentage: float = fSplashScreenPercentageStartValue
            fPercentageStep: float = fSplashScreenPercentageRange / len(self)

            aActions: List[cAction] = Globals.oEvents.CreateSimpleActionList(
                aActions=[{
                    'name': 'Show Message that we parse the XML Files',
                    'string': 'showsplashtext',
                    'maintext': '$lvar(412)'
                }])
            # Scheduling Parsing of Definition XML Files
            for uDefinitionKey in self:
                oDefinition = self[uDefinitionKey]
                fPercentage += fPercentageStep
                if Logger.getEffectiveLevel() != logging.DEBUG:
                    aCommands = []
                else:
                    aCommands = [{
                        'name': 'Update Percentage and Definitioon Name',
                        'string': 'showsplashtext',
                        'subtext': oDefinition.uDefPublicTitle,
                        'percentage': str(fPercentage)
                    }]
                aCommands.append({
                    'name': 'And parse the definition',
                    'string': 'parsedefinitionxml',
                    'definitionname': oDefinition.uAlias
                })
                Globals.oEvents.AddToSimpleActionList(aActionList=aActions,
                                                      aActions=aCommands)

            Globals.oEvents.ExecuteActionsNewQueue(aActions=aActions,
                                                   oParentWidget=None)
        else:
            self[uDefinitionName].LoadXMLFile()
        return None
Пример #9
0
    def LoadActions(self, *, fSplashScreenPercentageStartValue: float) -> None:
        """ Loads the action files for the definitions """

        oDefinition: cDefinition
        aCommands: List[Dict[str, str]]

        fSplashScreenPercentageRange: float = 10.0
        fPercentage: float = fSplashScreenPercentageStartValue
        fPercentageStep: float = fSplashScreenPercentageRange / len(self)

        aActions: List[cAction] = Globals.oEvents.CreateSimpleActionList(
            aActions=[{
                'name': 'Show Message we load Actions',
                'string': 'showsplashtext',
                'maintext': '$lvar(403)'
            }])
        for uDefinitionKey in reversed(self):
            oDefinition = self[uDefinitionKey]
            fPercentage += fPercentageStep
            if oDefinition.bImportActions:
                if Logger.getEffectiveLevel() != logging.DEBUG:
                    aCommands = []
                else:
                    aCommands = [{
                        'name': 'Update Percentage and Definition Name',
                        'string': 'showsplashtext',
                        'subtext': oDefinition.uDefPublicTitle,
                        'percentage': str(fPercentage)
                    }]

                aCommands.append({
                    'name': 'Load the Definition Actions',
                    "string": "loaddefinitionactions",
                    "definitionname": oDefinition.uAlias
                })
                Globals.oEvents.AddToSimpleActionList(aActionList=aActions,
                                                      aActions=aCommands)

        Globals.oEvents.ExecuteActionsNewQueue(aActions=aActions,
                                               oParentWidget=None)
        return None
Пример #10
0
    def LogAction(self,
                  *,
                  uTxt: str,
                  oAction: cAction,
                  uAddText: str = '') -> None:
        """ Logs an action """

        if Logger.getEffectiveLevel() != logging.DEBUG:
            return
        uTemp = self.CreateDebugLine(oAction=oAction, uTxt=uTxt)

        if uAddText:
            uTemp += u"| " + uAddText
        try:
            from ORCA.utils.TypeConvert import ToUnicode
            Logger.debug(ToUnicode(uTemp))
        except Exception:
            try:
                Logger.debug(uTemp.encode("'UTF-8'", errors='replace'))
            except Exception as e:
                Logger.error("Cant Create Debugline:" + str(e))
Пример #11
0
    def LoadSettings(self, *, uDefinitionName: str,
                     fSplashScreenPercentageStartValue: float) -> None:
        """ Loads the settings for a specific definition """

        oDefinition: cDefinition
        aCommands: List[Dict[str, str]]
        uHintKey: str
        fSplashScreenPercentageRange: float = 10.0

        if not uDefinitionName:
            # Scheduling Loading Definition Settings
            fPercentage: float = fSplashScreenPercentageStartValue
            fPercentageStep: float = fSplashScreenPercentageRange / len(self)

            aActions: List[cAction] = Globals.oEvents.CreateSimpleActionList(
                aActions=[{
                    'name': 'Show Message that we load the settings',
                    'string': 'showsplashtext',
                    'maintext': '$lvar(414)'
                }])
            for uDefinitionKey in reversed(self):
                oDefinition = self[uDefinitionKey]
                fPercentage += fPercentageStep
                if Logger.getEffectiveLevel() != logging.DEBUG:
                    aCommands = []
                else:
                    aCommands = [{
                        'name': 'Update Percentage and Definition Name',
                        'string': 'showsplashtext',
                        'subtext': oDefinition.uDefPublicTitle,
                        'percentage': str(fPercentage)
                    }]
                aCommands.append({
                    'name': 'Load the settings for the Definition',
                    'string': 'loaddefinitionsettings',
                    'definitionname': oDefinition.uAlias
                })
                Globals.oEvents.AddToSimpleActionList(aActionList=aActions,
                                                      aActions=aCommands)

            # Lets parse them (to init all default vars
            Globals.oEvents.AddToSimpleActionList(
                aActionList=aActions,
                aActions=[{
                    'name': 'Parse all Settings and set defaults',
                    'string': 'loaddefinitionsettings',
                    'definitionname': 'PARSESETTINGS'
                }])
            #Execute the Queue
            Globals.oEvents.ExecuteActionsNewQueue(aActions=aActions,
                                                   oParentWidget=None)
            #just to put it somewhere
            for uHintKey in self.dInstallationsHints:
                self.uInstallationHint += self.dInstallationsHints[uHintKey]
            SetVar(uVarName="INSTALLATIONHINT",
                   oVarValue=self.uInstallationHint)

        else:
            oDefinition = self[uDefinitionName]
            SetDefinitionContext(uDefinitionName=oDefinition.uName)
            oDefinition.ParseSettings()
            RestoreDefinitionContext()
        return None
Пример #12
0
    def InitInterFaceSettings(
            self, *, uDefinitionName: str,
            fSplashScreenPercentageStartValue: float) -> None:
        """ Init The Interface settings of a definition  """

        aCommands: List[Dict[str, str]]
        oInterface: cBaseInterFace
        fSplashScreenPercentageRange = 10.0

        if not uDefinitionName:
            # Scheduling Initialize Interface settings
            fPercentage = fSplashScreenPercentageStartValue
            fPercentageStep = fSplashScreenPercentageRange / len(self)

            aActions: List[cAction] = Globals.oEvents.CreateSimpleActionList(
                aActions=[{
                    'name': 'Show Message the we initialize the interfaces',
                    'string': 'showsplashtext',
                    'maintext': '$lvar(418)'
                }])

            for uDefinitionKey in reversed(self):
                oDefinition = self[uDefinitionKey]
                fPercentage += fPercentageStep
                if Logger.getEffectiveLevel() != logging.DEBUG:
                    aCommands = []
                else:
                    aCommands = [{
                        'name': 'Update Percentage and Interface Name',
                        'string': 'showsplashtext',
                        'subtext': oDefinition.uDefPublicTitle,
                        'percentage': str(fPercentage)
                    }]
                aCommands.append({
                    'name': 'Initialize the Interface',
                    'string': 'initinterfacesettings',
                    'definitionname': oDefinition.uAlias
                })
                Globals.oEvents.AddToSimpleActionList(aActionList=aActions,
                                                      aActions=aCommands)
            Globals.oEvents.AddToSimpleActionList(
                aActionList=aActions,
                aActions=[{
                    'name': 'Show Message the we write all interface settings',
                    'string': 'showsplashtext',
                    'subtext': "$lvar(456)",
                    'percentage': str(fPercentage)
                }, {
                    'name': 'Write all interface settings',
                    'string': 'initinterfacesettings',
                    'definitionname': 'WRITEALLSETTINGS'
                }])

            Globals.oEvents.ExecuteActionsNewQueue(aActions=aActions,
                                                   oParentWidget=None)

        elif uDefinitionName == "WRITEALLSETTINGS":
            for uInterfaceName in self.dInitInterfaceSettings:
                if uInterfaceName in Globals.oInterFaces.aObjectNameList:
                    oInterface = Globals.oInterFaces.GetInterface(
                        uInterfaceName)
                    if oInterface is None:
                        Logger.info(
                            'Need to load unrecognized Interface [%s] for configuration'
                            % uInterfaceName)
                        Globals.oInterFaces.LoadInterface(uInterfaceName)
                        oInterface = Globals.oInterFaces.GetInterface(
                            uInterfaceName)
                    if oInterface is not None:
                        for uConfigurationName in self.dInitInterfaceSettings[
                                uInterfaceName]:
                            oInterface.oObjectConfig.WriteDefinitionConfig(
                                uSectionName=uConfigurationName,
                                dSettings=self.dInitInterfaceSettings[
                                    uInterfaceName][uConfigurationName])
                else:
                    Logger.warning(
                        'Interface [%s] not on device, so it will not be configured!'
                        % uInterfaceName)

        else:
            oDef: cDefinition = self[uDefinitionName]
            SetDefinitionContext(uDefinitionName=oDef.uName)
            oDef.InitInterFaceSettings(oXMLRoot=oDef.oET_Root)
            RestoreDefinitionContext()
        return None
Пример #13
0
    def LoadLanguages(self, *,
                      fSplashScreenPercentageStartValue: float) -> None:
        """ Loads the language files for the definitions """
        # Scheduling Loading Definition Languages

        oDefinition: cDefinition
        aCommands: List[Dict[str, str]]
        fSplashScreenPercentageRange: float = 10.0
        fPercentage: float = fSplashScreenPercentageStartValue
        fPercentageStep: float = fSplashScreenPercentageRange / len(self)

        aActions: List[cAction] = Globals.oEvents.CreateSimpleActionList(
            aActions=[{
                'name': 'Show Message to Load the Language',
                'string': 'showsplashtext',
                'maintext': '$lvar(413)'
            }])
        for uDefinitionKey in reversed(self):
            oDefinition = self[uDefinitionKey]
            fPercentage += fPercentageStep
            if oDefinition.bImportLanguages:
                if Logger.getEffectiveLevel() != logging.DEBUG:
                    aCommands = []
                else:
                    aCommands = [{
                        'name': 'Update Percentage and DefinitionName',
                        'string': 'showsplashtext',
                        'subtext': oDefinition.uDefPublicTitle,
                        'percentage': str(fPercentage)
                    }]
                if oDefinition.oDefinitionPathes.oFnDefinitionLanguageFallBack.Exists(
                ):
                    aCommands.append({
                        'name':
                        'Load Default Language File',
                        'string':
                        'loadlanguages',
                        'languagefilename':
                        oDefinition.oDefinitionPathes.
                        oFnDefinitionLanguageFallBack.string,
                        'definition':
                        oDefinition.uName,
                        'definitionalias':
                        oDefinition.uAlias
                    })
                if not Globals.uLanguage == u'English':
                    oDefinition.oDefinitionPathes.LanguageChange()
                    if oDefinition.oDefinitionPathes.oFnDefinitionLanguage.Exists(
                    ):
                        aCommands.append({
                            'name':
                            'Load Requested Language File',
                            'string':
                            'loadlanguages',
                            'languagefilename':
                            oDefinition.oDefinitionPathes.
                            oFnDefinitionLanguage.string,
                            'definition':
                            oDefinition.uName,
                            'definitionalias':
                            oDefinition.uAlias
                        })
                if len(aCommands) > 0:
                    Globals.oEvents.AddToSimpleActionList(aActionList=aActions,
                                                          aActions=aCommands)

        Globals.oEvents.ExecuteActionsNewQueue(aActions=aActions,
                                               oParentWidget=None)
        return None
Пример #14
0
            client.user_context({'android_os_build': android_os_build})
        # Logger.error() to Sentry
        # https://docs.sentry.io/clients/python/integrations/logging/
        handler = SentryHandler(client)
        handler.setLevel(LOG_LEVELS.get('error'))
        setup_logging(handler)
    return client


class MainApp(App):

    theme_cls = ThemeManager()

    def build(self):
        self.icon = "docs/images/icon.png"


if __name__ == '__main__':
    # when the -d/--debug flag is set, Kivy sets log level to debug
    level = Logger.getEffectiveLevel()
    in_debug = level == LOG_LEVELS.get('debug')
    client = configure_sentry(in_debug)
    try:
        MainApp().run()
    except Exception:
        if type(client) == Client:
            Logger.info(
                'Errors will be sent to Sentry, run with "--debug" if you '
                'are a developper and want to the error in the shell.')
        client.captureException()