当前位置: 首页>>代码示例>>Python>>正文


Python Singleton.switchHomeUser方法代码示例

本文整理汇总了Python中DPH_Singleton.Singleton.switchHomeUser方法的典型用法代码示例。如果您正苦于以下问题:Python Singleton.switchHomeUser方法的具体用法?Python Singleton.switchHomeUser怎么用?Python Singleton.switchHomeUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DPH_Singleton.Singleton的用法示例。


在下文中一共展示了Singleton.switchHomeUser方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: DPS_ServerMenu

# 需要导入模块: from DPH_Singleton import Singleton [as 别名]
# 或者: from DPH_Singleton.Singleton import switchHomeUser [as 别名]

#.........这里部分代码省略.........
        printl("choice: " + str(choice), self, "D")
        self.isHomeUser = choice[3]
        self.currentHomeUserId = choice[4]
        self.currentHomeUserPin = choice[1]

        if self.isHomeUser:
            if choice[1] != "":
                printl(choice[1], self, "D")
                self.session.openWithCallback(
                    self.askForPin, InputBox, title=_("Please enter the pincode!"), type=Input.PIN
                )
            else:
                self.switchUser()
        else:
            if self.g_serverConfig.myplexPinProtect.value:
                self.session.openWithCallback(
                    self.askForPin, InputBox, title=_("Please enter the pincode!"), type=Input.PIN
                )
                self.currentPin = self.g_serverConfig.myplexPin.value
            else:
                self.switchUser()

        printl("", self, "C")

        # ===============================================================
        #
        # ===============================================================

    def switchUser(self):
        printl("", self, "S")

        # TODO add use saved values if we have no internet connection

        xmlResponse = self.plexInstance.switchHomeUser(self.currentHomeUserId, self.currentHomeUserPin)

        entryData = dict(xmlResponse.items())
        myId = entryData["id"]
        token = entryData["authenticationToken"]
        title = entryData["title"]

        self.plexInstance.serverConfig_myplexToken = token
        accessToken = self.plexInstance.getPlexUserTokenForLocalServerAuthentication(self.plexInstance.g_host)

        if not accessToken:
            # we get all the restriction data from plex and not from the local server this means that if we ar not connected no data is coming to check, means no restction
            self.session.open(
                MessageBox, "No accessToken! Check plex.tv connection and plexPass status.", MessageBox.TYPE_INFO
            )
        else:
            self.g_serverConfig.myplexCurrentHomeUser.value = title
            self.g_serverConfig.myplexCurrentHomeUserAccessToken.value = accessToken
            self.g_serverConfig.myplexCurrentHomeUserId.value = myId
            self.g_serverConfig.save()

            self.plexInstance.setAccessTokenHeader(self.plexInstance.g_currentServer, accessToken)

            self["text_HomeUser"].setText(title)

        printl("", self, "C")

        # ===============================================================
        #
        # ===============================================================

    def askForPin(self, enteredPin):
        printl("", self, "S")
开发者ID:acidangel,项目名称:DreamPlex,代码行数:70,代码来源:DP_ServerMenu.py


注:本文中的DPH_Singleton.Singleton.switchHomeUser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。