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


Python Settings.getTvTunesId方法代码示例

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


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

示例1: checkAccess

# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import getTvTunesId [as 别名]
    def checkAccess(self):
        log("ThemeStore: Checking access")

        if self.baseurl is None or self.userlistFile is None:
            log("ThemeStore: Theme Store details not loaded correctly")
            return False

        # Get the machine we need to check
        machineId = Settings.getTvTunesId()
        log("ThemeStore: Unique machine ID is %s" % machineId)

        validUser = False
        try:
            # Get the user list
            remoteUserList = urllib2.urlopen(self.userlistFile)
            userListDetails = remoteUserList.read()
            # Closes the connection after we have read the remote user list
            try:
                remoteUserList.close()
            except:
                log("ThemeStore: Failed to close connection for remote user list", xbmc.LOGERROR)

            # Check all of the settings
            userListDetailsET = ET.ElementTree(ET.fromstring(base64.b64decode(userListDetails)))
            for useridElem in userListDetailsET.findall('userid'):
                if useridElem is not None:
                    useridStr = useridElem.text
                    if useridStr == machineId:
                        log("ThemeStore: Detected valid user")
                        validUser = True
        except:
            log("ThemesStore: Failed to read in user list: %s" % traceback.format_exc(), xbmc.LOGERROR)
            return False

        return validUser
开发者ID:angelblue05,项目名称:script.tvtunes,代码行数:37,代码来源:store.py

示例2: __init__

# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import getTvTunesId [as 别名]
    def __init__(self):
        # Set up the addon directories if they do not already exist
        if not dir_exists(xbmc.translatePath('special://profile/addon_data/%s' % __addonid__).decode("utf-8")):
            xbmcvfs.mkdir(xbmc.translatePath('special://profile/addon_data/%s' % __addonid__).decode("utf-8"))

        self.tvtunesUploadRecord = xbmc.translatePath('special://profile/addon_data/%s/tvtunesUpload.xml' % __addonid__).decode("utf-8")

        # Records if the entire upload system is disabled
        self.uploadsDisabled = False
        self.isEmbyEnabled = True
        self.isVideoEnabled = True
        self.isAudioEnabled = True
        self.isTvShowsEnabled = True
        self.isMoviesEnabled = True

        self.ftpArg = None
        self.userArg = None
        self.passArg = None
        self.tvShowAudioExcludes = []
        self.movieAudioExcludes = []
        self.tvShowVideoExcludes = []
        self.movieVideoExcludes = []

        # Load all of the config settings
        self.loadUploadConfig()

        self.uploadRecord = None
        # Check if the file exists, if it does read it in
        if xbmcvfs.exists(self.tvtunesUploadRecord):
            try:
                recordFile = xbmcvfs.File(self.tvtunesUploadRecord, 'r')
                recordFileStr = recordFile.read()
                recordFile.close()

                self.uploadRecord = ET.ElementTree(ET.fromstring(recordFileStr))
            except:
                log("UploadThemes: Failed to read in file %s" % self.tvtunesUploadRecord, xbmc.LOGERROR)
                log("UploadThemes: %s" % traceback.format_exc(), xbmc.LOGERROR)
        else:
            # <tvtunesUpload machineid="XXXXXXXXX">
            #    <tvshows></tvshows>
            #    <movies></movies>
            # </tvtunesUpload>
            try:
                root = ET.Element('tvtunesUpload')
                root.attrib['machineid'] = Settings.getTvTunesId()
                tvshows = ET.Element('tvshows')
                movies = ET.Element('movies')
                root.extend((tvshows, movies))
                self.uploadRecord = ET.ElementTree(root)
            except:
                log("UploadThemes: Failed to create XML Content %s" % traceback.format_exc(), xbmc.LOGERROR)
开发者ID:angelblue05,项目名称:script.tvtunes,代码行数:54,代码来源:upload.py

示例3: loadConfig

# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import getTvTunesId [as 别名]

#.........这里部分代码省略.........
            if (isEnabled is None) or (isEnabled.text != 'true'):
                log("UploadThemes: Uploads disabled via online settings")
                self.uploadsDisabled = True
                return

            minVersion = uploadSettingET.find('version')
            if minVersion not in [None, ""]:
                if not self._isSupportedVersion(minVersion.text):
                    log("UploadThemes: Uploads disabled for older version")
                    self.uploadsDisabled = True
                    return

            # Check if audio uploads are enabled
            isAudioElem = uploadSettingET.find('audio')
            if (isAudioElem is None) or (isAudioElem.text != 'true'):
                log("UploadThemes: Uploads disabled for audio via online settings")
                self.isAudioEnabled = False

            # Check if video uploads are enabled
            isVideoElem = uploadSettingET.find('video')
            if (isVideoElem is None) or (isVideoElem.text != 'true'):
                log("UploadThemes: Uploads disabled for videos via online settings")
                self.isVideoEnabled = False

            # Check if tv show uploads are enabled
            isTvShowsElem = uploadSettingET.find('tvshows')
            if (isTvShowsElem is None) or (isTvShowsElem.text != 'true'):
                log("UploadThemes: Uploads disabled for tvshows via online settings")
                self.isTvShowsEnabled = False

            # Check if movie uploads are enabled
            isMoviesElem = uploadSettingET.find('movies')
            if (isMoviesElem is None) or (isMoviesElem.text != 'true'):
                log("UploadThemes: Uploads disabled for movies via online settings")
                self.isMoviesEnabled = False

            isSkipMultipleElem = uploadSettingET.find('skipmultiple')
            if (isSkipMultipleElem is None) or (isSkipMultipleElem.text != 'false'):
                log("UploadThemes: Skip Multiple enabled via online settings")
                self.skipMultipleThemes = True

            # Check if a reset is required
            isRecordResetElem = uploadSettingET.find('recordreset')
            if (isRecordResetElem is not None) and (isRecordResetElem.text == 'true'):
                log("UploadThemes: Clearing local record")
                if xbmcvfs.exists(self.tvtunesUploadRecord):
                    xbmcvfs.delete(self.tvtunesUploadRecord)

            # Get the details for where themes are uploaded to
            ftpArgElem = uploadSettingET.find('ftp')
            userArgElem = uploadSettingET.find('username')
            passArgElem = uploadSettingET.find('password')
            if (ftpArgElem in ["", None]) or (userArgElem in ["", None]) or (passArgElem in ["", None]):
                log("UploadThemes: Online settings not correct")
                self.uploadsDisabled = True
                return

            # Save off the values we have now read from the config file
            self.ftpArg = ftpArgElem.text
            self.userArg = userArgElem.text
            self.passArg = passArgElem.text
        except:
            log("UploadThemes: Failed to read upload settings %s" % traceback.format_exc(), xbmc.LOGERROR)
            # If we have had an error, stop trying to do any uploads
            self.uploadsDisabled = True

        # Now also load the existing elements that are in the library
        loadOK = self.loadLibraryContents()

        # If we failed to load then disable everything
        if not loadOK:
            log("UploadThemes: Disabling as load library failed")
            self.uploadsDisabled = True

        # Check if the upload record file exists, if it does read it in
        if xbmcvfs.exists(self.tvtunesUploadRecord):
            try:
                recordFile = xbmcvfs.File(self.tvtunesUploadRecord, 'r')
                recordFileStr = recordFile.read()
                recordFile.close()

                self.uploadRecord = ET.ElementTree(ET.fromstring(recordFileStr))
            except:
                log("UploadThemes: Failed to read in file %s" % self.tvtunesUploadRecord, xbmc.LOGERROR)
                log("UploadThemes: %s" % traceback.format_exc(), xbmc.LOGERROR)
        else:
            # <tvtunesUpload machineid="XXXXXXXXX">
            #    <tvshows></tvshows>
            #    <movies></movies>
            # </tvtunesUpload>
            try:
                root = ET.Element('tvtunesUpload')
                root.attrib['machineid'] = Settings.getTvTunesId()
                tvshows = ET.Element('tvshows')
                movies = ET.Element('movies')
                root.append(tvshows)
                root.append(movies)
                self.uploadRecord = ET.ElementTree(root)
            except:
                log("UploadThemes: Failed to create XML Content %s" % traceback.format_exc(), xbmc.LOGERROR)
开发者ID:kodibrasil,项目名称:KodiBrasil,代码行数:104,代码来源:upload.py

示例4: uploadFile

# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import getTvTunesId [as 别名]

#.........这里部分代码省略.........

            # Then into whichever type we are uploading, again this is pre-created
            ftp.cwd(videoItem['type'])

            if xbmc.abortRequested:
                ftp.quit()
                return False

            # Get the list of all the directories that exist, and see if the one we need is there
            if remoteDirName not in ftp.nlst():
                # Directory does not exist, so create it
                log("UploadThemes: Directory does not exist, creating %s" % remoteDirName)
                ftp.mkd(remoteDirName)

            if xbmc.abortRequested:
                ftp.quit()
                return False

            # Go into the required directory
            ftp.cwd(remoteDirName)

            if xbmc.abortRequested:
                ftp.quit()
                return False

            dirContents = ftp.nlst()

            # Need to check each theme to see if it needs to be uploaded
            themeNum = 0
            for aTheme in videoItem['themes']:
                if xbmc.abortRequested:
                    ftp.quit()
                    return False

                # Get the file Extension
                fileExt = os.path.splitext(aTheme)[1]
                if fileExt in ["", None]:
                    continue

                # Check to see if this file is larger than the largest file
                # that already exists
                largestFilesize = 0
                for fileInDir in dirContents:
                    # Skip hidden files and directory markers
                    if fileInDir.startswith('.'):
                        continue
                    # Check if it is the same filetype
                    if fileInDir.endswith(fileExt):
                        thisFileSize = ftp.size(fileInDir)

                        if xbmc.abortRequested:
                            ftp.quit()
                            return False

                        if thisFileSize > largestFilesize:
                            largestFilesize = thisFileSize

                log("UploadThemes: Largest file on server %s (%s) is %d" % (remoteDirName, fileExt, largestFilesize))

                stat = xbmcvfs.Stat(aTheme)
                currentFileSize = stat.st_size()

                log("UploadThemes: Theme file %s has a size of %d" % (aTheme, currentFileSize))

                # Check all of the themes to see if their size is larger than what is already there
                if currentFileSize > largestFilesize:
                    log("UploadThemes: Uploading new file of size %d" % currentFileSize)

                    # Name the file using the machine it comes from
                    fileToCreate = Settings.getTvTunesId()
                    if themeNum > 0:
                        fileToCreate = fileToCreate + "-" + str(themeNum)
                    # Now add the extension to it
                    fileToCreate = fileToCreate + fileExt
                    themeNum = themeNum + 1

                    # Transfer the file in binary mode
                    srcFile = xbmcvfs.File(aTheme, 'rb')
                    ftp.storbinary("STOR " + fileToCreate, srcFile)
                    srcFile.close()

                    fileUploaded = True
                    log("UploadThemes: Uploading of file %s complete" % fileToCreate)

            # Exit the ftp session
            ftp.quit()

        except:
            log("UploadThemes: Failed to upload file %s" % traceback.format_exc(), xbmc.LOGERROR)
            # If we have had an error, stop trying to do any uploads
            self.uploadsDisabled = True
            if ftp is not None:
                # Do a forced close to ensure the connection is no longer active
                try:
                    ftp.close()
                except:
                    pass
            fileUploaded = False

        return fileUploaded
开发者ID:kodibrasil,项目名称:KodiBrasil,代码行数:104,代码来源:upload.py

示例5: uploadRecordFile

# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import getTvTunesId [as 别名]
    def uploadRecordFile(self):
        log("UploadThemes: Uploading record")

        ftp = None
        try:
            # Connect to the ftp server
            ftp = ftplib.FTP(self.ftpArg, self.userArg, self.passArg)

            if xbmc.abortRequested:
                ftp.quit()
                return False

            # Now we are connected go into the uploads directory, this should always exist
            ftp.cwd('uploads')

            if xbmc.abortRequested:
                ftp.quit()
                return False

            # Check if uploads were enabled, if there is a file called enabled.txt then it
            # means the server is configured to receive uploads
            if 'enabled.txt' not in ftp.nlst():
                # Uploads are disabled if the file does not exist
                log("UploadThemes: Uploads are disabled")
                self.uploadsDisabled = True
                ftp.quit()
                return False

            # Then into whichever type we are uploading, again this is pre-created
            ftp.cwd('records')

            if xbmc.abortRequested:
                ftp.quit()
                return False

            # Name the file using the machine it comes from
            fileToCreate = Settings.getTvTunesId()
            # Now add the extension to it
            fileToCreate = fileToCreate + ".xml"

            log("UploadThemes: Uploading record file %s" % fileToCreate)

            # Transfer the file in binary mode
            srcFile = xbmcvfs.File(self.tvtunesUploadRecord, 'rb')
            ftp.storbinary("STOR " + fileToCreate, srcFile)
            srcFile.close()

            log("UploadThemes: Uploading record file %s complete" % fileToCreate)

            # Exit the ftp session
            ftp.quit()

        except:
            log("UploadThemes: Failed to upload file %s" % traceback.format_exc(), xbmc.LOGERROR)
            # If we have had an error, stop trying to do any uploads
            self.uploadsDisabled = True
            if ftp is not None:
                # Do a forced close to ensure the connection is no longer active
                try:
                    ftp.close()
                except:
                    pass
            return False

        return True
开发者ID:angelblue05,项目名称:script.tvtunes,代码行数:67,代码来源:upload.py


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