Skip to content

Commit

Permalink
v1.0.3: Once again fixed imports. Should now work with loca, pip-inst…
Browse files Browse the repository at this point in the history
…alled and bundled versions. Gui and cli now show filename during executing actions stage.
  • Loading branch information
brenthuisman committed Dec 5, 2018
1 parent 82b02c2 commit 9bc1587
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 15 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down Expand Up @@ -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.
Expand Down
9 changes: 6 additions & 3 deletions par2deep/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.')
Expand All @@ -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.')
Expand Down
19 changes: 14 additions & 5 deletions par2deep/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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


Expand All @@ -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',
Expand All @@ -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:
Expand All @@ -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',
Expand All @@ -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:
Expand Down Expand Up @@ -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',
Expand All @@ -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:
Expand Down
13 changes: 7 additions & 6 deletions par2deep/par2deep.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
'''
Expand Down Expand Up @@ -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)
Expand All @@ -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 ]
Expand All @@ -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 ])
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 9bc1587

Please sign in to comment.