示例#1
0
    def RestartAfterDefinitionLoad(self):
        """
        This function will get either called when we detect a new ORCA version we downloaded the updated ORCA repository files
        Or it will get called at the first time installation after we downloaded the setup definition
        in Both cases we restart ORCA to make changes effective
        """
        Globals.oOrcaConfigParser.set(u'ORCA', u'lastinstalledversion',
                                      str(Globals.iVersion))
        Globals.oOrcaConfigParser.write()

        # if we get called after a repository update caused by  new version install (but not on the first install)
        # we restart to make the changes effective
        # todo: check if we just need to skip restart as we might have updated several definitions
        if Globals.iVersion != Globals.iLastInstalledVersion:
            # self.ReStart()
            return True

        uTmp, uRepType, uRepName = Globals.oDownLoadSettings.uLast.split(':')

        if uRepType == u'definitions':
            if self.CheckForOrcaFiles():
                uDefName = GetDefinitionFileNameByName(uRepName)
                Globals.uDefinitionName = uDefName
                Globals.oOrcaConfigParser.set(u'ORCA', u'definition', uDefName)
                Globals.oOrcaConfigParser.write()
                self.ReStart()
                return True
        StopWait()
        return True
示例#2
0
    def ReStart(self):
        """
        Restarts the whole ORCA App
        """
        Logger.debug("Restarting ORCA....")
        Globals.oTheScreen.ShowSplash()
        # Whole restart
        # Stop the timer
        Globals.oTheScreen.DeInit()
        # Close the settings
        Globals.bInit = True
        self.close_settings()
        Globals.bInit = False
        # # Ensure, settings are recreated
        self._app_settings = None
        # Write current changes
        kivyConfig.write()
        # Delete the timers
        Globals.oEvents.oAllTimer.DeleteAllTimer()
        # Cancel Queue Events
        ClearQueue()
        # stop interfaces
        Globals.oInterFaces.DeInit()

        # Reset all the screen vars
        Globals.oTheScreen.InitVars()
        # delete all varlinks
        DelAllVarLinks()
        # And here we go again
        StopWait()
        Clock.schedule_once(self.Init_ReadConfig, 0)
示例#3
0
    def LoadSingleFile(self, *, uRef: str, oProgressBar: cProgressBar) -> bool:
        """
        Loads a single resource by web
        dispatches on_download_finished when finished
        """

        self.oRef = cDownLoadObject()
        self.oRef.FromString(uPars=uRef)

        uUrl = self.oRef.dPars["Url"]
        self.uTarget = self.oRef.dPars["Target"]
        self.uType = self.oRef.dPars["Type"]
        self.uName = self.oRef.dPars["Name"]
        self.uVersion = self.oRef.dPars["Version"]

        self.oFnDest = cFileName('').ImportFullPath(
            uFnFullName=self.oRef.dPars["Dest"])

        self.oWeb = None
        self.oProgressBar = oProgressBar
        self.bFinished = False
        self.bOnError = False
        self.bIsLoading = True
        self.bFirstMessage = True

        StartWait()

        try:
            Logger.debug("LoadOnlineResource: Downloading [%s] to [%s]" %
                         (uUrl, self.oFnDest.string))
            # noinspection PyUnresolvedReferences
            self.uUrl = urllib.parse.quote(uUrl, safe="%/:=&?~#+!$,;'@()*[]")

            #self.uUrl         = urllib.quote(uUrl,safe="%:=&?~#+!$,;'@()*[]")
            #todo: fix ocaremote ssl problem and remove verify=false
            self.oWeb = UrlRequest(self.uUrl,
                                   verify=False,
                                   on_success=self.OnSuccess,
                                   on_failure=self.OnFailure,
                                   on_error=self.OnError,
                                   on_progress=self.OnProgress,
                                   decode=False,
                                   file_path=self.oFnDest.string,
                                   debug=False)

            return True
        except Exception as e:
            LogError(uMsg=u'can\'t load online resource LSF: %s to %s' %
                     (self.uUrl, self.oFnDest.string),
                     oException=e)
            self.bFinished = True
            self.bOnError = True
            self.bIsLoading = False
            StopWait()
            SetVar(uVarName="DOWNLOADERROR", oVarValue="1")
            # noinspection PyUnresolvedReferences
            self.dispatch('on_download_finished')
            return False
示例#4
0
    def LoadSingleFile(self, sRef, oProgressBar):
        """
        Loads a single resource by web
        dispatches on_download_finished when finished
        """

        self.oRef = cDownLoadObject()
        self.oRef.FromString(sRef)

        uUrl = self.oRef.aPars["Url"]
        self.uDest = self.oRef.aPars["Dest"]
        self.uTarget = self.oRef.aPars["Target"]
        self.uType = self.oRef.aPars["Type"]
        self.uName = self.oRef.aPars["Name"]
        self.uVersion = self.oRef.aPars["Version"]

        self.oWeb = None
        self.oProgressBar = oProgressBar
        self.bFinished = False
        self.bOnError = False
        self.bIsLoading = True
        self.bFirstMessage = True

        StartWait()

        try:
            Logger.debug("LoadOnlineResource: Downloading [%s] to [%s]" %
                         (uUrl, self.uDest))
            if PY2:
                self.uUrl = urllib.quote(uUrl, safe="%/:=&?~#+!$,;'@()*[]")
            else:
                self.uUrl = urllib.parse.quote(uUrl,
                                               safe="%/:=&?~#+!$,;'@()*[]")

            #self.uUrl         = urllib.quote(uUrl,safe="%:=&?~#+!$,;'@()*[]")
            self.oWeb = UrlRequest(self.uUrl,
                                   on_success=self.OnSuccess,
                                   on_failure=self.OnFailure,
                                   on_error=self.OnError,
                                   on_progress=self.OnProgress,
                                   decode=False,
                                   file_path=self.uDest,
                                   debug=False)

            return True
        except Exception as e:
            LogError(
                u'can\'t load online resource: %s to %s' %
                (self.uUrl, self.uDest), e)
            self.bFinished = True
            self.bOnError = True
            self.bIsLoading = False
            StopWait()
            SetVar(uVarName="DOWNLOADERROR", oVarValue="1")
            self.dispatch('on_download_finished')
            return False
示例#5
0
 def CancelWaitForConnectivity(self, *largs):
     """ Called, when the user pushes the cancel button """
     if self.oThread is not None:
         self.oThread.join()
     self.bCancel = True
     self.bIsWaiting = False
     self.oPopup = None
     StopWait()
     self.bIsWaiting = False  #
     self.dispatch('on_waitforconnectivity_finished')
示例#6
0
 def CancelCheckPermissions(self, *largs):
     """ Called, when the user pushes the cancel button """
     if self.oThread is not None:
         self.oThread.join()
     self.bCancel = True
     self.bIsWaiting = False
     self.oPopup = None
     StopWait()
     self.bIsWaiting = False  #
     # noinspection PyUnresolvedReferences
     self.dispatch('on_checkpermissions_finished')
示例#7
0
 def RestartAfterRepositoryUpdate(self, *largs):
     """
     Restarts ORCA, after a definition has been updated
     """
     Globals.oOrcaConfigParser.set(u'ORCA', u'lastinstalledversion',
                                   str(Globals.iVersion))
     Globals.oOrcaConfigParser.write()
     Globals.iLastInstalledVersion = Globals.iVersion
     StopWait()
     self.ReStart()
     return True
示例#8
0
 def OnFailure(self, request, result):
     """ Handle an FTP Failure event """
     self.bFinished = True
     self.bOnError = True
     cFileName('').ImportFullPath(self.uDest).Delete()
     LogError(u'can\'t load online resource: %s to %s [%s]' %
              (self.uUrl, self.uDest, result))
     self.OnSuccess(None, None)
     self.bIsLoading = False
     SetVar(uVarName="DOWNLOADERROR", oVarValue="1")
     StopWait()
     return
示例#9
0
 def OnFailure(self, request, result) -> None:
     """ Handle an FTP Failure event """
     self.bFinished = True
     self.bOnError = True
     self.oFnDest.Delete()
     LogError(uMsg=u'can\'t load online resource OnFailure: %s to %s [%s]' %
              (self.uUrl, self.oFnDest.string, result))
     self.OnSuccess(None, None)
     self.bIsLoading = False
     SetVar(uVarName="DOWNLOADERROR", oVarValue="1")
     StopWait()
     return
示例#10
0
    def OnSuccess(self, request, result):
        """ Handles when the download of a single file finishes  """
        self.bIsLoading = False
        self.dispatch('on_download_finished')
        self.bFinished = True

        oFileName = cFileName().ImportFullPath(self.uDest)
        if not oFileName.Exists():
            Logger.error("Target File not found:" + oFileName.string)
            self.bOnError = True

        if not self.bOnError:
            self.Finish()
        StopWait()
示例#11
0
    def OnSuccess(self, request, result) -> None:
        """ Handles when the download of a single file finishes  """
        self.bIsLoading = False
        # noinspection PyUnresolvedReferences
        self.dispatch('on_download_finished')
        self.bFinished = True

        if not self.oFnDest.Exists():
            Logger.error("Target File not found:" + self.oFnDest.string)
            self.bOnError = True

        if not self.bOnError:
            self.Finish()
        StopWait()
示例#12
0
    def OnKey(self, window, uKey: str) -> bool:

        # Logger.debug (u'ScreenPage: KeyPressed: '+uKey)

        # Fallback to prevent unstoppable apps
        if uKey == 'key_ESC':
            self.iESCPressCount += 1
            if self.iESCPressCount > 2:
                StopWait()
                aActions = Globals.oActions.GetActionList(
                    uActionName="askonexit", bNoCopy=False)
                if aActions is not None:
                    Globals.oEvents.ExecuteActions(aActions=aActions,
                                                   oParentWidget=None)
        else:
            self.iESCPressCount = 0

        return True
示例#13
0
 def fktContinue(self, *largs):
     """ Stops waiting and continues ORCA """
     StopWait()
示例#14
0
 def __fktExecuteActionShowQuestionOption2(self, *largs):
     StopWait()
     if self.oQuestionAction.uActionNo != "" and self.oQuestionAction.uActionNo != u'dummy':
         self.__fktExecuteActionShowQuestionOption(
             self.oQuestionAction.uActionNo)
示例#15
0
    def ExecuteActionShowQuestion(self, oAction):
        """
        WikiDoc:Doc
        WikiDoc:Context:ActionsDetails
        WikiDoc:Page:Actions-ShowQuestion
        WikiDoc:TOCTitle:showquestion
        = showquestion =
        This actions open a separate page where the user can answer a question. Can be used to show a popup message as well

        <div style="overflow:auto; ">
        {| class="wikitable"
        ! align="left" | Attribute
        ! align="left" | Description
        |-
        |string
        |showquestion
        |-
        |title
        |Title of the question-popup
        |-
        |message
        |Message for the question bar popup (normally the question)
        |-
        |actionyes
        |Name of the action to called, if the user presses the Yes button
        |-
        |actionno
        |Name of the action to called, if the user presses the No button
        |-
        |dontstopqueue
        |Doesn't stop the queue (if set to any value). As standard, the queue will be stopped until the answer to the question has been given.
        |-
        |close
        |Closes the question popup. Use it only, when you used the dontstopqueue flag
        |}</div>

        A short example:
        <div style="overflow-x: auto;"><syntaxhighlight  lang="xml">
        <action name="My Qustion" string="showquestion" title="Mytitle" message="MyMessage" actionyes="myYesAction" actionno="myNoAction"/>
        </syntaxhighlight></div>
        WikiDoc:End
        """

        self.oEvenDispatcher.LogAction(u'ShowQuestion', oAction)

        oAction.uTitle = ReplaceVars(oAction.dActionPars.get("title", ""))
        oAction.uMessage = ReplaceVars(oAction.dActionPars.get("message", ""))
        oAction.uActionYes = ReplaceVars(
            oAction.dActionPars.get("actionyes", ""))
        oAction.uActionNo = ReplaceVars(oAction.dActionPars.get(
            "actionno", ""))
        uClose = ReplaceVars(oAction.dActionPars.get("close", ""))
        uDontStopQueue = ReplaceVars(
            oAction.dActionPars.get("dontstopqueue", ""))

        if uClose:
            if self.oQuestionAction:
                StopWait()
                self.oQuestionAction.oQuestionPopup.ClosePopup()
                return -2
        if uDontStopQueue == "":
            StartWait()
        self.oQuestionAction = oAction
        if oAction.uActionYes == '' and oAction.uActionNo == '':
            self.oQuestionAction.oQuestionPopup = ShowQuestionPopUp(
                uTitle=oAction.uTitle,
                uMessage=oAction.uMessage,
                uSound=u'message')
        elif oAction.uActionNo == '':
            self.oQuestionAction.oQuestionPopup = ShowQuestionPopUp(
                uTitle=oAction.uTitle,
                uMessage=oAction.uMessage,
                fktYes=self.__fktExecuteActionShowQuestionOption1,
                uStringYes='$lvar(5000)',
                uSound=u'message')
        else:
            self.oQuestionAction.oQuestionPopup = ShowQuestionPopUp(
                uTitle=oAction.uTitle,
                uMessage=oAction.uMessage,
                fktYes=self.__fktExecuteActionShowQuestionOption1,
                fktNo=self.__fktExecuteActionShowQuestionOption2,
                uStringYes='$lvar(5001)',
                uStringNo='$lvar(5002)',
                uSound=u'message')
        self.oQuestionAction.oQuestionPopup.bPreventCloseOnEscKey = True
        return -2
示例#16
0
    def DownloadDownloadQueue(self) -> None:
        """ starts to load the complete queue """

        uRep: str
        tRep: Tuple
        bDoRestart: bool = False
        bDoRefresh: bool = False

        if "setting" in Globals.oTheScreen.uCurrentPageName.lower():
            bDoRefresh = True

        oEvents = Globals.oEvents

        for uRep in self.aQueue:
            if uRep.startswith("definitions"):
                bDoRestart = True

        aActions: List[cAction] = oEvents.CreateSimpleActionList(
            aActions=[{
                'string': 'setvar',
                'varname': 'DOWNLOADERROR',
                'varvalue': '0'
            }, {
                'string': 'showprogressbar',
                'title': '$lvar(5015)',
                'message': 'Load File',
                'max': '100'
            }])

        for uItem in self.aItemQueue:
            uType: str = ToDic(uItem)['Type']
            uPrettyRepName: str = '?'
            for tRep in Globals.aRepNames:
                if tRep[1] == uType:
                    uPrettyRepName = ReplaceVars(tRep[0])
                    break

            uName: str = '%s: %s' % (uPrettyRepName, ToDic(uItem)['Name'])
            oEvents.AddToSimpleActionList(aActionList=aActions,
                                          aActions=[{
                                              'string': 'showprogressbar',
                                              'message': uName,
                                              'current': '0'
                                          }, {
                                              'string':
                                              'loadresource',
                                              'resourcereference':
                                              uItem,
                                              'condition':
                                              "$var(DOWNLOADERROR)==0"
                                          }])

        oEvents.AddToSimpleActionList(aActionList=aActions,
                                      aActions=[{
                                          'string': 'showprogressbar'
                                      }, {
                                          'string':
                                          'showquestion',
                                          'title':
                                          '$lvar(595)',
                                          'message':
                                          '$lvar(698)',
                                          'actionyes':
                                          'dummy',
                                          'condition':
                                          '$var(DOWNLOADERROR)==1'
                                      }])

        if bDoRefresh and not bDoRestart:
            oEvents.AddToSimpleActionList(aActionList=aActions,
                                          aActions=[{
                                              'string':
                                              'updatewidget',
                                              'widgetname':
                                              'SettingsDownload'
                                          }])

        if bDoRestart:
            oEvents.AddToSimpleActionList(aActionList=aActions,
                                          aActions=[{
                                              'string':
                                              'restartafterdefinitiondownload',
                                              'condition':
                                              '$var(DOWNLOADERROR)==0'
                                          }])

        #Execute the Queue
        StopWait()
        oEvents.ExecuteActionsNewQueue(aActions=aActions, oParentWidget=None)
示例#17
0
 def __fktExecuteActionShowQuestionOption1(self, *largs) -> None:
     StopWait()
     if self.oQuestionAction.uActionYes != "" and self.oQuestionAction.uActionYes != u'dummy':
         self.__fktExecuteActionShowQuestionOption(
             self.oQuestionAction.uActionYes)