本文整理汇总了Python中xbmcvfs.rmdir方法的典型用法代码示例。如果您正苦于以下问题:Python xbmcvfs.rmdir方法的具体用法?Python xbmcvfs.rmdir怎么用?Python xbmcvfs.rmdir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xbmcvfs
的用法示例。
在下文中一共展示了xbmcvfs.rmdir方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: delete_nodes
# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import rmdir [as 别名]
def delete_nodes(self):
''' Remove node and children files.
'''
path = xbmc.translatePath("special://profile/library/video/").decode('utf-8')
dirs, files = xbmcvfs.listdir(path)
for file in files:
if file.startswith('emby'):
self.delete_node(os.path.join(path, file.decode('utf-8')))
for directory in dirs:
if directory.startswith('emby'):
_, files = xbmcvfs.listdir(os.path.join(path, directory.decode('utf-8')))
for file in files:
self.delete_node(os.path.join(path, directory.decode('utf-8'), file.decode('utf-8')))
xbmcvfs.rmdir(os.path.join(path, directory.decode('utf-8')))
示例2: delete_node_by_id
# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import rmdir [as 别名]
def delete_node_by_id(self, view_id):
''' Remove node and children files based on view_id.
'''
path = xbmc.translatePath("special://profile/library/video/").decode('utf-8')
dirs, files = xbmcvfs.listdir(path)
for directory in dirs:
if directory.startswith('emby') and directory.endswith(view_id):
_, files = xbmcvfs.listdir(os.path.join(path, directory.decode('utf-8')))
for file in files:
self.delete_node(os.path.join(path, directory.decode('utf-8'), file.decode('utf-8')))
xbmcvfs.rmdir(os.path.join(path, directory.decode('utf-8')))
示例3: delete_folder_contents
# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import rmdir [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))
示例4: delete_recursive
# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import rmdir [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')))
示例5: delete_cache_folder
# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import rmdir [as 别名]
def delete_cache_folder():
# Delete cache folder in the add-on userdata (no more needed with the new cache management)
cache_path = os.path.join(g.DATA_PATH, 'cache')
if not os.path.exists(g.py2_decode(xbmc.translatePath(cache_path))):
return
debug('Deleting the cache folder from add-on userdata folder')
try:
delete_folder_contents(cache_path, True)
xbmc.sleep(80)
xbmcvfs.rmdir(cache_path)
except Exception: # pylint: disable=broad-except
import traceback
error(g.py2_decode(traceback.format_exc(), 'latin-1'))
示例6: remove_item
# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import rmdir [as 别名]
def remove_item(item_task, library_home=None):
"""Remove an item from the library and delete if from disk"""
# pylint: disable=unused-argument, broad-except
common.info('Removing {} from library', item_task['title'])
exported_filename = g.py2_decode(xbmc.translatePath(item_task['filepath']))
videoid = item_task['videoid']
common.debug('VideoId: {}', videoid)
try:
parent_folder = g.py2_decode(xbmc.translatePath(os.path.dirname(exported_filename)))
if xbmcvfs.exists(exported_filename):
xbmcvfs.delete(exported_filename)
else:
common.warn('Cannot delete {}, file does not exist', exported_filename)
# Remove the NFO files if exists
nfo_file = os.path.splitext(exported_filename)[0] + '.nfo'
if xbmcvfs.exists(nfo_file):
xbmcvfs.delete(nfo_file)
dirs, files = xbmcvfs.listdir(parent_folder)
tvshow_nfo_file = g.py2_decode(makeLegalFilename('/'.join([parent_folder, 'tvshow.nfo'])))
# Remove tvshow_nfo_file only when is the last file
# (users have the option of removing even single seasons)
if xbmcvfs.exists(tvshow_nfo_file) and not dirs and len(files) == 1:
xbmcvfs.delete(tvshow_nfo_file)
# Delete parent folder
xbmcvfs.rmdir(parent_folder)
# Delete parent folder when empty
if not dirs and not files:
xbmcvfs.rmdir(parent_folder)
_remove_videoid_from_db(videoid)
except ItemNotFound:
common.warn('The video with id {} not exists in the database', videoid)
except Exception as exc:
import traceback
common.error(g.py2_decode(traceback.format_exc(), 'latin-1'))
ui.show_addon_error_info(exc)
示例7: recursive_delete_dir
# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import rmdir [as 别名]
def recursive_delete_dir(self, fullpath):
'''helper to recursively delete a directory'''
success = True
if not isinstance(fullpath, unicode):
fullpath = fullpath.decode("utf-8")
dirs, files = xbmcvfs.listdir(fullpath)
for file in files:
file = file.decode("utf-8")
success = xbmcvfs.delete(os.path.join(fullpath, file))
for directory in dirs:
directory = directory.decode("utf-8")
success = self.recursive_delete_dir(os.path.join(fullpath, directory))
success = xbmcvfs.rmdir(fullpath)
return success
示例8: rmdirtree
# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import rmdir [as 别名]
def rmdirtree(path, silent=False, vfs=True):
"""
Elimina un directorio y su contenido
@param path: ruta a eliminar
@type path: str
@rtype: bool
@return: devuelve False en caso de error
"""
path = encode(path)
try:
if xbmc_vfs and vfs:
if not exists(path): return True
if not path.endswith('/') and not path.endswith('\\'):
path = join(path, ' ').rstrip()
for raiz, subcarpetas, ficheros in walk(path, topdown=False):
for f in ficheros:
xbmcvfs.delete(join(raiz, f))
for s in subcarpetas:
xbmcvfs.rmdir(join(raiz, s))
xbmcvfs.rmdir(path)
elif path.lower().startswith("smb://"):
for raiz, subcarpetas, ficheros in samba.walk(path, topdown=False):
for f in ficheros:
samba.remove(join(decode(raiz), decode(f)))
for s in subcarpetas:
samba.rmdir(join(decode(raiz), decode(s)))
samba.rmdir(path)
else:
import shutil
shutil.rmtree(path, ignore_errors=True)
except:
logger.error("ERROR al eliminar el directorio: %s" % path)
if not silent:
logger.error(traceback.format_exc())
platformtools.dialog_notification("Error al eliminar el directorio", path)
return False
else:
return not exists(path)
示例9: rmdir
# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import rmdir [as 别名]
def rmdir(path, silent=False, vfs=True):
"""
Elimina un directorio
@param path: ruta a eliminar
@type path: str
@rtype: bool
@return: devuelve False en caso de error
"""
path = encode(path)
try:
if xbmc_vfs and vfs:
if not path.endswith('/') and not path.endswith('\\'):
path = join(path, ' ').rstrip()
return bool(xbmcvfs.rmdir(path))
elif path.lower().startswith("smb://"):
samba.rmdir(path)
else:
os.rmdir(path)
except:
logger.error("ERROR al eliminar el directorio: %s" % path)
if not silent:
logger.error(traceback.format_exc())
platformtools.dialog_notification("Error al eliminar el directorio", path)
return False
else:
return True
示例10: rmtree
# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import rmdir [as 别名]
def rmtree(path):
if isinstance(path, unicode):
path = path.encode('utf-8')
dirs, files = xbmcvfs.listdir(path)
for dir in dirs:
rmtree(os.path.join(path, dir))
for file in files:
xbmcvfs.delete(os.path.join(path, file))
xbmcvfs.rmdir(path)
示例11: delete
# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import rmdir [as 别名]
def delete(path):
dirs, files = xbmcvfs.listdir(path)
for file in files:
xbmcvfs.delete(path+file)
for dir in dirs:
delete(path + dir + '/')
xbmcvfs.rmdir(path)
示例12: rmdirs
# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import rmdir [as 别名]
def rmdirs(path):
path = xbmc.translatePath(path)
dirs, files = xbmcvfs.listdir(path)
for dir in dirs:
rmdirs(os.path.join(path,dir))
xbmcvfs.rmdir(path)
示例13: rmdir
# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import rmdir [as 别名]
def rmdir(f, force=False):
import xbmcvfs
return xbmcvfs.rmdir(f, force)
示例14: library_tv_remove_strm
# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import rmdir [as 别名]
def library_tv_remove_strm(show, folder, id, season, episode):
enc_season = ('Season %s' % season).translate(None, '\/:*?"<>|').strip('.')
enc_name = '%s - S%02dE%02d.strm' % (text.clean_title(show['seriesname']), season, episode)
season_folder = os.path.join(folder, enc_season)
stream_file = os.path.join(season_folder, enc_name)
if xbmcvfs.exists(stream_file):
xbmcvfs.delete(stream_file)
while not xbmc.Monitor().abortRequested() and xbmcvfs.exists(stream_file):
xbmc.sleep(1000)
a,b = xbmcvfs.listdir(season_folder)
if not a and not b:
xbmcvfs.rmdir(season_folder)
return True
return False
示例15: rmdir
# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import rmdir [as 别名]
def rmdir(path, quiet=False):
if not exists(path):
if debug:
xbmc.log('******** VFS rmdir notice: %s does not exist' % path)
return False
if not quiet:
msg = 'Remove Directory'
msg2 = 'Please confirm directory removal!'
if not confirm(msg, msg2, path): return False
try:
xbmcvfs.rmdir(path)
except Exception as e:
xbmc.log('******** VFS error: %s' % e)