def rmdirtree(path): """ 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 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)) logger.error(traceback.format_exc()) platformtools.dialog_notification("Error al eliminar el directorio", path) return False else: return not exists(path)
def rmdir(path): """ 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 path.lower().startswith("smb://"): samba.rmdir(path) else: os.rmdir(path) except: logger.error("ERROR al eliminar el directorio: %s" %(path)) logger.error(traceback.format_exc()) platformtools.dialog_notification("Error al eliminar el directorio", path) return False else: return True
def rmdir(path): """ 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 path.lower().startswith("smb://"): samba.rmdir(path) else: os.rmdir(path) except: logger.error("ERROR al eliminar el directorio: %s" % path) logger.error(traceback.format_exc()) platformtools.dialog_notification("Impossibile rimuovere la directory.", path) return False else: return True
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)