From 9bc15873bd3e2c8399eee2b9e16b0c049d88d2fd Mon Sep 17 00:00:00 2001 From: Brent Huisman Date: Wed, 5 Dec 2018 12:42:44 +0100 Subject: [PATCH] v1.0.3: Once again fixed imports. Should now work with loca, pip-installed and bundled versions. Gui and cli now show filename during executing actions stage. --- README.md | 3 ++- par2deep/cli.py | 9 ++++++--- par2deep/gui.py | 19 ++++++++++++++----- par2deep/par2deep.py | 13 +++++++------ 4 files changed, 29 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 12f0b9d..e0d2be9 100755 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ I use `par2deep` to secure my photos and music across drives, machines and opera Simply run the following: - $ python setup.py install + $ python setup.py install --user Or run directly with: @@ -43,6 +43,7 @@ Example `par2deep.ini`: ### Changelog + * 2018-12-05: v1.0.3. Once again fixed imports. Should now work with loca, pip-installed and bundled versions. Gui and cli now show filename during executing actions stage. * 2018-05-30: v1.0.2. GUI updates: file doubleclick now checkes if string is file, added tooltips to GUI settings, and treeview category headers have a bit for info (nb of files in category). CLI updates: same par2deep import check as GUI. * 2018-05-25: v1.0.1. Crossplatform doubleclick in treeview. Improved Windows par2 executable finding. New cx_Freeze installer script. Converted relative imports. * 2016-08-20: Ensured par2 command is called correctly from Windows and other OS in GUI mode. Added NSIS installer script. diff --git a/par2deep/cli.py b/par2deep/cli.py index d3eba7e..a76628d 100755 --- a/par2deep/cli.py +++ b/par2deep/cli.py @@ -60,7 +60,8 @@ def main(): print(p2d.len_all_actions) with tqdm.tqdm(total=p2d.len_all_actions, unit='files', unit_scale=True) as pbar: for i in p2d.execute(): - pbar.update(i) + pbar.update(1) + pbar.set_postfix_str(i[-20:]) print("==========================================================") print(len(p2d.verifiedfiles_succes),'files verified and in order.') @@ -79,11 +80,13 @@ def main(): if p2d.quiet or (not p2d.quiet and not p2d.noverify and ask_yn("Would you like to fix the repairable corrupted files and recreate for unrepairable files?", default=None)): with tqdm.tqdm(total=p2d.len_verified_actions, unit='files', unit_scale=True) as pbar: for i in p2d.execute_repair(): - pbar.update(i) + pbar.update(1) + pbar.set_postfix_str(i[-20:]) elif not p2d.quiet and not p2d.noverify and ask_yn("Would you like to recreate par files for the changed and unrepairable files?", default=None): with tqdm.tqdm(total=p2d.len_verified_actions, unit='files', unit_scale=True) as pbar: for i in p2d.execute_recreate(): - pbar.update(i) + pbar.update(1) + pbar.set_postfix_str(i[-20:]) else: noaction=True # print('No reparation or recreation will take place.') diff --git a/par2deep/gui.py b/par2deep/gui.py index b3906b8..1195365 100755 --- a/par2deep/gui.py +++ b/par2deep/gui.py @@ -15,7 +15,7 @@ class CreateToolTip(object): Copied from https://stackoverflow.com/a/36221216 """ def __init__(self, widget, text='widget info'): - self.waittime = 500 #miliseconds + self.waittime = 500 #milliseconds self.wraplength = 250 #pixels self.widget = widget self.text = text @@ -71,6 +71,7 @@ def __init__(self, master): #main window has 1 frame, thats it Grid.rowconfigure(master, 0, weight=1) Grid.columnconfigure(master, 0, weight=1) + self.waittime = 500 #milliseconds #swithin that, frames, row-wise, which are updated as necesary. #topbar: displays stage of verification @@ -252,7 +253,9 @@ def progress_frame(self,length): subframe = Frame(self) self.pb=Progressbar(subframe, mode='determinate',maximum=length) self.pb.pack(fill=X,expand=True) - Label(subframe, text="Executing actions, may take a few moments...").pack(fill=X) + self.pb_currentfile = StringVar() + self.pb_currentfile.set("Executing actions, may take a few moments...") + Label(subframe, textvariable = self.pb_currentfile).pack(fill=X) return subframe @@ -269,7 +272,8 @@ def repair_action(self): self.cnt_stop = False def run(): for i in self.p2d.execute_repair(): - self.cnt+=i + self.cnt+=1 + self.currentfile = i dispdict = { 'verifiedfiles_succes' : 'Verified and in order', 'createdfiles' : 'Newly created parity files', @@ -290,6 +294,7 @@ def run(): def upd(): if not self.cnt_stop: self.pb.step(self.cnt) + self.pb_currentfile.set("Processing "+os.path.basename(self.currentfile)) self.cnt=0 self.master.after(self.waittime, upd) else: @@ -307,7 +312,8 @@ def recreate_action(self): self.cnt_stop = False def run(): for i in self.p2d.execute_recreate(): - self.cnt+=i + self.cnt+=1 + self.currentfile = i dispdict = { 'verifiedfiles_succes' : 'Verified and in order', 'createdfiles' : 'Newly created parity files', @@ -328,6 +334,7 @@ def run(): def upd(): if not self.cnt_stop: self.pb.step(self.cnt) + self.pb_currentfile.set("Processing "+os.path.basename(self.currentfile)) self.cnt=0 self.master.after(self.waittime, upd) else: @@ -378,7 +385,8 @@ def execute_actions(self): self.cnt_stop = False def run(): for i in self.p2d.execute(): - self.cnt+=i + self.cnt+=1 + self.currentfile = i dispdict = { 'verifiedfiles_succes' : 'Verified and in order', 'createdfiles' : 'Newly created parity files', @@ -396,6 +404,7 @@ def run(): def upd(): if not self.cnt_stop: self.pb.step(self.cnt) + self.pb_currentfile.set("Processing "+os.path.basename(self.currentfile)) self.cnt=0 self.master.after(self.waittime, upd) else: diff --git a/par2deep/par2deep.py b/par2deep/par2deep.py index 6a1d070..f48a20a 100755 --- a/par2deep/par2deep.py +++ b/par2deep/par2deep.py @@ -15,6 +15,7 @@ - no file but .par2 - override = dont remove .par2 if no file third, execute user choices. + - these _execute function are iterable through yield, which is done at the start of the loop such that we know what the current file being worked on is. fourth, ask to repair if possible/necesary. fifth, final report. ''' @@ -184,7 +185,7 @@ def execute(self): if len(create)>0: #print('Creating ...') for f in create: - yield 1 + yield f pars = glob.glob(glob.escape(f)+'*.par2') for p in pars: os.remove(p) @@ -198,7 +199,7 @@ def execute(self): if not self.noverify and not self.overwrite and len(verify)>0: #print('Verifying ...') for f in verify: - yield 1 + yield f verifiedfiles.append([ f , self.runpar([self.par_cmd,"v",f]) ]) verifiedfiles_err=[ [i,j] for i,j in verifiedfiles if j != 0 and j != 100 and j != 1 ] verifiedfiles_repairable=[ [i,j] for i,j in verifiedfiles if j == 1 ] @@ -209,7 +210,7 @@ def execute(self): if not self.keep_old and len(unused)>0: #print('Removing ...') for f in unused: - yield 1 + yield f if os.path.isfile(f): # so os.remove always succeeds and returns None os.remove(f) removedfiles.append([ f , 100 ]) @@ -237,14 +238,14 @@ def execute_repair(self): recreatedfiles=[] if self.len_verified_actions>0: for f,retcode in self.verifiedfiles_repairable: - yield 1 + yield f retval = self.runpar([self.par_cmd,"r",f]) if retval == 0: if not self.keep_old and os.path.isfile(f+".1"): os.remove(f+".1") repairedfiles.append([ f , retval ]) for f,retcode in self.verifiedfiles_err: - yield 1 + yield f pars = glob.glob(glob.escape(f)+'*.par2') for p in pars: os.remove(p) @@ -265,7 +266,7 @@ def execute_recreate(self): recreatedfiles=[] if self.len_verified_actions>0: for f,retcode in self.verifiedfiles_repairable+self.verifiedfiles_err: - yield 1 + yield f pars = glob.glob(glob.escape(f)+'*.par2') for p in pars: os.remove(p)