本文整理汇总了Python中xbmcvfs.delete方法的典型用法代码示例。如果您正苦于以下问题:Python xbmcvfs.delete方法的具体用法?Python xbmcvfs.delete怎么用?Python xbmcvfs.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xbmcvfs
的用法示例。
在下文中一共展示了xbmcvfs.delete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: delete_folder
# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import delete [as 别名]
def delete_folder(path=None):
''' Delete objects from kodi cache
'''
LOG.debug("--[ delete folder ]")
delete_path = path is not None
path = path or xbmc.translatePath('special://temp/emby').decode('utf-8')
dirs, files = xbmcvfs.listdir(path)
delete_recursive(path, dirs)
for file in files:
xbmcvfs.delete(os.path.join(path, file.decode('utf-8')))
if delete_path:
xbmcvfs.delete(path)
LOG.warn("DELETE %s", path)
示例2: get_credentials
# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import delete [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
示例3: deleteFile
# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import delete [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)
示例4: download_thumb
# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import delete [as 别名]
def download_thumb(self, thumburl, destfilename):
log.info("begin download_thumb using requests module: thumburl = %s" % thumburl)
# Download file to tmp folder
tmp = util.joinPath(util.getTempDir(), os.path.basename(destfilename))
log.info("download_thumb: start downloading to temp file: %s" % tmp)
response = requests.get(thumburl, headers=WebScraper._headers, stream=True)
log.info("download_thumb: status code = %s" % response.status_code)
if response.status_code != 200:
log.info("download_thumb: invalid response status code. Can't download image.")
return
with open(tmp, 'wb') as f:
response.raw.decode_content = True
shutil.copyfileobj(response.raw, f)
log.info("download_thumb: copy from temp file to final destination: %s" % destfilename)
# Copy from the tmp folder to the target location
xbmcvfs.copy(tmp, destfilename)
xbmcvfs.delete(tmp)
log.info("end download_thumb")
示例5: onPlayBackStopped
# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import delete [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
示例6: delete_folder_contents
# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import delete [as 别名]
def delete_folder_contents(path, delete_subfolders=False):
"""
Delete all files in a folder
:param path: Path to perform delete contents
:param delete_subfolders: If True delete also all subfolders
"""
directories, files = list_dir(path)
for filename in files:
xbmcvfs.delete(os.path.join(path, filename))
if not delete_subfolders:
return
for directory in directories:
delete_folder_contents(os.path.join(path, directory), True)
# Give time because the system performs previous op. otherwise it can't delete the folder
xbmc.sleep(80)
xbmcvfs.rmdir(os.path.join(path, directory))
示例7: clearUserData
# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import delete [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
示例8: copySystemdFiles
# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import delete [as 别名]
def copySystemdFiles():
# Delete any existing openvpn.service and copy openvpn service file to config directory
service_source = getAddonPath(True, "openvpn.service")
service_dest = getSystemdPath("system.d/openvpn.service")
debugTrace("Copying openvpn.service " + service_source + " to " + service_dest)
if not fakeSystemd():
if xbmcvfs.exists(service_dest): xbmcvfs.delete(service_dest)
xbmcvfs.copy(service_source, service_dest)
if not xbmcvfs.exists(service_dest): raise IOError('Failed to copy service ' + service_source + " to " + service_dest)
# Delete any existing openvpn.config and copy first VPN to openvpn.config
config_source = sudo_setting = xbmcaddon.Addon(getID()).getSetting("1_vpn_validated")
if service_source == "": errorTrace("vpnplatform.py", "Nothing has been validated")
config_dest = getSystemdPath("openvpn.config")
debugTrace("Copying openvpn.config " + config_source + " to " + config_dest)
if not fakeSystemd():
if xbmcvfs.exists(config_dest): xbmcvfs.delete(config_dest)
xbmcvfs.copy(config_source, config_dest)
if not xbmcvfs.exists(config_dest): raise IOError('Failed to copy service ovpn ' + config_source + " to " + config_dest)
示例9: fix_update
# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import delete [as 别名]
def fix_update():
if os.path.exists(os.path.join(CONFIG.USERDATA, 'autoexec.py')):
temp = os.path.join(CONFIG.USERDATA, 'autoexec_temp.py')
if os.path.exists(temp):
xbmcvfs.delete(temp)
xbmcvfs.rename(os.path.join(CONFIG.USERDATA, 'autoexec.py'), temp)
xbmcvfs.copy(os.path.join(CONFIG.PLUGIN, 'resources', 'libs', 'autoexec.py'),
os.path.join(CONFIG.USERDATA, 'autoexec.py'))
dbfile = os.path.join(CONFIG.DATABASE, latest_db('Addons'))
try:
os.remove(dbfile)
except:
logging.log("Unable to remove {0}, Purging DB".format(dbfile))
purge_db_file(dbfile)
from resources.libs.common import tools
tools.kill_kodi(over=True)
示例10: _rotate_file
# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import delete [as 别名]
def _rotate_file():
newdate = ndate = pykodi.get_infolabel('System.Date(yyyy-mm-dd)')
count = 0
while _exists(newdate):
count += 1
newdate = ndate + '.' + str(count)
if not xbmcvfs.copy(_get_filepath(), _get_filepath(newdate)):
log("Could not copy latest report to new filename", xbmc.LOGWARNING, 'reporting')
return False
if not xbmcvfs.delete(_get_filepath()):
log("Could not delete old copy of latest report", xbmc.LOGWARNING, 'reporting')
return False
# delete old reports
_, files = xbmcvfs.listdir(settings.datapath)
reportfiles = sorted(f[:-4] for f in files if f.startswith(REPORT_NAME))
while len(reportfiles) > REPORT_COUNT:
filename = reportfiles[0] + '.txt'
if not xbmcvfs.delete(settings.datapath + filename):
log("Could not delete old report '{0}'".format(filename), xbmc.LOGWARNING, 'reporting')
return False
del reportfiles[0]
report_startup()
return True
示例11: remove_deselected_files
# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import delete [as 别名]
def remove_deselected_files(self, mediaitem, assignedart=False):
if self.debug:
return
for arttype, newimage in mediaitem.selectedart.iteritems():
if newimage is not None:
continue
if assignedart:
oldimage = mediaitem.art.get(arttype)
else:
oldimage = mediaitem.forcedart.get(arttype)
if not oldimage:
continue
old_url = oldimage['url'] if isinstance(oldimage, dict) else \
oldimage if isinstance(oldimage, basestring) else oldimage[0]['url']
if not old_url or old_url.startswith(pykodi.notimagefiles) \
or old_url in mediaitem.selectedart.values() or not xbmcvfs.exists(old_url):
continue
if settings.recycle_removed:
recyclefile(old_url)
xbmcvfs.delete(old_url)
示例12: youtubeDLDownload
# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import delete [as 别名]
def youtubeDLDownload(self,vid,path,target=None):
import YDStreamExtractor as StreamExtractor
import YDStreamUtils as StreamUtils
if not target: target = self.chooseDirectory()
if not target: return
with StreamUtils.DownloadProgress() as prog:
try:
StreamExtractor.disableDASHVideo(True)
StreamExtractor.setOutputCallback(prog)
result = StreamExtractor.downloadVideo(vid,path)
finally:
StreamExtractor.setOutputCallback(None)
if not result and result.status != 'canceled':
xbmcgui.Dialog().ok(T(32103),'[CR]',result.message)
elif result:
xbmcgui.Dialog().ok(T(32062),T(32104),'[CR]',result.filepath)
if target:
xbmcvfs.copy(result.filepath,os.path.join(target,os.path.basename(result.filepath)))
xbmcvfs.delete(result.filepath)
示例13: remove
# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import delete [as 别名]
def remove(path, silent=False, vfs=True):
"""
Elimina un archivo
@param path: ruta del fichero a eliminar
@type path: str
@rtype: bool
@return: devuelve False en caso de error
"""
path = encode(path)
try:
if xbmc_vfs and vfs:
return bool(xbmcvfs.delete(path))
elif path.lower().startswith("smb://"):
samba.remove(path)
else:
os.remove(path)
except:
logger.error("ERROR al eliminar el archivo: %s" % path)
if not silent:
logger.error(traceback.format_exc())
platformtools.dialog_notification("Error al eliminar el archivo", path)
return False
else:
return True
示例14: delete
# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import delete [as 别名]
def delete(path):
"""Remove a file (using xbmcvfs)"""
from xbmcvfs import delete as vfsdelete
log(2, "Delete file '{path}'.", path=path)
return vfsdelete(from_unicode(path))
示例15: delete_recursive
# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import delete [as 别名]
def delete_recursive(path, dirs):
''' Delete files and dirs recursively.
'''
for directory in dirs:
dirs2, files = xbmcvfs.listdir(os.path.join(path, directory.decode('utf-8')))
for file in files:
xbmcvfs.delete(os.path.join(path, directory.decode('utf-8'), file.decode('utf-8')))
delete_recursive(os.path.join(path, directory.decode('utf-8')), dirs2)
xbmcvfs.rmdir(os.path.join(path, directory.decode('utf-8')))