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


Python sfile.exists函数代码示例

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


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

示例1: doDownload

def doDownload(file):
    utils.log('download url: %s' % file)
    dst = ADDON.getSetting('DOWNLOAD_FOLDER')

    import sfile
    sfile.makedirs(dst)

    if not sfile.exists(dst):
        utils.DialogOK(GETTEXT(30256), GETTEXT(30257))
        utils.openSettings(ADDONID, 2.24)
        xbmc.sleep(500)
        while(xbmc.getCondVisibility('Window.IsActive(addonsettings)') == 1):
            xbmc.sleep(100)

    dst = ADDON.getSetting('DOWNLOAD_FOLDER')
    if not sfile.exists(dst):
        utils.DialogOK(GETTEXT(30256))
        return

    import os
    dst = os.path.join(ADDON.getSetting('DOWNLOAD_FOLDER'), getDownloadTitle(file))  

    if utils.DialogYesNo(GETTEXT(30243), GETTEXT(30244)):            
        xbmc.executebuiltin('Action(Stop)')
       
    import download            
    download.download(file, dst, utils.TITLE)
开发者ID:rkramesh,项目名称:Random,代码行数:27,代码来源:1mod_menuUtils.py

示例2: RetrieveURL

def RetrieveURL(url, type, isServer):
    if len(url) == 0:
        return

    if type == VIDEO_ADDON:
        AddDir(1, url, 0)

    root = utils.getDownloadLocation()

    if type == SERVER_FILE:
        dst = urllib.quote_plus(url)
        dst = os.path.join(root, dst)

        if not sfile.exists(dst):
            try:    sfile.copy(url, dst)
            except: pass
        AddDir(1, dst, 0)

    if type == AMAZON_FILE:
        src = url.lower().endswith('.txt') or url.lower().endswith('.%s' % SRC)
        url = urllib.quote_plus(url)
        dst = os.path.join(root, url)

        import download
        url = s3.getURL(url)
        url = s3.convertToCloud(url)
        utils.Log('Amazon URL : %s' % url)        

        if src:
            url = utils.GetHTML(url, maxAge=7*86400)
            url = urllib.quote_plus(url)
            dst = os.path.join(root, url)
            url = s3.getURL(url)
            url = s3.convertToCloud(url)                
            utils.Log('Real Amazon URL : %s' % url) 
            
        downloading = sfile.exists(dst+'.part')

        if downloading:
            if False:#isServer:
                AddDir(1, dst, 0)
            else:
                AddDir(1, url, 0)

            return

        if sfile.exists(dst):
            AddDir(1, dst, 0)
            return

        download.download(url, dst)

        #if isServer:
        #    while sfile.size(dst) == 0:
        #        xbmc.sleep(100)
        #    AddDir(1, dst, 0)
        #    return

        AddDir(1, url, 0)
开发者ID:TheLivebox,项目名称:TheLiveBox,代码行数:59,代码来源:default.py

示例3: downloadDefaults

def downloadDefaults(url):
    import download
    import extract

    url1 = url + "ott/skins.zip"
    url2 = url + "ottepg/skins.zip"
    url3 = url + "ottepg/logos.zip"
    url4 = url + "ottepg/channels.zip"

    path1 = xbmc.translatePath(PROFILE)  # /addon_data/script.on-tapp.tv/
    path2 = os.path.join(epgpath, "extras")  # /addon_data/script.tvguidedixie/extras/
    path3 = os.path.join(path2, "skins")
    path4 = os.path.join(path2, "logos")

    zip1 = os.path.join(path1, "skins.zip")
    zip2 = os.path.join(path2, "skins.zip")
    zip3 = os.path.join(path2, "logos.zip")
    zip4 = os.path.join(epgpath, "channels.zip")

    if not sfile.exists(epgpath):
        sfile.makedirs(epgpath)

    if not sfile.exists(path1):
        sfile.makedirs(path1)
    download.download(url1, zip1)
    extract.all(zip1, path1, dp="Installing OTT skins")
    sfile.remove(zip1)

    if not sfile.exists(path2):
        sfile.makedirs(path2)
    download.download(url2, zip2)
    extract.all(zip2, path2, dp="Installing EPG skins")
    sfile.remove(zip2)

    if not sfile.exists(path4):
        sfile.makedirs(path2)
    download.download(url3, zip3)
    extract.all(zip3, path2)
    sfile.remove(zip3)

    if not sfile.exists(epgpath):
        sfile.makedirs(epgpath)
    download.download(url4, zip4)
    extract.all(zip4, epgpath)
    sfile.remove(zip4)

    if OTTURL == "OTHER":
        Addon.setSetting("dixie.url", "Other")
        Addon.setSetting("dixie.skin", "EPG-Skin")
        setSetting("SKIN", "OTT-Skin")
    else:
        Addon.setSetting("dixie.url", "All Channels")
        Addon.setSetting("dixie.skin", "FXB v4.0")
        setSetting("SKIN", "FXB78")

    setSetting("FIRSTRUN", "true")
开发者ID:jaffa222,项目名称:Dixie-Deans-XBMC-Repo,代码行数:56,代码来源:utilsOTT.py

示例4: downloadDefaults

def downloadDefaults(url):
    import download
    import extract

    url1 = url + 'ott/skins.zip'
    url2 = url + 'ottepg/skins.zip'
    url3 = url + 'ottepg/logos.zip'
    url4 = url + 'ottepg/channels.zip'
    
    path1 = xbmc.translatePath(PROFILE)     # /addon_data/script.on-tapp.tv/
    path2 = os.path.join(epgpath, 'extras') # /addon_data/script.tvguidedixie/extras/
    path3 = os.path.join(path2,   'skins')
    path4 = os.path.join(path2,   'logos')
    
    zip1  = os.path.join(path1,   'skins.zip')
    zip2  = os.path.join(path2,   'skins.zip')
    zip3  = os.path.join(path2,   'logos.zip')
    zip4  = os.path.join(epgpath, 'channels.zip')

    if not sfile.exists(epgpath):
        sfile.makedirs(epgpath)
    
    if not sfile.exists(path1):
        sfile.makedirs(path1)
    download.download(url1, zip1)
    extract.all(zip1, path1, dp='Installing OTT skins')
    sfile.remove(zip1)
    
    if not sfile.exists(path2):
        sfile.makedirs(path2)
    download.download(url2, zip2)
    extract.all(zip2, path2, dp='Installing EPG skins')
    sfile.remove(zip2)
    
    if not sfile.exists(path4):
        sfile.makedirs(path2)
    download.download(url3, zip3)
    extract.all(zip3, path2)
    sfile.remove(zip3)
    
    if not sfile.exists(epgpath):
        sfile.makedirs(epgpath)
    download.download(url4, zip4)
    extract.all(zip4, epgpath)
    sfile.remove(zip4)

    if isDSF():
        Addon.setSetting('dixie.skin', 'EPG-Skin')
        Addon.setSetting('playlist.url', '')
        setSetting('SKIN', 'OTT-Skin')
    else:
        Addon.setSetting('dixie.skin', 'FXB v4.0')
        setSetting('SKIN', 'FXB78')
    
    setSetting('FIRSTRUN', 'true')
开发者ID:abauerx,项目名称:Dixie-Deans-XBMC-Repo,代码行数:55,代码来源:utilsOTT.py

示例5: downloadDefaults

def downloadDefaults(url):
    import download
    import extract

    url1 = url + 'ott/skins.zip'
    url2 = url + 'ottepg/skins.zip'
    url3 = url + 'ottepg/logos.zip'
    # url4 = url + 'ottepg/channels.zip'
    
    path1 = xbmc.translatePath(PROFILE)     # /addon_data/script.on-tapp.tv/
    path2 = os.path.join(epgpath, 'extras') # /addon_data/script.tvguidedixie/extras/
    path3 = os.path.join(path2,   'skins')
    path4 = os.path.join(path2,   'logos')
    
    zip1  = os.path.join(path1,   'skins.zip')
    zip2  = os.path.join(path2,   'skins.zip')
    zip3  = os.path.join(path2,   'logos.zip')
    # zip4  = os.path.join(epgpath, 'channels.zip')

    if not sfile.exists(epgpath):
        sfile.makedirs(epgpath)
    
    if not sfile.exists(path1):
        sfile.makedirs(path1)
    download.download(url1, zip1)
    extract.all(zip1, path1, dp='Installing OTT skins')
    sfile.remove(zip1)
    
    if not sfile.exists(path2):
        sfile.makedirs(path2)
    download.download(url2, zip2)
    extract.all(zip2, path2, dp='Installing EPG skins')
    sfile.remove(zip2)
    
    if not sfile.exists(path4):
        sfile.makedirs(path2)
    download.download(url3, zip3)
    extract.all(zip3, path2)
    sfile.remove(zip3)
    
    # if not sfile.exists(epgpath):
    #     sfile.makedirs(epgpath)
    # download.download(url4, zip4)
    # extract.all(zip4, epgpath)
    # sfile.remove(zip4)

    Addon.setSetting('dixie.skin', 'EPG-Skin')
    Addon.setSetting('playlist.url', '')
    utils.setSetting('SKIN', 'OTT-Skin')
    
    if utils.DialogYesNo('Would you like to assign a button ', 'on your remote control or keybord', 'to activate the On-Tapp.TV Mini-Guide?'):
        xbmc.executebuiltin('RunScript(special://home/addons/script.tvguidedixie/keyProgrammer.py)')
    
    utils.setSetting('FIRSTRUN', 'true')
开发者ID:noobsandnerds,项目名称:Dixie-Deans-XBMC-Repo,代码行数:54,代码来源:dsf.py

示例6: resetChannels

def resetChannels():
    AddonID =  'script.trtv'
    dialog  = xbmcgui.Dialog()
    path    = dixie.GetChannelFolder()
    chan    = os.path.join(path, 'channels')
    chanchk = xbmc.translatePath(os.path.join('special://profile/addon_data/',AddonID,'chan.xml'))
    catsxml = xbmc.translatePath(os.path.join('special://profile/addon_data/',AddonID,'cats.xml'))
    success = 0

    try:
        os.remove(chanchk)
    except:
        dixie.log("### IMPORTANT ### Failed to remove the chanchk file in addon_data, please manually remove if it's still there")

    if sfile.exists(chan):
        xbmc.executebuiltin('Dialog.Show(busydialog)')
        sfile.rmtree(chan)
        xbmc.executebuiltin('Dialog.Close(busydialog)')
        success = 1

    if success == 1:
        dialog.ok('TRTV - Reset Channels', 'TRTV Channels successfully reset.', 'They will be re-created next time', 'you start the guide')

    if success == 0:
        dialog.ok('TRTV - Reset Channels', 'There was nothing to reset, please try running the add-on again so it can repopulate your channels.')

    if os.path.exists(catsxml):
        choice = dialog.yesno('Do You Need To Reset Categories?','It\'s highly unlikely you\'ll need to use this but if your main categories list has become corrupt it can cause problems. Would you like to reset the categories to the defaults?')
        if choice == 1:
            try:
                os.remove(catsxml)
                dialog.ok('TRTV - Reset Categories', 'TRTV Categories successfully reset to addon defaults. Any customisations you previously had are now lost.')
            except:
                dialog.ok('TRTV - Reset Categories', 'There was nothing to reset, please try running the add-on again so it can repopulate your categories.')
                dixie.log("### IMPORTANT ### Unable to remove the cats.xml file in your addon_data folder. Please manually delete")
开发者ID:Quihico,项目名称:repository.spartacus,代码行数:35,代码来源:resetChannels.py

示例7: checkLatest

def checkLatest(current, latest):
    if current == latest:
        return CURRENT

    if not utils.DialogYesNo(utils.GETTEXT(30115), utils.GETTEXT(30116)):
        return DECLINED

    filename = 'addon-%s.zip' % latest

    url   = s3.getFile(ROOT, filename)
    dest  = os.path.join(PROFILE, filename)
    title = utils.GETTEXT(30117)
    dp    = utils.DialogProgress(utils.GETTEXT(30079) % title, utils.GETTEXT(30080))

    import download
    download.doDownload(url, dest, title=title, referrer='', dp=dp, silent=False)

    if not sfile.exists(dest):
        return FAILED

    extracted = extract(dest, dp)

    try:    sfile.delete(dest)
    except: pass

    if not extracted:
        return FAILED

    import xbmcgui
    xbmcgui.Window(10000).setProperty('LB_RELAUNCH', 'true')

    cmd = 'UpdateLocalAddons'
    xbmc.executebuiltin(cmd)

    return UPDATED
开发者ID:TheLivebox,项目名称:TheLiveBox,代码行数:35,代码来源:checkUpdates.py

示例8: createChannel

    def createChannel(self, channel):
        path = os.path.join(channelPath, channel.id)

        if sfile.exists(path):
            return

        self.addChannel(channel)
开发者ID:noobsandnerds,项目名称:noobsandnerds,代码行数:7,代码来源:source.py

示例9: MigrateChannels

def MigrateChannels(dst):
    dst = os.path.join(dst, 'channels')
    src = os.path.join(datapath, 'channels')

    if not sfile.exists(dst):
        try:    sfile.copytree(src, dst)
        except: pass
开发者ID:Quihico,项目名称:repository.spartacus,代码行数:7,代码来源:dixie.py

示例10: checkForExternalDrive

def checkForExternalDrive():
    extDrive = getExternalDrive()
    if sfile.exists(extDrive):
        return True

    DialogOK(GETTEXT(30087), GETTEXT(30088))
    return False
开发者ID:TheLivebox,项目名称:TheLiveBox,代码行数:7,代码来源:utils.py

示例11: updateAdvancedSettings

def updateAdvancedSettings(input):
    try:
        filename = 'advancedsettings.xml'
        source   = os.path.join('special://userdata', filename)

        if sfile.exists(source):
            contents = sfile.read(source)
            if input in contents:
                Log('%s already in %s' % (input, filename))
                return True

            Log('Updating %s with %s' % (filename, input))
            start = input.replace('>', ' >').split(' ', 1)[0].strip()
            end   = '</' + input.rsplit('</', 1)[-1].strip()

            start = contents.split(start, 1)[0]
            end   = contents.split(end, 1)[-1]

            contents = start
            if start != end:
                contents += end

            contents = contents.replace('</advancedsettings>', '%s</advancedsettings>' % input)
        else:
            Log('Creating %s with %s' % (filename, input))
            contents = '<advancedsettings>%s</advancedsettings>' % input
    except:
        Log('Error updating %s with %s' % (filename, input))
        Log('Resetting %s with %s' % (filename, input))
        contents = '<advancedsettings>%s</advancedsettings>' % input

    sfile.write(source, contents)
    
    return False
开发者ID:TheLivebox,项目名称:TheLiveBox,代码行数:34,代码来源:utils.py

示例12: getCategories

    def getCategories(self):        
        cat  = dict()
        path = os.path.join(datapath, 'cats.xml')
        dixie.log("Checking for category XML path at: "+path)
        try:
            if sfile.exists(path):
                xml = sfile.read(path)
        except:
            dixie.log("### cats.xml does not exist")
#        xml = xml.replace('&', '&amp;')
        xml = StringIO.StringIO(xml)
        xml = ElementTree.iterparse(xml, events=("start", "end"))

        for event, elem in xml:
            try:
                if event == 'end':
                    if elem.tag == 'cats':
                        channel  = elem.findtext('channel')
                        category = elem.findtext('category')
                        if channel != '' and category != '':
                            cat[channel] = category
            except:
                pass

        return cat
开发者ID:noobsandnerds,项目名称:noobsandnerds,代码行数:25,代码来源:source.py

示例13: isPlayable

def isPlayable(path, ignore, maxAge=-1):
    if not sfile.exists(path):
        return False

    if sfile.isfile(path):
        playable = isFilePlayable(path, maxAge)
        return playable

    try:
        if sfile.getfilename(path)[0] in ignore:
            return False
    except:
        pass
         
    current, dirs, files = sfile.walk(path)

    for file in files:
        if isPlayable(os.path.join(current, file), ignore, maxAge):
            return True

    for dir in dirs:
        try: 
            if isPlayable(os.path.join(current, dir), ignore, maxAge):
                return True
        except:
            pass

    return False
开发者ID:TheLivebox,项目名称:TheLiveBox,代码行数:28,代码来源:utils.py

示例14: removeCleanChannel

 def removeCleanChannel(self, id):
     path = os.path.join(OTT_CHANNELS, id)
     if sfile.exists(path):
         try:
             sfile.remove(path)
         except:
             pass
开发者ID:noobsandnerds,项目名称:noobsandnerds,代码行数:7,代码来源:osd.py

示例15: VerifyKeymapHot

def VerifyKeymapHot():
    if ADDON.getSetting('HOTKEY') == GETTEXT(30111): #i.e. programmable
        return False    

    dest = os.path.join('special://profile/keymaps', KEYMAP_HOT)

    if sfile.exists(dest):
        return False

    key = ADDON.getSetting('HOTKEY')

    valid = []
    for i in range(30028, 30040):
        valid.append(GETTEXT(i))
    valid.append(GETTEXT(30058))

    includeKey = key in valid

    if not includeKey:
        DeleteKeymap(KEYMAP_HOT)
        return True

    if isATV():
        DialogOK(GETTEXT(30118), GETTEXT(30119))
        return False

    return WriteKeymap(key.lower(), key.lower())
开发者ID:XvBMC,项目名称:spoyser-repo,代码行数:27,代码来源:utils.py


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