def delete_service(self, ref, serviceHandler): from Screens.MessageBox import MessageBox if config.usage.movielist_use_trash_dir.value: from Screens.MovieSelection import getTrashDir from Components.FileTransfer import FileTransferJob from Components.Task import job_manager trash_dir = getTrashDir(ref.getPath()) if trash_dir: src_file = str(ref.getPath()) dst_file = trash_dir if dst_file.endswith("/"): dst_file = trash_dir[:-1] text = _("remove") job_manager.AddJob( FileTransferJob(src_file, dst_file, False, False, "%s : %s" % (text, src_file))) else: result_txt = _( "Delete failed, because there is no movie trash !\nDisable movie trash in configuration to delete this item" ) self.session.openWithCallback(self.close, MessageBox, result_txt, MessageBox.TYPE_ERROR) return False else: offline = serviceHandler.offlineOperations(ref) if offline.deleteFromDisk(0): self.session.openWithCallback(self.close, MessageBox, _("You cannot delete this!"), MessageBox.TYPE_ERROR) return False return True
def delete_service(self, ref, serviceHandler): from Screens.MessageBox import MessageBox if config.usage.movielist_use_trash_dir.value: from Screens.MovieSelection import getTrashDir from Components.FileTransfer import FileTransferJob from Components.Task import job_manager trash_dir = getTrashDir(ref.getPath()) if trash_dir: src_file = str(ref.getPath()) dst_file = trash_dir if dst_file.endswith("/"): dst_file = trash_dir[:-1] text = _("remove") job_manager.AddJob(FileTransferJob(src_file,dst_file, False, False, "%s : %s" % (text, src_file))) else: result_txt = _("Delete failed, because there is no movie trash !\nDisable movie trash in configuration to delete this item") self.session.openWithCallback(self.close, MessageBox, result_txt, MessageBox.TYPE_ERROR) return False else: offline = serviceHandler.offlineOperations(ref) if offline.deleteFromDisk(0): self.session.openWithCallback(self.close, MessageBox, _("You cannot delete this!"), MessageBox.TYPE_ERROR) return False return True
def removeMovie(session, sRef, Force=False): service = ServiceReference(sRef) result = False deleted = False message = "service error" if service is not None: serviceHandler = eServiceCenter.getInstance() offline = serviceHandler.offlineOperations(service.ref) info = serviceHandler.info(service.ref) name = info and info.getName(service.ref) or "this recording" if offline is not None: if Force is True: message = "force delete" elif hasattr(config.usage, 'movielist_trashcan'): fullpath = service.ref.getPath() srcpath = '/'.join(fullpath.split('/')[:-1]) + '/' # TODO: check trash # TODO: check enable trash default value if '.Trash' not in fullpath and config.usage.movielist_trashcan.value: result = False message = "trashcan" try: import Tools.Trashcan trash = Tools.Trashcan.createTrashFolder(srcpath) MovieSelection.moveServiceFiles(service.ref, trash) result = True message = "The recording '%s' has been successfully moved to trashcan" % name except ImportError: message = "trashcan exception" pass except Exception, e: print "Failed to move to .Trash folder:", e message = "Failed to move to .Trash folder: %s" + str(e) deleted = True elif hasattr(config.usage, 'movielist_use_trash_dir'): fullpath = service.ref.getPath() if TRASHDIRNAME not in fullpath and config.usage.movielist_use_trash_dir.value: message = "trashdir" try: from Screens.MovieSelection import getTrashDir from Components.FileTransfer import FileTransferJob from Components.Task import job_manager trash_dir = getTrashDir(fullpath) if trash_dir: src_file = str(fullpath) dst_file = trash_dir if dst_file.endswith("/"): dst_file = trash_dir[:-1] text = _("remove") job_manager.AddJob( FileTransferJob(src_file, dst_file, False, False, "%s : %s" % (text, src_file))) # No Result because of async job message = "The recording '%s' has been successfully moved to trashcan" % name result = True else: message = _( "Delete failed, because there is no movie trash !\nDisable movie trash in configuration to delete this item" ) except ImportError: message = "trashdir exception" pass except Exception, e: print "Failed to move to trashdir:", e message = "Failed to move to trashdir: %s" + str(e) deleted = True
def removeMovie(session, sRef, Force=False): service = ServiceReference(sRef) result = False deleted = False message = "service error" if service is not None: serviceHandler = eServiceCenter.getInstance() offline = serviceHandler.offlineOperations(service.ref) info = serviceHandler.info(service.ref) name = info and info.getName(service.ref) or "this recording" if offline is not None: if Force is True: message = "force delete" elif hasattr(config.usage, 'movielist_trashcan'): fullpath = service.ref.getPath() srcpath = '/'.join(fullpath.split('/')[:-1]) + '/' # TODO: check trash # TODO: check enable trash default value if '.Trash' not in fullpath and config.usage.movielist_trashcan.value: result = False message = "trashcan" try: import Tools.Trashcan trash = Tools.Trashcan.createTrashFolder(srcpath) MovieSelection.moveServiceFiles(service.ref, trash) result = True message = "The recording '%s' has been successfully moved to trashcan" % name except ImportError: message = "trashcan exception" pass except Exception, e: print "Failed to move to .Trash folder:", e message = "Failed to move to .Trash folder: %s" + str(e) deleted = True elif hasattr(config.usage, 'movielist_use_trash_dir'): fullpath = service.ref.getPath() if TRASHDIRNAME not in fullpath and config.usage.movielist_use_trash_dir.value: message = "trashdir" try: from Screens.MovieSelection import getTrashDir from Components.FileTransfer import FileTransferJob from Components.Task import job_manager trash_dir = getTrashDir(fullpath) if trash_dir: src_file = str(fullpath) dst_file = trash_dir if dst_file.endswith("/"): dst_file = trash_dir[:-1] text = _("remove") job_manager.AddJob(FileTransferJob(src_file, dst_file, False, False, "%s : %s" % (text, src_file))) # No Result because of async job message = "The recording '%s' has been successfully moved to trashcan" % name result = True else: message = _("Delete failed, because there is no movie trash !\nDisable movie trash in configuration to delete this item") except ImportError: message = "trashdir exception" pass except Exception, e: print "Failed to move to trashdir:", e message = "Failed to move to trashdir: %s" + str(e) deleted = True