本文整理匯總了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
示例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)
示例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
示例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
示例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
示例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
示例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()
示例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)
示例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)
示例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
示例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
示例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
示例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
示例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
示例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