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


Python xbmcvfs.exists方法代码示例

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


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

示例1: validate

# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import exists [as 别名]
def validate(path):

    ''' Verify if path is accessible.
    '''
    if window('emby_pathverified.bool'):
        return True

    string = "%s %s. %s" % (_(33047), path, _(33048))

    if not os.path.supports_unicode_filenames:
        path = path.encode('utf-8')

    if not xbmcvfs.exists(path):
        LOG.info("Could not find %s", path)

        if dialog("yesno", heading="{emby}", line1=string):

            return False

    window('emby_pathverified.bool', True)

    return True 
开发者ID:MediaBrowser,项目名称:plugin.video.emby,代码行数:24,代码来源:utils.py

示例2: copytree

# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import exists [as 别名]
def copytree(path, dest):

    ''' Copy folder content from one to another.
    '''
    dirs, files = xbmcvfs.listdir(path)

    if not xbmcvfs.exists(dest):
        xbmcvfs.mkdirs(dest)

    if dirs:
        copy_recursive(path, dirs, dest)

    for file in files:
        copy_file(os.path.join(path, file.decode('utf-8')), os.path.join(dest, file.decode('utf-8')))

    LOG.info("Copied %s", path) 
开发者ID:MediaBrowser,项目名称:plugin.video.emby,代码行数:18,代码来源:utils.py

示例3: download_external_subs

# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import exists [as 别名]
def download_external_subs(cls, src, filename):

        ''' Download external subtitles to temp folder
            to be able to have proper names to streams.
        '''
        temp = xbmc.translatePath("special://profile/addon_data/plugin.video.emby/temp/").decode('utf-8')

        if not xbmcvfs.exists(temp):
            xbmcvfs.mkdir(temp)

        path = os.path.join(temp, filename)

        try:
            response = requests.get(src, stream=True, verify=False)
            response.raise_for_status()
        except Exception as e:
            raise
        else:
            response.encoding = 'utf-8'
            with open(path, 'wb') as f:
                f.write(response.content)
                del response

        return path 
开发者ID:MediaBrowser,项目名称:plugin.video.emby,代码行数:26,代码来源:playutils.py

示例4: _get_database

# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import exists [as 别名]
def _get_database(self, path, silent=False):

        path = xbmc.translatePath(path).decode('utf-8')

        if not silent:

            if not xbmcvfs.exists(path):
                raise Exception("Database: %s missing" % path)

            conn = sqlite3.connect(path)
            cursor = conn.cursor()
            cursor.execute("SELECT name FROM sqlite_master WHERE type='table';")
            tables = cursor.fetchall()
            conn.close()

            if not len(tables):
                raise Exception("Database: %s malformed?" % path)

        return path 
开发者ID:MediaBrowser,项目名称:plugin.video.emby,代码行数:21,代码来源:__init__.py

示例5: get_credentials

# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import exists [as 别名]
def get_credentials():

    path = xbmc.translatePath("special://profile/addon_data/plugin.video.emby/").decode('utf-8')
    
    if not xbmcvfs.exists(path):
        xbmcvfs.mkdirs(path)

    try:
        with open(os.path.join(path, 'data.json')) as infile:
            credentials = json.load(infile)
    except Exception:

        try:
            with open(os.path.join(path, 'data.txt')) as infile:
                credentials = json.load(infile)
                save_credentials(credentials)
            
            xbmcvfs.delete(os.path.join(path, 'data.txt'))
        except Exception:
            credentials = {}

    credentials['Servers'] = credentials.get('Servers', [])

    return credentials 
开发者ID:MediaBrowser,项目名称:plugin.video.emby,代码行数:26,代码来源:__init__.py

示例6: add_item_to_library

# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import exists [as 别名]
def add_item_to_library(self, item_path, item_url):
        error = False
        new = False
        if item_path:
            item_path = xbmc.translatePath(item_path)
            dir = os.path.dirname(item_path)
            if not xbmcvfs.exists(dir):
                try:
                    xbmcvfs.mkdirs(dir)
                except Exception, e:
                    error = True
                    util.error('Failed to create directory 1: ' + dir)

            if not xbmcvfs.exists(item_path):
                try:
                    file_desc = xbmcvfs.File(item_path, 'w')
                    file_desc.write(item_url)
                    file_desc.close()
                    new = True
                except Exception, e:
                    util.error('Failed to create .strm file: ' +
                               item_path + " | " + str(e))
                    error = True 
开发者ID:kodi-czsk,项目名称:plugin.video.sosac.ph,代码行数:25,代码来源:sutils.py

示例7: __init__

# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import exists [as 别名]
def __init__(self,force=False):
        self.conn = None
        self.eventQueue = list()
        self.event = threading.Event()
        self.eventResults = dict()

        self.loadOptional(force)
        self.source = instantiateSource(force)

        self.updateInProgress = False
        self.updateFailed = False
        self.settingsChanged = None
        self.alreadyTriedUnlinking = False
        self.channelList = list()
        self.category = "Any"

        profilePath = xbmc.translatePath(ADDON.getAddonInfo('profile'))
        if not os.path.exists(profilePath):
            os.makedirs(profilePath)
        self.databasePath = os.path.join(profilePath, Database.SOURCE_DB)

        threading.Thread(name='Database Event Loop', target=self.eventLoop).start() 
开发者ID:primaeval,项目名称:script.tvguide.fullscreen,代码行数:24,代码来源:source.py

示例8: __init__

# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import exists [as 别名]
def __init__(self, url, path, addon):
        self.addon = addon

        if url.startswith("http://") or url.startswith("https://"):
            self.fileType = self.TYPE_REMOTE
            self.fileUrl = url
            self.fileName = path.split('/')[-1]
            self.filePath = path
        else:
            self.fileType = self.TYPE_DEFAULT
            self.fileUrl = url
            self.fileName = path.split('/')[-1]
            self.filePath = path

        # make sure the folder is actually there already!
        if not os.path.exists(self.basePath):
            os.makedirs(self.basePath) 
开发者ID:primaeval,项目名称:script.tvguide.fullscreen,代码行数:19,代码来源:fileFetcher.py

示例9: deleteFile

# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import exists [as 别名]
def deleteFile(filename):
    log('Deleting %s' % filename)

    if len(filename) < 1:
        log('Empty filename')
        return

    try:    current = xbmc.Player().getPlayingFile() if xbmc.Player().isPlaying() else ''
    except: current = ''

    while current == filename:
        try:    current = xbmc.Player().getPlayingFile() if xbmc.Player().isPlaying() else ''
        except: current = ''
        xbmc.sleep(1000)

    tries = 15
    while xbmcvfs.exists(filename) and tries > 0:
        tries -= 1 
        try: 
            xbmcvfs.delete(filename)
        except Exception, e: 
            log('ERROR %s in deleteFile %s' % (str(e), filename))
            log('ERROR tries=%d' % tries)
            xbmc.sleep(500) 
开发者ID:bugatsinho,项目名称:bugatsinho.github.io,代码行数:26,代码来源:playerMP3.py

示例10: checkRomfileAlreadyExists

# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import exists [as 别名]
def checkRomfileAlreadyExists(self, filename, enableFullReimport):

        isUpdate = False
        gameId = None
        log.debug("Checking if file already exists in DB: %s" % filename)
        romFile = File(self.gdb).getFileByNameAndType(filename, 0)
        if romFile is not None:
            isUpdate = True
            gameId = romFile[3]  # FIXME TODO Replace with FILE_parentId
            log.info("File '%s' already exists in database." % filename)
            log.info("Always rescan imported games = {0}".format(enableFullReimport))
            if enableFullReimport is False:
                log.info("Won't scrape this game again. Set 'Always rescan imported games' to True to force scraping.")
                return False, isUpdate, gameId
        else:
            log.debug("Couldn't find file in DB")

        return True, isUpdate, gameId 
开发者ID:maloep,项目名称:romcollectionbrowser,代码行数:20,代码来源:dbupdate.py

示例11: onPlayBackStopped

# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import exists [as 别名]
def onPlayBackStopped(self):
        self._playbackLock = False
        url = "http://" + LOCAL_IP + ":" + str(VIDEO_PORT) + "/"
        xbmc.sleep(300)
        if os.path.exists("/proc/" + str(self.spsc_pid)) and xbmc.getCondVisibility(
                "Window.IsActive(epg.xml)") and settings.getSetting('safe_stop') == "true":
            if not xbmc.Player().isPlaying():
                player = streamplayer(spsc_pid=self.spsc_pid, listitem=self.listitem)
                player.play(url, self.listitem)
        else:
            try:
                os.kill(self.spsc_pid, 9)
            except:
                pass
        try:
            xbmcvfs.delete(os.path.join(pastaperfil, 'sopcast.avi'))
        except:
            pass 
开发者ID:tvaddonsco,项目名称:program.plexus,代码行数:20,代码来源:sopcast.py

示例12: add_to_history

# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import exists [as 别名]
def add_to_history(name,url,mode,iconimage):
	line = str(name) + '|' + str(url) + '|' +str(mode) +'|' + str(iconimage) + '\n'
	if xbmcvfs.exists(history_file):
		lines = open(history_file).readlines()
		if len(lines) < int(settings.getSetting('items_per_page')):
			if name in lines[0]: pass
			else:
				lines.insert(0,line)
				open(history_file, 'w').writelines(lines)
		else:
			lines = open(history_file).readlines()
			newlines = lines[0:-1*int(settings.getSetting('items_per_page'))-1]
			newlines.insert(0,line)
			open(history_file, 'w').writelines(newlines)
	else:
		save(history_file,line)
	return 
开发者ID:tvaddonsco,项目名称:program.plexus,代码行数:19,代码来源:history.py

示例13: download

# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import exists [as 别名]
def download(link):
  subtitle_list = []

  if xbmcvfs.exists(__temp__):
    shutil.rmtree(__temp__)
  xbmcvfs.mkdirs(__temp__)

  file = os.path.join(__temp__, "addic7ed.srt")

  f = get_url(link)

  local_file_handle = open(file, "wb")
  local_file_handle.write(f)
  local_file_handle.close()

  subtitle_list.append(file)

  if len(subtitle_list) == 0:
    if search_string:
      xbmc.executebuiltin((u'Notification(%s,%s)' % (__scriptname__ , __language__(32002))).encode('utf-8'))
    else:
      xbmc.executebuiltin((u'Notification(%s,%s)' % (__scriptname__ , __language__(32003))).encode('utf-8'))

  return subtitle_list 
开发者ID:cflannagan,项目名称:service.subtitles.addic7ed,代码行数:26,代码来源:service.py

示例14: clearUserData

# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import exists [as 别名]
def clearUserData():
    # Deleting everything here, but not deleting 'DEFAULT.txt' as 
    # any existing user and password info will get deleted
    path = getUserDataPath("UserDefined" + "/*.*")
    debugTrace("Deleting contents of User Defined directory" + path)
    files = glob.glob(path)
    try:
        for file in files:
            if not file.endswith("DEFAULT.txt") and xbmcvfs.exists(file): 
                debugTrace("Deleting " + file)
                xbmcvfs.delete(file)
    except Exception as e:
        errorTrace("userdefined.py", "Couldn't clear the UserDefined directory")
        errorTrace("userdefined.py", str(e))
        return False
    return True 
开发者ID:Zomboided,项目名称:service.vpn.manager,代码行数:18,代码来源:userdefined.py

示例15: checkVPNInstall

# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import exists [as 别名]
def checkVPNInstall(addon):
    # Check that openvpn plugin exists (this was an issue with OE6), there's
    # another check below that validates that the command actually works
    if not fakeConnection():
        p = getPlatform()
        dialog_msg = ""
        if p == platforms.RPI:
            command_path = getAddonPath(False, "network.openvpn/bin/openvpn")
            if xbmcvfs.exists(command_path):
                # Check the version that's installed
                vpn_addon = xbmcaddon.Addon("network.openvpn")
                version =  vpn_addon.getAddonInfo("version")
                version = version.replace(".", "")
                if int(version) >= 600: return True
            dialog_msg = "OpenVPN executable not available.  Install the openvpn plugin, version 6.0.1 or greater from the OpenELEC unofficial repo."
            # Display error message
            xbmcgui.Dialog().ok(addon.getAddonInfo("name"), dialog_msg)
    return True 
开发者ID:Zomboided,项目名称:service.vpn.manager,代码行数:20,代码来源:vpnplatform.py


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