Python xbmcvfs.rmdir() Examples
The following are 19
code examples of xbmcvfs.rmdir().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
xbmcvfs
, or try the search function
.
Example #1
Source File: views.py From plugin.video.emby with GNU General Public License v3.0 | 6 votes |
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')))
Example #2
Source File: views.py From plugin.video.emby with GNU General Public License v3.0 | 6 votes |
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')))
Example #3
Source File: fileops.py From plugin.video.netflix with MIT License | 6 votes |
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))
Example #4
Source File: service.py From xbmc-addons-chinese with GNU General Public License v2.0 | 5 votes |
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)
Example #5
Source File: Library.py From plugin.video.netflix with MIT License | 5 votes |
def remove_movie(self, title, year): """Removes the DB entry & the strm file for the movie given Parameters ---------- title : :obj:`str` Title of the movie year : :obj:`int` Release year of the movie Returns ------- bool Delete successfull """ title = re.sub(r'[?|$|!|:|#]', r'', title) movie_meta = '%s (%d)' % (title, year) folder = re.sub( pattern=r'[?|$|!|:|#]', repl=r'', string=self.db[self.movies_label][movie_meta]['alt_title']) progress = xbmcgui.DialogProgress() progress.create(self.kodi_helper.get_local_string(1210), movie_meta) progress.update(50) time.sleep(0.5) del self.db[self.movies_label][movie_meta] self._update_local_db(filename=self.db_filepath, db=self.db) dirname = self.nx_common.check_folder_path( path=os.path.join(self.movie_path, folder)) filename = os.path.join(self.movie_path, folder, movie_meta + '.strm') if xbmcvfs.exists(dirname): xbmcvfs.delete(filename) xbmcvfs.rmdir(dirname) return True return False time.sleep(1) progress.close()
Example #6
Source File: utils.py From script.skin.helper.service with GNU General Public License v2.0 | 5 votes |
def recursive_delete_dir(path): '''helper to recursively delete a directory''' success = True path = try_encode(path) dirs, files = xbmcvfs.listdir(path) for file in files: success = xbmcvfs.delete(os.path.join(path, file)) for directory in dirs: success = recursive_delete_dir(os.path.join(path, directory)) success = xbmcvfs.rmdir(path) return success
Example #7
Source File: vfs.py From plugin.git.browser with GNU General Public License v3.0 | 5 votes |
def rm(path, quiet=False, recursive=False): if not exists(path): if debug: xbmc.log('******** VFS rmdir notice: %s does not exist' % path) return False if not quiet: msg = 'Confirmation' msg2 = 'Please confirm directory removal!' if not confirm(msg, msg2, path): return False if not recursive: try: xbmcvfs.delete(path) except Exception as e: xbmc.log('******** VFS error: %s' % e) else: dirs,files = ls(path) for f in files: r = os.path.join(xbmc.translatePath(path), f) try: xbmcvfs.delete(r) except Exception as e: xbmc.log('******** VFS error: %s' % e) for d in dirs: subdir = os.path.join(xbmc.translatePath(path), d) rm(subdir, quiet=True, recursive=True) try: xbmcvfs.rmdir(path) except Exception as e: xbmc.log('******** VFS error: %s' % e) return True
Example #8
Source File: vfs.py From plugin.git.browser with GNU General Public License v3.0 | 5 votes |
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)
Example #9
Source File: lib_tvshows.py From plugin.video.openmeta with GNU General Public License v3.0 | 5 votes |
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
Example #10
Source File: utils.py From script.module.clouddrive.common with GNU General Public License v3.0 | 5 votes |
def rmdir(f, force=False): import xbmcvfs return xbmcvfs.rmdir(f, force)
Example #11
Source File: main.py From plugin.video.iptv.recorder with GNU General Public License v3.0 | 5 votes |
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)
Example #12
Source File: main.py From plugin.video.iptv.recorder with GNU General Public License v3.0 | 5 votes |
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)
Example #13
Source File: utils.py From plugin.video.emby with GNU General Public License v3.0 | 5 votes |
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')))
Example #14
Source File: filetools.py From addon with GNU General Public License v3.0 | 5 votes |
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
Example #15
Source File: filetools.py From addon with GNU General Public License v3.0 | 5 votes |
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)
Example #16
Source File: downloader.py From plugin.video.themoviedb.helper with GNU General Public License v3.0 | 5 votes |
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
Example #17
Source File: library_items.py From plugin.video.netflix with MIT License | 5 votes |
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)
Example #18
Source File: upgrade_actions.py From plugin.video.netflix with MIT License | 5 votes |
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'))
Example #19
Source File: Library.py From plugin.video.netflix with MIT License | 4 votes |
def remove_show(self, title): """Removes the DB entry & the strm files for the show given Parameters ---------- title : :obj:`str` Title of the show Returns ------- bool Delete successfull """ title = re.sub(r'[?|$|!|:|#]', r'', title) label = self.series_label rep_str = self.db[label][title]['alt_title'].encode('utf-8') folder = re.sub( pattern=r'[?|$|!|:|#]', repl=r'', string=rep_str) progress = xbmcgui.DialogProgress() progress.create(self.kodi_helper.get_local_string(1210), title) time.sleep(0.5) del self.db[self.series_label][title] self._update_local_db(filename=self.db_filepath, db=self.db) show_dir = self.nx_common.check_folder_path( path=os.path.join(self.tvshow_path, folder)) if xbmcvfs.exists(show_dir): show_files = xbmcvfs.listdir(show_dir)[1] episode_count_total = len(show_files) step = round(100.0 / episode_count_total, 1) percent = 100 - step for filename in show_files: progress.update(int(percent)) xbmcvfs.delete(os.path.join(show_dir, filename)) percent = percent - step time.sleep(0.05) xbmcvfs.rmdir(show_dir) return True return False time.sleep(1) progress.close()