def doCopy(self, result): if result is not None: if result[1]: filename = self.SOURCELIST.getFilename() sourceDir = self.SOURCELIST.getCurrentDirectory() targetDir = self.TARGETLIST.getCurrentDirectory() updateDirs = [targetDir] dst_file = targetDir if dst_file.endswith("/") and dst_file != "/": targetDir = dst_file[:-1] if sourceDir not in filename: self.addJob(FileTransferJob(sourceDir + filename, targetDir, False, True, "%s : %s" % (_("copy file"), sourceDir + filename)), updateDirs) else: self.addJob(FileTransferJob(filename, targetDir, True, True, "%s : %s" % (_("copy folder"), filename)), updateDirs)
def doMove(self,result): if result is not None: if result[1]: filename = self.SOURCELIST.getFilename() sourceDir = self.SOURCELIST.getCurrentDirectory() targetDir = self.TARGETLIST.getCurrentDirectory() dst_file = targetDir if dst_file.endswith("/"): targetDir = dst_file[:-1] if not sourceDir in filename: job_manager.AddJob(FileTransferJob(sourceDir+filename, targetDir, False, False, "%s : %s" % (_("move file"), sourceDir+filename))) self.doMoveCB() else: job_manager.AddJob(FileTransferJob(filename, targetDir, True, False, "%s : %s" % (_("move folder"), filename))) self.doMoveCB()
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 goYellow(self): targetDir = self.TARGETLIST.getCurrentDirectory() if targetDir is None: return self.cleanList() updateDirs = [targetDir] jobs = [] for file in self.selectedFiles: dst_file = targetDir if dst_file.endswith("/") and dst_file != "/": targetDir = dst_file[:-1] if file.endswith("/"): jobs.append(FileTransferJob(file, targetDir, True, True, "%s : %s" % (_("copy folder"), file))) else: jobs.append(FileTransferJob(file, targetDir, False, True, "%s : %s" % (_("copy file"), file))) self.exit(jobs, updateDirs)
def goYellow(self): targetDir = self.TARGETLIST.getCurrentDirectory() for file in self.selectedFiles: extension = file.split('.') extension = extension[-1].lower() if MOVIEEXTENSIONS.has_key(extension): print "[Moviebrowser]: skip " +extension else: print "[Moviebrowser]: copy " +extension dst_file = targetDir if dst_file.endswith("/"): targetDir = dst_file[:-1] if file.endswith("/"): job_manager.AddJob(FileTransferJob(file, targetDir, True, True, "%s : %s" % (_("copy folder"),file))) else: job_manager.AddJob(FileTransferJob(file, targetDir, False, True, "%s : %s" % (_("copy file"),file))) self.exit()
def goGreen(self): targetDir = self.TARGETLIST.getCurrentDirectory() if targetDir is None: return self.cleanList() updateDirs = [targetDir, self.SOURCELIST.getCurrentDirectory()] jobs = [] for file in self.selectedFiles: dst_file = targetDir if dst_file.endswith("/") and dst_file != "/": targetDir = dst_file[:-1] jobs.append(FileTransferJob(file, targetDir, False, False, "%s : %s" % (_("move file"), file))) self.exit(jobs, updateDirs)
def goGreen(self): targetDir = self.TARGETLIST.getCurrentDirectory() for file in self.selectedFiles: extension = file.split('.') extension = extension[-1].lower() if extension in MOVIEEXTENSIONS: print "[FileCommander] skip " + extension else: print "[FileCommander] copy " + extension dst_file = targetDir if dst_file.endswith("/"): targetDir = dst_file[:-1] job_manager.AddJob( FileTransferJob(file, targetDir, False, False, "%s : %s" % (_("move file"), file))) self.exit()
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