def cp_multiple(self, filelist, remove_after_copy, cp_status_callback=None, rm_status_callback=None): delta, total = 0, 0 self.START_OPERATION('cp_multiple') t1 = time.time() try: for f in filelist: size = self.cp(f, f, False) if cp_status_callback: cp_status_callback(os.path.join(self.pwd(), f), os.path.join(os.getcwd(), f), size) total += size if remove_after_copy: pcardext.rm(f) t2 = time.time() delta = t2 - t1 finally: if remove_after_copy: self.ls(True, '*', False) self.END_OPERATION('cp_multiple') return (total, delta)
def rm(self, name, refresh_dir=True, openclose=True): self.START_OPERATION() try: r = pcardext.rm(name) if refresh_dir: self.ls(True, '*', False) finally: self.END_OPERATION(openclose) return r
def cp_list(self, filelist, remove_after_copy, cp_status_callback=None, rm_status_callback=None): self.save_wd() delta, total = 0, 0 self.START_OPERATION('cp_list') t1 = time.time() try: for f in filelist: path_list = f.split('/')[:-1] filename = f.split('/')[-1] for p in path_list: self.cd(p, False) size = self.cp(filename, filename, False) if cp_status_callback is not None: cp_status_callback(f, os.path.join(os.getcwd(), filename), size) total += size if remove_after_copy: pcardext.rm(filename) if rm_status_callback is not None: rm_status_callback(f) self.cd('/', False) t2 = time.time() delta = t2 - t1 finally: #if remove_after_copy: # self.ls( True, '*', False ) self.restore_wd() self.END_OPERATION('cp_list') return (total, delta)