Ejemplo n.º 1
0
 def __ParseXMLActions(self, oXMLNode, aActions):
     for oXMLAction in oXMLNode.findall('action'):
         oTmpAction = cAction()
         oTmpAction.ParseAction(oXMLAction, None)
         aActions.append(oTmpAction)
     # If we got no child actions, then we use the Command Tag as a single action
     if len(aActions) == 0:
         oTmpAction = cAction()
         oTmpAction.ParseAction(oXMLNode, None)
         aActions.append(oTmpAction)
Ejemplo n.º 2
0
 def __ParseXMLActions(self, *, oXMLNode: Element, aActions: List[cAction],
                       uFunctionName: str) -> None:
     bFound: bool = False
     oXMLAction: List[Element]
     for oXMLAction in oXMLNode.findall('action'):
         aActions.append(
             cAction(pars=oXMLAction, functionname=uFunctionName))
         bFound = True
     # If we got no child actions, then we use the Command Tag as a single action
     if not bFound:
         aActions.append(cAction(pars=oXMLNode, functionname=uFunctionName))
Ejemplo n.º 3
0
    def AddActions(self, *, aActions: List[cAction],
                   oParentWidget: cWidgetBase) -> None:
        """ This functions just adds the action commands to the queue """

        oTmpAction: cAction
        oAction: cAction
        iActionId: int

        for oTmpAction in aActions:
            oAction = copy(oTmpAction)
            oAction.oParentWidget = oParentWidget

            iActionId = oAction.iActionId
            ''' this enables to any function to call without call statement from an macro, as long as the action exists'''
            if iActionId == Globals.oActions.oActionType.NoAction:
                if oAction.uActionString.lower() != "noaction":
                    oAction.iActionId = -1
                    aTmpActions = Globals.oActions.GetActionList(
                        uActionName=oAction.uActionString, bNoCopy=True)
                    if aTmpActions is not None:
                        iActionId = aTmpActions[0].iActionId

            if iActionId == Globals.oActions.oActionType.SendCommand:
                self.__InsertToQueue(oAction=cAction(
                    actionname='enabletransmitterpicture'))
            if iActionId == Globals.oActions.oActionType.ShowPage:
                self.__InsertToQueue(oAction=cAction(
                    actionname='PAGESTOPACTIONS', actionstring="call"))

            self.__InsertToQueue(oAction=oAction)

            if iActionId == Globals.oActions.oActionType.ShowPage:
                oTmpAction = copy(oTmpAction)
                uPagenameToCall = oAction.dActionPars.get('pagename', '')
                if uPagenameToCall == "":
                    if oAction.oParentWidget is not None:
                        if hasattr(oAction.oParentWidget, "dActionPars"):
                            uPagenameToCall = oAction.oParentWidget.dActionPars.get(
                                'pagename', '')
                oTmpAction.dActionPars['string'] = 'call'
                oTmpAction.dActionPars['actionname'] = 'PAGESTARTACTIONS'
                oTmpAction.dActionPars['pagename'] = uPagenameToCall
                oTmpAction.dActionPars['currentpagename'] = GetVar(
                    uVarName='CURRENTPAGE')
                oTmpAction.iActionId = GetActionID(
                    oTmpAction.dActionPars['string'])
                self.__InsertToQueue(oAction=oTmpAction)
            if iActionId == Globals.oActions.oActionType.SendCommand:
                self.__InsertToQueue(oAction=cAction(
                    actionname='disabletransmitterpicture'))
Ejemplo n.º 4
0
        def Connect(self) -> bool:

            if self.oResultParser is None:
                # Initiate Resultparser
                self.oInterFace.ParseResult(cAction(),"",self)

            # if not cBaseInterFaceSettings.Connect(self):
            if not super().Connect():
                return False

            if (self.aIniSettings.uHost=="") or (self.aIniSettings.uPort==u""):
                self.ShowError(uMsg=u'Cannot connect on empty host of port ')
                self.bOnError=True
                return False

            try:
                self.oSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
                self.oSocket.setblocking(False)
                self.oSocket.setsockopt( socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
                self.oSocket.setsockopt( socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
                self.oSocket.settimeout(self.aIniSettings.fTimeOut)
                self.oSocket.connect((str(self.aIniSettings.uHost),int(self.aIniSettings.uPort)))
                if self.oThread:
                    self.bStopThreadEvent = True
                    self.oThread.join()
                    self.oThread = None

                self.oThread = Thread(target = self.Receive,)
                self.bStopThreadEvent = False
                self.oThread.oParent = self
                self.oThread.start()
            except socket.error as e:
                self.ShowError(uMsg=u'Cannot open socket:'+self.aIniSettings.uHost+':'+self.aIniSettings.uPort,oException=e)
                self.oSocket.close()
                self.oSocket = None
            except Exception as e:
                self.ShowError(uMsg=u'Cannot open socket#2:'+self.aIniSettings.uHost+':'+self.aIniSettings.uPort,oException=e)
                self.bOnError=True

            if self.oSocket is None:
                self.bOnError=True
                return False

            self.bIsConnected =True
            return self.bIsConnected
Ejemplo n.º 5
0
def CheckCondition(oPar):
    """
    Checks if a condition is true
    We check for Single Click and Double Click
    ConditionTypes: '==' , '!='  compares Strings
    ConditionTypes: '<' , '>' compares Integers )
    ConditionVar / ConditionValue: If Starts if '$' , the Application Vars are referenced

    :rtype: bool
    :param cAction|dict oPar: Either an cAction or a dict
    :return: True, if condition checks to true
    """

    if oPar.__class__.__name__ == "cAction":
        oAction = oPar
        oPar = oAction.dActionPars
    else:
        oAction = cAction()

    uConditionCheckType = oPar.get(u'conditionchecktype')
    uCondition = oPar.get(u'condition')
    uContext = oPar.get(u"varcontext", "")

    if uConditionCheckType is None:
        if uCondition is None:
            return True

    uConditionVar = oPar.get(u'conditionvar')
    uConditionValue = oPar.get(u'conditionvalue')

    if uCondition != '' and uCondition is not None:
        uConditionCheckType, uConditionVar, uConditionValue = SplitCondition(
            uCondition)

    bRet = False

    try:
        if not oAction.oParentWidget is None:
            if not oAction.uActionTapType == u'both':
                if oAction.uActionTapType == u'single':
                    if oAction.oParentWidget.bDoubleTap:
                        return bRet
                if oAction.uActionTapType == u'double':
                    if not oAction.oParentWidget.bDoubleTap:
                        return bRet

        if uConditionCheckType == u'':
            return True
        uVar = ReplaceVars(uConditionVar, uContext)
        if uVar.startswith('$var('):
            uVar = ReplaceVars(uVar, uContext)

        uValue = ReplaceVars(uConditionValue, uContext)
        uConditionCheckType = ReplaceVars(uConditionCheckType, uContext)
        if uConditionCheckType == u'==' or uConditionCheckType == u'=':
            if uVar == uValue:
                bRet = True
        elif uConditionCheckType == u'!=' or uConditionCheckType == u'<>':
            if uVar != uValue:
                bRet = True
        else:
            fValue, bIsValue = ToFloat2(uValue)
            fVar, bIsVar = ToFloat2(uVar)

            if bIsValue and bIsVar:
                if uConditionCheckType == u'>':
                    if fVar > fValue:
                        bRet = True
                elif uConditionCheckType == u'>=':
                    if fVar >= fValue:
                        bRet = True
                elif uConditionCheckType == u'<':
                    if fVar < fValue:
                        bRet = True
                elif uConditionCheckType == u'<=':
                    if fVar <= fValue:
                        bRet = True
    except Exception as e:
        uMsg = LogError(
            u'CheckCondition: Cannot validate option: %s %s %s' %
            (uConditionVar, uConditionCheckType, uConditionValue), e)
        Logger.error(uMsg)
        ShowErrorPopUp(uMessage=uMsg)
        return False

    Logger.debug(
        "Checking condition [%s]:[%s][%s][%s] returns %s" %
        (uConditionVar, uVar, uConditionCheckType, uValue[:100], str(bRet)))

    return bRet
Ejemplo n.º 6
0
 def __fktExecuteActionShowQuestionOption(self, uActionName):
     if not uActionName == u'':
         oAction = cAction()
         oAction.dActionPars = {'string': 'call', 'actionname': uActionName}
         oAction.iActionId = Globals.oActions.oActionType.Call
         self.oEvenDispatcher.ExecuteAction(oAction)
Ejemplo n.º 7
0
 def __fktExecuteActionShowQuestionOption(self,uActionName):
     if not uActionName==u'':
         oAction=cAction()
         oAction.aActionPars={'string':'call','actionname':uActionName}
         oAction.iActionId = oActionType.Call
         self.oEvenDispatcher.ExecuteAction(oAction)
Ejemplo n.º 8
0
 def GetActionObject(self):
     ''' litte hacky to bypass some import issues '''
     oAction = cAction()
     return oAction