Ejemplo n.º 1
0
    def Start(self):
        """ create the popup """
        oContent = BoxLayout(spacing='5dp', orientation='vertical')
        self.oPopup = popup = Popup(content=oContent,
                                    title=ReplaceVars('$lvar(666)'),
                                    size_hint=(0.95, 0.95),
                                    auto_dismiss=False)

        #we need to open the popup first to get the metrics
        popup.open()
        #todo: check sXML reference
        #self.oXMLText=TextInput(text=oDBSelector.sXML)
        oContent.add_widget(self.oXMLText)
        oContent.add_widget(SettingSpacer())

        # 2 buttons are created for save or cancel the current file
        oBtnlayout = BoxLayout(size_hint_y=None, height='50dp', spacing='5dp')
        oBtn = Button(text=ReplaceVars('$lvar(5025)'))
        oBtn.bind(on_release=self.On_Save)
        oBtnlayout.add_widget(oBtn)
        oBtn = Button(text=ReplaceVars('$lvar(5009)'))
        oBtn.bind(on_release=self.oPopup.dismiss)
        oBtnlayout.add_widget(oBtn)
        oContent.add_widget(oBtnlayout)
        self.oXMLText.cursor = (0, 0)
Ejemplo n.º 2
0
    def Dump(self, iIndent):
        """ Dumps a specific action """

        uOut = " " * iIndent
        if self.uActionName:
            uOut += self.uActionName + ": "
        for uAttributName in self.__dict__:
            oValue = self.__dict__[uAttributName]
            if isinstance(oValue, string_types):
                if not "$var" in oValue:
                    uOut += "'%s'='%s' , " % (uAttributName, oValue)
                else:
                    uOut += "'%s'='%s [%s]' , " % (uAttributName, oValue,
                                                   ReplaceVars(oValue))

            elif isinstance(oValue, dict):
                uOut = uOut + uAttributName + ":{"
                for uKey in oValue:
                    if uKey != "name":
                        uValue = oValue[uKey]
                        if not "$var" in uValue:
                            uOut += "'%s'='%s' , " % (uKey, uValue)
                        else:
                            uOut += "'%s'='%s [%s]' , " % (uKey, uValue,
                                                           ReplaceVars(uValue))

                uOut += "} "

        Logger.debug(uOut)
Ejemplo n.º 3
0
        def Connect(self) -> bool:

            if not super().Connect():
                return False

            self.ShowDebug(uMsg=u'Interface trying to connect...')

            try:
                if self.oWebSocket is None or self.oWebSocket.sock is None:
                    uURL = ReplaceVars(self.aIniSettings.uService)
                    uURL = ReplaceVars(
                        uURL, self.oInterFace.uObjectName + '/' +
                        self.uConfigName + "CONFIG_")
                    self.oWebSocket = self.cWebSocketClient(uURL,
                                                            heartbeat_freq=2.0)
                    self.oWebSocket.SetSettingObject(self)
                self.oWebSocket.connect()
                self.bInConnect = True
                self.bIsConnected = True
                self.ExecuteStandardAction('logon')
                self.bInConnect = False
                self.bIsConnected = True
            except Exception as e:
                self.ShowError(
                    uMsg=u'Interface not connected: Cannot open socket #2:' +
                    self.aIniSettings.uHost + ':' + self.aIniSettings.uPort,
                    oException=e)
                self.bOnError = True
                return False

            self.ShowDebug(uMsg=u'Interface connected!')
            return True
Ejemplo n.º 4
0
    def ExecuteActionSetDefinitionVar(self, oAction: cAction) -> eReturnCode:
        """
        setdefinitionvar:
            sets a definition variable with a value
            Parameter:
            varname:  variable to use
            varvalue: value to set
            definitionname: Name of the definition
        """

        uVarName: str = ReplaceVars(oAction.dActionPars.get("varname", ""))
        uVarValue: str = ReplaceVars(oAction.dActionPars.get("varvalue", ""))
        uDefinitionName: str = ReplaceVars(
            oAction.dActionPars.get("definitionname", ""))
        oDef: cDefinition

        self.oEventDispatcher.LogAction(uTxt=u'SetDefinitionVar',
                                        oAction=oAction)
        if uDefinitionName == "":
            oDef = Globals.oDefinitions[0]
        else:
            oDef = Globals.oDefinitions[uDefinitionName]
        if oDef:
            if uVarValue != u'':
                oDef.oDefinitionVars[uVarName] = uVarValue
            else:
                if uVarName in oDef.oDefinitionVars:
                    del oDef.oDefinitionVars[uVarName]
            return eReturnCode.Nothing
        else:
            LogError(uMsg=u'Action: SetDefinitionVar: Can'
                     't find definition:' + uDefinitionName)
        return eReturnCode.Error
Ejemplo n.º 5
0
def Var_Find(uVarName, uFindVar, uDestVar):
    """
    Finds the posiion of a substring in a variable value.
    The changed variable value will be returned and stored in the destination var (Triggers raised if set)

    :rtype: string
    :param string uVarName: The variable name for the action, from where the value is pulled
    :param string uFindVar: The string to search for
    :param string uDestVar: The name of the variable for the result (the Position) If not found, '-1' will be returned
    :return: The position of the substring
    """

    uValue = GetVar(uVarName=uVarName)
    uValue = uVarName
    if uValue == u'':
        uValue = uVarName
    uValue = ReplaceVars(uValue)

    uFindVar = ReplaceVars(uFindVar)
    iPos = uValue.find(uFindVar)
    uResult = ToUnicode(iPos)
    SetVar(uVarName=uDestVar, oVarValue=uResult)
    Logger.debug(u'Var_Find: [%s] in [%s] returned [%s]  (stored in [%s])' %
                 (uFindVar, uValue, uResult, uDestVar))
    return uResult
Ejemplo n.º 6
0
    def _create_popup(self, instance) -> None:
        """ create popup layout  """
        oContent:BoxLayout = BoxLayout(orientation='vertical', spacing='5dp')
        self.popup = popup = Popup(title=self.title,content=oContent, size_hint=(0.9, 0.9))

        # Create the slider used for numeric input
        oColorpicker:ColorPicker = ColorPicker()
        self.oColorpicker = oColorpicker

        oContent.add_widget(oColorpicker)
        oContent.add_widget(SettingSpacer())

        oBtn:cMultiLineButton

        # 2 buttons are created for accept or cancel the current value
        oBtnlayout:BoxLayout = BoxLayout(size_hint_y=None, height='50dp', spacing='5dp')
        oBtn = cMultiLineButton(text=ReplaceVars('$lvar(5008)'), halign='center', valign='middle')
        oBtn.bind(on_release=self._validate)
        oBtnlayout.add_widget(oBtn)
        oBtn = cMultiLineButton(text=ReplaceVars('$lvar(5009)'), halign='center', valign='middle')
        oBtn.bind(on_release=self._dismiss)
        oBtnlayout.add_widget(oBtn)
        oContent.add_widget(oBtnlayout)
        oColorpicker.bind(color= self.On_Color)
        # all done, open the popup !

        oColorpicker.hex_color = self.value

        popup.open()
Ejemplo n.º 7
0
    def ELV_getattribute(self, oSetting: cInterFaceSettings, oAction: cAction,
                         dParams: Dict) -> List[TypedQueryDict]:
        """
        Returns a attribut for a device or room

        :param cInterface.cInterFaceSettings oSetting: The setting object
        :param cAction oAction: The action object (unused)
        :param dict dParams: The parameter, needs to include rf_address and attributename
        :return: dict: key:result=Error or result=attributevalue, attributevalue=n/a if attribute not found
        """

        oDevice: MaxCube

        uRF_Address: str = ReplaceVars(
            dParams["rf_address"],
            self.uObjectName + u'/' + oSetting.uConfigName)
        uAttribute: str = ReplaceVars(
            dParams["attributename"],
            self.uObjectName + u'/' + oSetting.uConfigName)

        try:
            oDevice = oSetting.oDevice.device_by_rf(uRF_Address)
            uRet: str = getattr(oDevice, uAttribute, "N/A")
            if uRet is None:
                uRet = "N/A"
        except Exception as e:
            uRet = "N/A"

        if uRet == "N/A":
            Logger.error(uAttribute)

        return self._CreateSimpleResult(uRet)
Ejemplo n.º 8
0
    def ExecuteActionRegisterNotification_sub(self,
                                              oAction: cAction) -> eReturnCode:
        uNotification: str = ReplaceVars(
            oAction.dActionPars.get("notification", ""))
        uActionName: str = ReplaceVars(
            oAction.dActionPars.get("notifyaction", ""))

        uRegisterOption: str = oAction.dActionPars.get("registeroption",
                                                       "replace")
        uFilterPageName: str = oAction.dActionPars.get("filterpagename", "")
        if uRegisterOption == "append":
            Globals.oNotifications.RegisterNotification(
                uNotification=uNotification,
                fNotifyFunction=self.NotificationHandler,
                uDescription="Action:" + uActionName,
                bQuiet=True,
                **oAction.dActionPars)
        else:
            uKey: str = uNotification + "_" + uFilterPageName
            iHash: int = Globals.oNotifications.dFilterPageNames.get(uKey, 0)
            if iHash != 0:
                Globals.oNotifications.UnRegisterNotification_ByHash(
                    iHash=iHash)
            Globals.oNotifications.RegisterNotification(
                uNotification=uNotification,
                fNotifyFunction=self.NotificationHandler,
                uDescription="Action:" + uActionName,
                bQuiet=True,
                **oAction.dActionPars)
        return eReturnCode.Nothing
Ejemplo n.º 9
0
    def ShowList(self):
        """ Shows the discover results """
        # create the popup
        oContent         = GridLayout(cols=1, spacing='5dp')
        oScrollview      = ScrollView( do_scroll_x=False)
        self.oScrollContent   = StackLayout(size_hint=(None, None))
        self.oPopup   = oPopup = Popup(content=oContent, title=ReplaceVars('$lvar(5028)'), size_hint=(0.9, 0.9),  auto_dismiss=False)

        #we need to open the popup first to get the metrics
        oPopup.open()
        #Add some space on top
        oContent.add_widget(Widget(size_hint_y=None, height=dp(2)))
        aDiscoverScripts=Globals.oScripts.GetScriptListForScriptType("DEVICE_DISCOVER")
        aScrollContent=[]
        for uDiscoverScriptName in aDiscoverScripts:
            oScrollContentSingle   = GridLayout(size_hint=(None, None),size=(oPopup.width, dp(10)))
            aScrollContent.append(oScrollContentSingle)
            oScrollContentSingle.bind(minimum_height=oScrollContentSingle.setter('height'))
            Globals.oScripts.RunScript(uDiscoverScriptName,**{'createlist':1,'oGrid':oScrollContentSingle})
            self.oScrollContent.add_widget(cLabel(text=Globals.oScripts.dScripts[uDiscoverScriptName].uSubType, background_color=[0.2, 0.2, 0.2, 1.0], color=[0.2, 0.9, 0.9, 1.0], size=(oPopup.width, dp(30)),size_hint=(None, None), halign='center'))
            self.oScrollContent.add_widget(oScrollContentSingle)
            self.oScrollContent.add_widget(SettingSpacer())

        # finally, add a cancel button to return on the previous panel
        oScrollview.add_widget(self.oScrollContent)
        oContent.add_widget(oScrollview)
        oContent.add_widget(SettingSpacer())

        oBtn = Button(text=ReplaceVars('$lvar(5000)'), size=(oPopup.width, dp(50)),size_hint=(1, None))
        oBtn.bind(on_release=self.On_Cancel)
        oContent.add_widget(oBtn)

        #resize the Scrollcontent to fit to all Childs. Needs to be done, after the popup has been shown
        Clock.schedule_once(self.SetScrollSize, 0)
Ejemplo n.º 10
0
    def ExecuteAction(self,oAction):
        """ Executes a single action in a queue (excluding condition verifying)"""

        try:
            oAction.uActionString=ReplaceVars(oAction.uActionString)
            oFunction=self.dActionFunctions.get(oAction.iActionId)
            if oFunction:
                return oFunction(oAction)
            else:
                ''' this enables to use standardactions / actions without call, but assigning parameters like interface and configname '''

                aActions=Globals.oActions.GetActionList(uActionName = oAction.uActionString, bNoCopy = True)
                if aActions:
                    if len(aActions)>1:
                        Logger.error("you can''t use multiline actions as short cut, use call instead")

                    oFunction=self.dActionFunctions.get(aActions[0].iActionId)
                    if oFunction:
                        oAction.uActionString=ReplaceVars(aActions[0].uActionString)
                        self.CopyActionPars(dTarget=oAction.dActionPars,dSource=aActions[0].dActionPars,uReplaceOption="donotreplacetarget")
                        if not oAction.uRetVar:
                            oAction.uRetVar=aActions[0].uRetVar
                        return oFunction(oAction)
                Logger.error("ExecuteAction: Action not Found:"+oAction.uActionName+':'+oAction.uActionString)
                return 0
        except Exception as e:
            uMsg=LogError('Error executing Action:'+self.CreateDebugLine(oAction=oAction, uTxt=''),e)
            ShowErrorPopUp(uMessage=uMsg)
            return False

        return False
Ejemplo n.º 11
0
    def __init__(self, **kwargs):
        kwargs['orientation'] = 'vertical'
        super(cITachToKeene, self).__init__(
            **RemoveNoClassArgs(dInArgs=kwargs, oObject=BoxLayout))
        self.uCodesetFileName: str = ''
        self.oLayoutHeaders: BoxLayout = BoxLayout(size_hint_y=None, height=30)
        self.oLayoutButtons: BoxLayout = BoxLayout(size_hint_y=None, height=30)
        self.oLayoutPanels: BoxLayout = BoxLayout()
        self.add_widget(self.oLayoutHeaders)
        self.add_widget(SettingSpacer())
        self.add_widget(self.oLayoutPanels)
        self.add_widget(SettingSpacer())
        self.add_widget(self.oLayoutButtons)

        self.oTextInput: TextInput = TextInput()
        self.oTextInput2: TextInput = TextInput()
        self.oLayoutPanels.add_widget(self.oTextInput)
        self.oLayoutPanels.add_widget(self.oTextInput2)

        self.oButtonLoad: Button = Button(text=ReplaceVars('$lvar(563)'))
        self.oButtonSave: Button = Button(text=ReplaceVars('$lvar(5025)'))
        self.oButtonLoad.bind(on_release=self.show_load)
        self.oButtonSave.bind(on_release=self.show_save)
        self.oLayoutButtons.add_widget(self.oButtonLoad)
        self.oLayoutButtons.add_widget(self.oButtonSave)

        self.oLabelITach: Label = Label(text="ITach", halign='center')
        self.oLabelKeene: Label = Label(text="Keene Kira", halign='center')
        self.oLayoutHeaders.add_widget(self.oLabelITach)
        self.oLayoutHeaders.add_widget(self.oLabelKeene)

        self.oContent: Union[FileBrowser, None] = None
        self._popup: Union[Popup, None] = None
        self.oXMLCodeset: Union[Element, None] = None
Ejemplo n.º 12
0
    def ExecuteActionSendNotification(self,oAction):
        """
        WikiDoc:Doc
        WikiDoc:Context:ActionsDetails
        WikiDoc:Page:Actions-SendNotification
        WikiDoc:TOCTitle:noaction

        = sendnotification =
        Will send an ORCA internal notification
        This action will not modify the error code

        <div style="overflow:auto; ">
        {| border=1 class="wikitable"
        ! align="left" | string
        ! align="left" | notification
        ! align="left" | actionpars
        |-
        |sendnotification
        |notification string to send
        |Optional: Actionpars to be submitted: Format "{'parname1':'varvalue1','parname2':'varvalue2'}"
        |}</div>
        WikiDoc:End
        """

        uNotification                   = ReplaceVars(oAction.dActionPars.get("notification",""))
        dActionPars                     = ToDic(ReplaceVars(oAction.dActionPars.get("actionpars","{}")))
        if not isinstance(dActionPars,dict):
            dActionPars = ToDic(oAction.dActionPars.get("actionpars", "{}"))
        self.oEvenDispatcher.bDoNext    = True
        self.oEvenDispatcher.LogAction(u'SendNotification',oAction)

        Globals.oNotifications.SendNotification(uNotification,**dActionPars)
        return -2
Ejemplo n.º 13
0
    def ExecuteActionGetInterfaceSetting(self, oAction):
        """
        WikiDoc:Doc
        WikiDoc:Context:ActionsDetails
        WikiDoc:Page:Actions-GetInterfaceSetting
        WikiDoc:TOCTitle:getinterfacesetting
        = getinterfacesetting =
        Reads a parameter from the interface.ini file. Important: You can't use this command in the appstart actions.
        <div style="overflow:auto; ">
        {| class="wikitable"
        ! align="left" | Attribute
        ! align="left" | Description
        |-
        |string
        |getinterfacesetting
        |-
        |interfacename
        |Name of the interface
        |-
        |configname
        |Name of the configuration
        |-
        |varname
        |Name of the variable to get
        |-
        |retvar
        |Destination var
        |}</div>
        A short example:
        <div style="overflow-x: auto;"><syntaxhighlight  lang="xml">
        <action name="" string="getinterfacesetting" interfacename="eiscp" configname="myconfig" varname="uHost" retvar="DISCOVERHOST"/>
        </syntaxhighlight></div>
        WikiDoc:End
        """

        self.oEvenDispatcher.bDoNext = True
        self.oEvenDispatcher.LogAction(u'GetInterfaceSetting', oAction)

        uInterfaceName = ReplaceVars(
            oAction.dActionPars.get("interfacename", ""))
        uConfigName = ReplaceVars(oAction.dActionPars.get("configname", ""))
        uVarName = ReplaceVars(oAction.dActionPars.get("varname", ""))
        uRetVar = ReplaceVars(oAction.dActionPars.get("retvar", ""))

        oInterFace = Globals.oInterFaces.dInterfaces.get(uInterfaceName)
        if oInterFace is None:
            Globals.oInterFaces.LoadInterface(uInterfaceName)
            oInterFace = Globals.oInterFaces.dInterfaces.get(uInterfaceName)

        if oInterFace is None:
            LogError(
                u'Action: Get Interface Setting failed: Interface: %s  Interface not found!'
                % (uInterfaceName))
            return 1

        SetVar(uVarName=uRetVar,
               oVarValue=oInterFace.oInterFaceConfig.GetSettingParFromIni(
                   uConfigName, uVarName))

        return 0
Ejemplo n.º 14
0
    def SendCommand(self,
                    oAction: cAction,
                    oSetting: cInterFaceSettings,
                    uRetVar: str,
                    bNoLogOut: bool = False) -> eReturnCode:
        super().SendCommand(oAction=oAction,
                            oSetting=oSetting,
                            uRetVar=uRetVar,
                            bNoLogOut=bNoLogOut)

        uCmd: str
        uCmd = ReplaceVars(oAction.uCmd)
        uCmd = ReplaceVars(uCmd, self.uObjectName + '/' + oSetting.uConfigName)

        self.ShowInfo(uMsg=u'Sending Command: %s to %s (%s:%s)' %
                      (uCmd, oSetting.aIniSettings.uWidgetName,
                       oSetting.uConfigName, oSetting.aIniSettings.uStream))
        oSetting.Connect()

        eRet: eReturnCode = eReturnCode.Error
        if oSetting.bIsConnected:
            try:
                oSetting.oWidgetPlayer.StatusControl(
                    uCmd, oSetting.aIniSettings.uStream)
                eRet = eReturnCode.Success
            except Exception as e:
                self.ShowError(uMsg=u'can\'t Send Message',
                               uParConfigName=u'',
                               oException=e)
                eRet = eReturnCode.Error
        return eRet
Ejemplo n.º 15
0
 def _CreateFinal(self):
     self.bDirty = False
     if self.uRaw:
         self.uFinal = CleanUp(
             ReplaceVars(self.oPath.uRaw) + ReplaceVars(self.uRaw))
     else:
         self.uFinal = u''
Ejemplo n.º 16
0
def GetPlaces() -> List[Tuple[str, cPath]]:
    """
    Returns the list of available user places for the operating system
    """

    oPath: cPath
    aLocPlaces: List[Tuple[str, cPath]] = []
    uPlace: str

    oPath = GetDownloadFolder()
    if oPath.string is not "":
        aLocPlaces.append((ReplaceVars("$lvar(1200)"), oPath))

    oPath = GetDocumentsFolder()
    if oPath.string is not "":
        aLocPlaces.append((ReplaceVars("$lvar(1202)"), oPath))

    oPath = GetPicturesFolder()
    if oPath.string is not "":
        aLocPlaces.append((ReplaceVars("$lvar(1203)"), oPath))

    oPath = GetVideosFolder()
    if oPath.string is not "":
        aLocPlaces.append((ReplaceVars("$lvar(1204)"), oPath))

    oPath = GetMusicFolder()
    if oPath.string is not "":
        aLocPlaces.append((ReplaceVars("$lvar(1205)"), oPath))

    return aLocPlaces
Ejemplo n.º 17
0
 def ReInit(self,uTitle:str,uMessage:str,iMax:int) -> None:
     """ Re-Starts the progressbar """
     self.oPopup.title       = ReplaceVars(uTitle)
     self.oLabel.text        = ReplaceVars(uMessage)
     self.oProgressBar.value = 0
     self.bCancel            = False
     self.SetMax(iMax)
Ejemplo n.º 18
0
    def __init__(self, **kwargs):
        kwargs['orientation'] = 'vertical'
        super(cITachToKeene,
              self).__init__(**RemoveNoClassArgs(kwargs, BoxLayout))
        self.uCodesetFileName = ''

        self.oLayoutHeaders = BoxLayout(size_hint_y=None, height=30)
        self.oLayoutButtons = BoxLayout(size_hint_y=None, height=30)
        self.oLayoutPanels = BoxLayout()
        self.add_widget(self.oLayoutHeaders)
        self.add_widget(SettingSpacer())
        self.add_widget(self.oLayoutPanels)
        self.add_widget(SettingSpacer())
        self.add_widget(self.oLayoutButtons)

        self.oTextInput = TextInput()
        self.oTextInput2 = TextInput()
        self.oLayoutPanels.add_widget(self.oTextInput)
        self.oLayoutPanels.add_widget(self.oTextInput2)

        self.oButtonLoad = Button(text=ReplaceVars('$lvar(563)'))
        self.oButtonSave = Button(text=ReplaceVars('$lvar(5025)'))
        self.oButtonLoad.bind(on_release=self.show_load)
        self.oButtonSave.bind(on_release=self.show_save)
        self.oLayoutButtons.add_widget(self.oButtonLoad)
        self.oLayoutButtons.add_widget(self.oButtonSave)

        self.oLabelITach = Label(text="ITach", halign='center')
        self.oLabelKeene = Label(text="Keene Kira", halign='center')
        self.oLayoutHeaders.add_widget(self.oLabelITach)
        self.oLayoutHeaders.add_widget(self.oLabelKeene)
Ejemplo n.º 19
0
    def Show(self,*,uTitle:str,uMessage:str,iMax:int) -> Popup:
        """ Shows the Popup """
        self.iMax           = iMax
        self.bCancel        = False
        oContent:BoxLayout  = BoxLayout(orientation='vertical', spacing='5dp')
        iHeight:int         = int(Globals.iAppHeight*0.5)
        if Globals.uDeviceOrientation=="landscape":
            iHeight=int(Globals.iAppHeight*0.9)
        self.oPopup         = Popup(title=ReplaceVars(uTitle),content=oContent, size=(Globals.iAppWidth*0.9,iHeight),size_hint=(None, None),auto_dismiss=False)
        self.oLabel         = Label(text=ReplaceVars(uMessage), text_size=(Globals.iAppWidth*0.86, None), shorten=True, valign='top',halign='left')
        self.oProgressText  = Label(valign='top',halign='center',text_size=(Globals.iAppWidth*0.86, None), shorten=True)
        oContent.add_widget(Widget())
        oContent.add_widget(self.oLabel)
        oContent.add_widget(Widget())
        self.oProgressText.text=""

        self.oProgressBar = ProgressBar(size_hint_y=None, height='50dp', max=iMax)
        oContent.add_widget(self.oProgressBar)
        oContent.add_widget(self.oProgressText)
        oContent.add_widget(SettingSpacer())
        oBtn:Button = Button(size_hint_y=None, height='50dp',text=ReplaceVars('$lvar(5009)'))
        oBtn.bind(on_release=self.OnCancel)
        oContent.add_widget(oBtn)
        self.oPopup.open()
        return self.oPopup
Ejemplo n.º 20
0
    def Create(self, oParent: Widget) -> bool:
        """ creates the Widget """
        try:
            self.fMin = ToFloat(ReplaceVars(self.uMin))
            self.fMax = ToFloat(ReplaceVars(self.uMax))
            self.AddArg('min', self.fMin)
            self.AddArg('max', self.fMax)
            self.AddArg('orientation', self.uDeviceOrientation)
            self.AddArg('value', self.fMin)
            self.AddArg('background_pic',
                        ToAtlas(oFileName=self.oFnPictureNormal))
            self.AddArg('button_pic', ToAtlas(oFileName=self.oFnPictureButton))
            if self.CreateBase(Parent=oParent, Class=cSliderEx):
                self.fDataRange = abs(self.fMax - self.fMin)
                self.oObject.bind(on_slider_moved=self.OnNotifyChange)
                # Capability to click on Knobs as well (needs to be implemented)
                if not self.uActionName == u'':
                    self.oObject.bind(on_release=self.On_Button_Up)
                    self.oObject.bind(on_press=self.On_Button_Down)

                self.oParent.add_widget(self.oObject)
                self.UpdateWidget()
                return True
            return False
        except Exception as e:
            LogError(uMsg=u'cWidgetSlider:Unexpected error Creating Object:',
                     oException=e)
            return False
Ejemplo n.º 21
0
    def AddTrigger(self, oAction):
        """
        Adds a trigger

        :param cAction oAction: The Action object to set a trigger
        """

        uTrigger = ReplaceVars(oAction.dActionPars.get("triggername", ""))
        uAction = ReplaceVars(oAction.dActionPars.get("actionname", ""))
        uRetVar = oAction.dActionPars.get("retvar", "")
        uGetVar = oAction.dActionPars.get("getvar", "")

        if uAction != u'' or uRetVar != u'':
            self.ShowDebug(u'Adding Trigger:' + uTrigger,
                           oAction.dActionPars.get(u'configname', u''))
        else:
            self.ShowDebug(u'Delete Trigger:' + uTrigger,
                           oAction.dActionPars.get(u'configname', u''))
        oSetting = self.GetSettingObjectForConfigName(
            oAction.dActionPars.get(u'configname', u''))

        if uAction == u'' and uRetVar == u'':
            oSetting.DelTrigger(uTrigger)
        else:
            oSetting.AddTrigger(uTrigger, uAction, uRetVar, uGetVar)
Ejemplo n.º 22
0
 def ReInit(self, uTitle, uMessage, lMax):
     """ Re-Starts the progressbar """
     self.oPopup.title = ReplaceVars(uTitle)
     self.oLabel.text = ReplaceVars(uMessage)
     self.oProgressBar.value = 0
     self.oProgressBar.max = lMax
     self.lMax = lMax
     self.bCancel = False
Ejemplo n.º 23
0
    def ExecuteActionSetPageEffect(self, oAction):
        """
        WikiDoc:Doc
        WikiDoc:Context:ActionsDetails
        WikiDoc:Page:Actions-SetPageEffect
        WikiDoc:TOCTitle:setpageffect
        = setpageeffect =
        With this action, you can set, how a page is displayed. This is a global parameter, which is active for all showpage actions, until it will be defined again. For some page effects like 'slide', you can set the direction, from where he new page should be shown. This is a global parameter, which is active for all showpage actions, until it will be defined again.
        Please play around with the page effects to get a visual expression of the effect. Find examples in the "showcase" definition

        <div style="overflow:auto; ">
        {| class="wikitable"
        ! align="left" | Attribute
        ! align="left" | Description
        |-
        |string
        |setpageeffect
        |-
        |effect
        |name of the effect, could be
        * 'no'
        * 'fade'
        * 'slide'
        * 'wipe'
        * 'swap'
        * 'fallout'
        * 'risein'
        |-
        |direction
        |direction of the page effect. Valid page effects directions are:
        *'left'
        *'right'
        *'up'
        *'down'
        |}</div>

        A short example:
        <div style="overflow-x: auto;"><syntaxhighlight  lang="xml">
         <action name="Set effect page" string="setpageeffect" effect="side" direction="left"/>
        </syntaxhighlight></div>
        WikiDoc:End
        """

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

        self.oEvenDispatcher.bDoNext = True
        uEffect = ReplaceVars(oAction.dActionPars.get("effect", ""))
        uDirection = ReplaceVars(oAction.dActionPars.get("direction", ""))

        if Globals.oTheScreen.SetPageEffect(uEffect=uEffect):
            if Globals.oTheScreen.SetPageEffectDirection(
                    uDirection=uDirection):
                return 0
            else:
                return 1

        else:
            return 1
Ejemplo n.º 24
0
def BuildSettingsStringOnlineResources() -> str:
    """ Build the settings for the ORCA Online Resource """

    iCountBlanks: int = 0
    i: int
    uReps: str = ''
    uKey: str
    oInstalledRep: cInstalledReps
    aSubList: List[cInstalledReps]

    for i in range(Globals.iCntRepositories):
        if Globals.aRepositories[i] == '':
            iCountBlanks += 1
            if iCountBlanks > 1:
                continue
        uReps += u'{"type": "string","title":    "$lvar(671)","desc": "$lvar(672)","section": "ORCA","key": "repository%d"},\n' % i


    uOrcaSettingsJSON  =u'[{ "type": "title","title":  "$lvar(670)" },\n' \
                        '%s' \
                        u'{ "type": "title","title": "$lvar(680)" },\n' \
                        u'{"type": "buttons","title": "$lvar(681)","desc": "$lvar(682)","section": "ORCA","key": "button_getonline","buttons":[{"title":"$lvar(678)","id":"button_getonline"}]}' \
                        u']' % uReps

    if len(Globals.dInstalledReps) > 0:
        uOrcaSettingsJSON = uOrcaSettingsJSON[:-1]

        aSubList = []

        for (uKey, oInstalledRep) in Globals.dInstalledReps.items():
            aSubList.append(oInstalledRep)
        aSubList.sort(key=lambda x: x.uType)

        uOldType: str = u''
        uOrcaSettingsJSON += u',{ "type": "title","title": "$lvar(679)" },\n'
        for oInstalledRep in aSubList:
            if uOldType != oInstalledRep.uType:
                uOldType = oInstalledRep.uType
                uName = "???"
                for tTup in Globals.aRepNames:
                    if tTup[1] == oInstalledRep.uType:
                        uName = tTup[0]
                uOrcaSettingsJSON += u'{ "type": "title","title": "-> %s" },\n' % uName

            uOrcaSettingsJSON += u'{"type": "buttons","title": "%s","desc": "$lvar(751): %s","section": "ORCA","key": "button_installed_reps","buttons":[{"title":"$lvar(752)","id":"button_updaterep:%s:%s"}]},\n' % (
                oInstalledRep.uName, ToStringVersion(oInstalledRep.iVersion),
                oInstalledRep.uType, oInstalledRep.uName)
        uOrcaSettingsJSON = uOrcaSettingsJSON[:-2]
        uOrcaSettingsJSON += u']'

    uOrcaSettingsJSON = uOrcaSettingsJSON.replace("'", "\'")

    uOrcaSettingsJSON = AddScriptSetting(
        uSettingName="TOOLS",
        uSettingPage=ReplaceVars("$lvar(699)"),
        uOrcaSettingsJSON=uOrcaSettingsJSON)
    uOrcaSettingsJSON = ReplaceVars(uOrcaSettingsJSON)
    return uOrcaSettingsJSON
Ejemplo n.º 25
0
    def GetTargetInterfaceAndConfig(self,oAction):
        """
        Gets the interface and config for an sendcommand action
        If interfaces has not been set, we set the page defaults
        but we need to restore old values, as actions could be used from several pages  """

        uOrgInterFace  =   oAction.dActionPars.get(u'interface',u'')
        uOrgConfigName =   oAction.dActionPars.get(u'configname',u'')

        #Interface / config detection
        #Action Interfaces rules
        #then Widget Interface
        #then Anchor Interface
        #then Page Interface

        uToUseInterFace  = uOrgInterFace
        uToUseConfigName = uOrgConfigName

        if oAction.oParentWidget:
            if uToUseInterFace==u'':
                uToUseInterFace=oAction.oParentWidget.uInterFace
            if uToUseConfigName==u'':
                uToUseConfigName=oAction.oParentWidget.uConfigName

            if uToUseInterFace==u'':
                uAnchorName=oAction.oParentWidget.uAnchorName
                while uAnchorName!=u'':
                    oTmpAnchor=oAction.oParentWidget.oParentScreenPage.dWidgets.get(uAnchorName)
                    if oTmpAnchor:
                        uToUseInterFace=oTmpAnchor.uInterFace
                        uAnchorName=oTmpAnchor.uInterFace
                    if uToUseInterFace!="":
                        break

            if uToUseInterFace==u'':
                uToUseInterFace=oAction.oParentWidget.oParentScreenPage.uDefaultInterface
            if uToUseConfigName==u'':
                uAnchorName=oAction.oParentWidget.uAnchorName
                while uAnchorName!=u'':
                    # oTmpAnchor=oAction.oParentWidget.oParentScreenPage.dWidgets.get(oAction.oParentWidget.uAnchorName)
                    oTmpAnchor = oAction.oParentWidget.oParentScreenPage.dWidgets.get(uAnchorName)
                    if oTmpAnchor:
                        uToUseConfigName=oTmpAnchor.uConfigName
                        uAnchorName=oTmpAnchor.uInterFace
                    if uToUseConfigName!="":
                        break

            if uToUseConfigName==u'':
                uToUseConfigName=oAction.oParentWidget.oParentScreenPage.uDefaultConfigName

        uToUseConfigName = ReplaceVars(uToUseConfigName)
        uToUseInterFace  = ReplaceVars(uToUseInterFace)

        # We already should have loaded all interfaces at Defintionstart, but if this fails caused by heavy var tweaking, we ensure to load it here
        Globals.oInterFaces.LoadInterface(uToUseInterFace)

        return uToUseInterFace,uToUseConfigName
Ejemplo n.º 26
0
    def ConfigureKivySettingsForDiscoverParameter(
            self, oKivySetting: KivySettings,
            uConfigName: str) -> Union[KivyConfigParser, None]:
        """
        Create the JSON string for all discover scripts and applies it to a kivy settings object

        :param setting oKivySetting:
        :param string uConfigName:
        :return: The KivySetting object
        """

        uSettingsJSON: str
        uKey: str
        uDictKey: str

        SetVar(uVarName=u'ObjectConfigSection', oVarValue=uConfigName)
        self.uConfigName = uConfigName
        RegisterSettingTypes(oKivySetting)
        oSetting: cBaseInterFaceSettings = self.oInterFace.GetSettingObjectForConfigName(
            uConfigName=uConfigName)
        dSettingsJSON: Dict[str, Dict] = self.CreateSettingJsonCombined(
            oSetting=oSetting)
        if len(dSettingsJSON) == 0:
            return None
            # return self.On_SettingsClose(None)

        # add the jSon to the Kivy Setting

        dTarget: Dict[str, Dict] = {}
        for uKey in dSettingsJSON:
            uDictKey = dSettingsJSON[uKey]['scriptsection']
            if dTarget.get(uDictKey) is None:
                dTarget[uDictKey] = {}
            dTarget[uDictKey][uKey] = dSettingsJSON[uKey]

        for uKey in dTarget:
            if not uKey.startswith('discover'):
                uSettingsJSON = SettingDictToString2(dTarget[uKey])
                uSettingsJSON = ReplaceVars(uSettingsJSON)
                if uSettingsJSON != u'[]':
                    oKivySetting.add_json_panel(ReplaceVars(uKey),
                                                self.oConfigParser,
                                                data=uSettingsJSON)

        for uKey in dTarget:
            if uKey.startswith('discover'):
                if uKey in GetVar("DISCOVERSCRIPTLIST"):
                    uSettingsJSON = SettingDictToString2(dTarget[uKey])
                    uSettingsJSON = ReplaceVars(uSettingsJSON)
                    if uSettingsJSON != u'[]':
                        oKivySetting.add_json_panel(uKey[9:].upper(),
                                                    self.oConfigParser,
                                                    data=uSettingsJSON)

        # Adds the action handler
        oKivySetting.bind(on_config_change=self.On_ConfigChange)
        return oKivySetting
Ejemplo n.º 27
0
    def ConfigDownLoadSettings(self, *,
                               oSetting: KivySettings) -> KivySettings:
        """  Creates the settings tab for download """
        self.oSetting = oSetting
        self.bForce = False
        uSettingsJSONResources: str = u'[{"type": "title","title": "$lvar(694)" },\n'
        iNumber: int = 0
        uURL: str
        uSubRep: str

        RegisterSettingTypes(oSetting)

        for uURL in Globals.aRepositories:
            if not uURL == '':
                uSettingsJSONResources += u'{"type": "bool","title": "$lvar(695) %s","desc": "%s","section": "ORCA","key": "repository_state%s"},\n' % (
                    str(iNumber), uURL, str(iNumber))
            iNumber += 1

        uSettingsJSONResources += u'{"type": "buttons","title": "$lvar(696)","desc": "$lvar(697)","section": "ORCA","key": "button_load_resources","buttons":[{"title":"$lvar(5016)","id":"button_load_resources"}]}]\n'

        aSubList2: List = sorted(oRepository.aRepEntries,
                                 key=lambda entry: entry.uName)

        for uSubRep in self.aSubReps:
            aSubList = [
                oEntry for oEntry in aSubList2 if oEntry.uRepType == uSubRep[1]
            ]
            if len(aSubList) > 0:
                uSettingsJSON = u'['
                for oEntry in aSubList:
                    uDescription: str = ''
                    if len(oEntry.oDescriptions.dDescriptions) > 0:
                        uDescription = oEntry.oDescriptions.dDescriptions.get(
                            Globals.uLanguage)
                        if uDescription is None:
                            uDescription = oEntry.oDescriptions.dDescriptions.get(
                                'English')
                        if uDescription is None:
                            for uKey in oEntry.oDescriptions.dDescriptions:
                                uDescription = oEntry.oDescriptions.dDescriptions[
                                    uKey]
                                break
                    uSettingsJSON += u'{"type": "buttons","title": "%s ","desc": "%s %s:%s","section": "ORCA","key": "button_add_resource","buttons":[{"title":"$lvar(5016)","id":"button:%s:%s"}]},' % (
                        oEntry.uName, uDescription, '$lvar(673)',
                        oEntry.uVersion, uSubRep[1], oEntry.uName)
                uSettingsJSON: str = uSettingsJSON[:-1] + u']'
                oSetting.add_json_panel(ReplaceVars(uSubRep[0]),
                                        None,
                                        data=ReplaceVars(uSettingsJSON))

        oSetting.add_json_panel("Resources",
                                Globals.oOrcaConfigParser,
                                data=ReplaceVars(uSettingsJSONResources))
        oSetting.bind(on_close=self.On_SettingsClose)
        oSetting.bind(on_config_change=self.On_ConfigChange)

        return oSetting
Ejemplo n.º 28
0
    def RaiseQuestion(self,
                      *,
                      uTitle: str = '',
                      uMessage: str = '',
                      fktYes: Union[Callable, None] = None,
                      fktNo: Union[Callable, None] = None,
                      uStringYes: str = '',
                      uStringNo: str = '',
                      uStringDetails: str = '') -> Popup:
        """ Shows the question """
        oContent: BoxLayout = BoxLayout(orientation='vertical', spacing='5dp')
        self.uMessage = uMessage
        self.oPopup = Popup(title=ReplaceVars(uTitle),
                            content=oContent,
                            size=(Globals.iAppWidth * 0.9,
                                  Globals.iAppHeight * 0.9),
                            size_hint=(None, None),
                            auto_dismiss=False)
        self.oLabel = cScrollableLabelLarge(
            text=ReplaceVars(uMessage),
            size_hint=(1, None),
            size=(Globals.iAppWidth * 0.86, Globals.iAppHeight * 0.4),
            markup=True,
            noxscroll=True,
        )

        oContent.add_widget(Widget())
        oContent.add_widget(self.oLabel)
        oContent.add_widget(Widget())
        oContent.add_widget(SettingSpacer())
        self.fktYes = fktYes
        self.fktNo = fktNo

        # 2 buttons are created for accept or cancel the current value
        self.oBtnlayout = BoxLayout(size_hint_y=None,
                                    height='50dp',
                                    spacing='5dp')
        if uStringYes != '':
            self.oBtn1 = Button(text=ReplaceVars(uStringYes))
            self.oBtn1.bind(on_release=self.fktYES)
            self.oBtnlayout.add_widget(self.oBtn1)

        if uStringDetails != '':
            self.uStringDetails = uStringDetails
            self.oBtnDetails = Button(text=ReplaceVars('$lvar(452)'))
            self.oBtnDetails.bind(on_release=self.fktDetails)
            self.oBtnlayout.add_widget(self.oBtnDetails)

        if uStringNo != '':
            self.oBtn2 = Button(text=ReplaceVars(uStringNo))
            self.oBtn2.bind(on_release=self.fktNO)
            self.oBtnlayout.add_widget(self.oBtn2)

        oContent.add_widget(self.oBtnlayout)

        self.oPopup.open()
        return self.oPopup
Ejemplo n.º 29
0
    def __init__(self, **kwargs):
        self.bNoValueChange: bool = False
        self.bAllWaysOnChange: bool = False
        self.bAddInputField: bool = False
        self.bIsLanguageInput: bool = False
        self.bStopVarTrigger: bool = False
        self.bIsOpen: bool = False
        self.oButtonCancel: Union[cMultiLineButton, None] = None
        self.oTextInput: Union[TextInput, None] = None
        self.oContent: Union[GridLayout, None] = None
        self.popup: Union[Popup, None] = None
        self.value: str = kwargs.get('value', '')
        self.title: str = kwargs.get('title', '')
        self.options: List[str] = kwargs.get('options', '')

        if len(self.options) > 0:
            if self.options[0] == "$LANGUAGELIST":
                self.bIsLanguageInput = True

        uRet = kwargs.get('novaluechange')
        if uRet:
            self.bNoValueChange = (uRet == '1')
            self.uOrgValue = self.value

        self.bAllWaysOnChange = (kwargs.get('alwaysonchange', 0) == "1")
        self.bAddInputField = (kwargs.get('allowtextinput', 0) == "1")
        self.oButtonHeigth = dp(55)

        self.bStopVarTrigger = True
        self.value = self.UnhideLanguageVars(self.value)
        ''' Show text of language vars '''
        if self.value.startswith(u'$lvar(') and self.value.endswith(
                u')') and ":::" not in self.value:
            self.value = "%s [[%s]]" % (ReplaceVars(
                self.value), self.value[self.value.find("(") + 1:-1])

        if ":::" in self.value:
            aValues = self.value.split(":::")
            self.value = ""
            for uValue in aValues:
                if uValue.startswith(u'$lvar(') and uValue.endswith(u')'):
                    self.value += "%s [[%s]]" % (ReplaceVars(
                        uValue), uValue[uValue.find("(") + 1:-1]) + ":::"
                else:
                    self.value += uValue + ":::"
            self.value = self.value[:-3]

        self.bStopVarTrigger = False
        Globals.oNotifications.RegisterNotification(
            uNotification="on_key",
            fNotifyFunction=self.ClosePopUpbyESC,
            uDescription="Close Settings Popup",
            aValueLinks=[{
                "in": "key",
                "out": "key"
            }])
Ejemplo n.º 30
0
    def _create_popup(self, instance):
        """ create popup layout """
        content = BoxLayout(orientation='vertical', spacing=5)
        self.popup = popup = Popup(title=self.title,
                                   content=content,
                                   size_hint=(0.95, 0.95))

        # create the filechooser
        uRoot, uName = split(self.value)
        uRoot = ReplaceVars(uRoot)
        self.textinput = textinput = FileBrowser(select_string     = ReplaceVars('$lvar(563)'), \
                                                 cancel_string     = ReplaceVars('$lvar(5009)'), \
                                                 libraries_string  = ReplaceVars('$lvar(5018)'), \
                                                 favorites_string  = ReplaceVars('$lvar(5019)'), \
                                                 computer_string   = ReplaceVars('$lvar(5020)'), \
                                                 location_string   = ReplaceVars('$lvar(5021)'), \
                                                 listview_string   = ReplaceVars('$lvar(5022)'), \
                                                 iconview_string   = ReplaceVars('$lvar(5023)'), \
                                                 path              = uRoot, dirselect=False, \
                                                 transition        = FadeTransition(), \
                                                 size_hint         = (1, 1), \
                                                 favorites         = [(Globals.oPathRoot.string, 'ORCA')], \
                                                 show_fileinput    = False, \
                                                 show_filterinput  = False \
                                                 )

        # construct the content
        content.add_widget(textinput)
        textinput.bind(on_success=self._validate, on_canceled=self._dismiss)

        # all done, open the popup !
        popup.open()