From db4adc0518aca207d029fdccffa321a03d2ff72d Mon Sep 17 00:00:00 2001 From: a-Sansara Date: Wed, 15 May 2013 20:51:08 +0200 Subject: [PATCH] bugfix somes gui issues on destination file --- CHANGELOG | 6 ++-- README | 8 ++--- kirmah-cli.py | 4 +-- kirmah.py | 2 +- kirmah/app.py | 15 ++++---- kirmah/cli.py | 2 +- kirmah/cliapp.py | 54 +++++++++++++++++++---------- kirmah/conf.py | 4 +-- kirmah/crypt.py | 36 +++++++++++-------- kirmah/gui.py | 40 ++++++++++----------- kirmah/ui.py | 4 +-- psr/cli.py | 2 +- psr/const.py | 6 ++-- psr/io.py | 3 +- psr/log.py | 2 +- psr/mproc.py | 2 +- psr/sys.py | 10 +++--- psr/w32color.py | 2 +- resources/kirmah/glade/kirmah.glade | 3 +- setup.py | 2 +- 20 files changed, 117 insertions(+), 90 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index f1ad00a..dd7126b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,10 +1,10 @@ -Kirmah 2.17 (2013-05-06) +Kirmah 2.18 (2013-05-15) ========================= - + New General Features ------------------------- - * + * Bugfixes ------------------------- diff --git a/README b/README index 05436c3..7bde23c 100644 --- a/README +++ b/README @@ -1,9 +1,9 @@ -Kirmah 2.17 (2013-05-06) +Kirmah 2.18 (2013-05-15) ========================= - + Install on Archlinux ------------------------- -sudo pacman -U http://sourceforge.net/projects/kirmah/files/packages/archlinux/kirmah-2.17-1-any.pkg.tar.xz/download +sudo pacman -U http://sourceforge.net/projects/kirmah/files/packages/archlinux/kirmah-2.18-1-any.pkg.tar.xz/download (re)build instruction @@ -21,7 +21,7 @@ Install on other distrib install pkg depends (look at archlinux PKGBUILD file wich provide usefull informations) simply untar archive, then launch : -$ python ./kirmah/kirmah.py +$ python ./kirmah/kirmah.py $ python ./kirmah/kirmah-cli.py you can also use python2 disutils and setup.py diff --git a/kirmah-cli.py b/kirmah-cli.py index bb7fe71..b61e15a 100644 --- a/kirmah-cli.py +++ b/kirmah-cli.py @@ -4,7 +4,7 @@ # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # software : Kirmah -# version : 2.17 +# version : 2.18 # date : 2013 # licence : GPLv3.0 # author : a-Sansara <[a-sansara]at[clochardprod]dot[net]> @@ -36,8 +36,8 @@ def main(): c = 0 Cli('.'+Sys.sep) except Exception as e : - raise e Sys.pwarn((('main : ',(str(e),Sys.CLZ_ERROR_PARAM), ' !'),), True) + #~ raise e c = 1 return c diff --git a/kirmah.py b/kirmah.py index 6fdffcb..8de4303 100644 --- a/kirmah.py +++ b/kirmah.py @@ -36,8 +36,8 @@ def main(): c = 0 AppGui() except Exception as e: - raise e Sys.pwarn((('main : ',(str(e),Sys.CLZ_ERROR_PARAM), ' !'),), True) + #~ raise e c = 1 return c diff --git a/kirmah/app.py b/kirmah/app.py index 83fa253..f5c013b 100644 --- a/kirmah/app.py +++ b/kirmah/app.py @@ -4,7 +4,7 @@ # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # software : Kirmah -# version : 2.17 +# version : 2.18 # date : 2013 # licence : GPLv3.0 # author : a-Sansara <[a-sansara]at[clochardprod]dot[net]> @@ -167,25 +167,28 @@ class KirmahApp: if path is not None : self.dst = ''.join([path, Sys.sep, '' if self.src is None else Sys.basename(self.src)]) if self.encmode: - self.dst = ''.join([self.dst, conf.DEFVAL_CRYPT_EXT]) + self.dst = ''.join([self.dst, Kirmah.EXT if not self.splitmode else Kirmah.EXT_TARK]) else : self.dst, ext = Sys.getFileExt(self.dst) - if Io.file_exists(self.dst): - raise FileNeedOverwriteException(self.dst) + if not ext == (Kirmah.EXT if not self.splitmode else Kirmah.EXT_TARK): + self.dst += ext + #~ if Io.file_exists(self.dst): + #~ raise FileNeedOverwriteException(self.dst) else : self.dst = None @Log(Const.LOG_DEFAULT) def getCall(self): + q = '' action = ('enc' if self.encmode else 'dec') if not self.splitmode else ('split' if self.encmode else 'merge') comp = '-a' if self.compression==1 else ('-z' if self.compression==2 else '-Z') mproc = '' if self.nproc==0 or self.splitmode else '-j'+str(self.nproc) rmode = '-r' if self.random else '-R ' mmode = '-m' if self.mix else '-M' debug = '-fd' if Sys.g.DEBUG else '-f' + key = '-k'+q+self.kpath+q if self.kpath != self.getDefaultKeyPath() else '' #~ q = '"' - q = '' - call = ['kirmah-cli.py',debug, action,q+self.src+q,comp,mproc,rmode,mmode,'-o',q+self.dst+q] + call = ['kirmah-cli.py',debug, action,q+self.src+q,comp,mproc,rmode,mmode,'-o',q+self.dst+q,key] print('python '+(' '.join(call))) return call diff --git a/kirmah/cli.py b/kirmah/cli.py index b82b7d0..e29435d 100755 --- a/kirmah/cli.py +++ b/kirmah/cli.py @@ -4,7 +4,7 @@ # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # software : Kirmah -# version : 2.17 +# version : 2.18 # date : 2013 # licence : GPLv3.0 # author : a-Sansara <[a-sansara]at[clochardprod]dot[net]> diff --git a/kirmah/cliapp.py b/kirmah/cliapp.py index 0cc33bd..57aeafc 100755 --- a/kirmah/cliapp.py +++ b/kirmah/cliapp.py @@ -4,7 +4,7 @@ # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # software : Kirmah -# version : 2.17 +# version : 2.18 # date : 2013 # licence : GPLv3.0 # author : a-Sansara <[a-sansara]at[clochardprod]dot[net]> @@ -158,11 +158,9 @@ class CliApp: km.decrypt(self.a[1], self.o.outputfile, nproc) - except BadKeyException as e : + except BadKeyException: done = False - Sys.pwarn(('BadKeyException',)) - if Sys.g.DEBUG : - raise e + Sys.pwarn((('BadKeyException : ',('wrong key ',Sys.CLZ_WARN_PARAM), ' !'),), False) if not Sys.g.QUIET : self.onend_cmd('Kirmah Decrypt', self.stime, done, self.o.outputfile) @@ -257,35 +255,52 @@ class CliApp: key = Io.get_data(self.o.keyfile) km = Kirmah(key) - + kcf = None + istar = True try: import tarfile + dpath = Sys.dirname(Sys.realpath(self.o.outputfile))+Sys.sep if self.o.outputfile is not None else Sys.dirname(Sys.realpath(self.a[1]))+Sys.sep + if self.o.outputfile is None : + self.o.outputfile = dpath with tarfile.open(self.a[1], mode='r') as tar: - dpath = Sys.dirname(Sys.realpath(self.o.outputfile))+Sys.sep if self.o.outputfile is not None else '.'+Sys.sep - print(dpath) + #~ print(dpath) tar.extractall(path=dpath) kcf = None for tarinfo in tar: - print(tarinfo.name) + #~ print(tarinfo.name) if tarinfo.isreg() and tarinfo.name[-4:]=='.kcf': + #~ print(dpath+tarinfo.name) kcf = dpath+tarinfo.name - if kcf is not None : - toPath = km.mergeFile(kcf) - except Exception as e: - Sys.pwarn((('onCommandMerge : ',(str(e),Sys.CLZ_WARN_PARAM), ' !'),), False) - raise e - toPath = km.mergeFile(self.a[1]) - if self.o.outputfile is not None : - Io.rename(toPath, self.o.outputfile) - toPath = self.o.outputfile + if kcf is not None : + km.DIR_OUTBOX = dpath + toPath = km.mergeFile(kcf, self.o.outputfile) + except BadKeyException: + Sys.pwarn((('BadKeyException : ',('wrong key ',Sys.CLZ_WARN_PARAM), ' !'),), False) + done = False + + except Exception : + istar = False + toPath = km.mergeFile(self.a[1], self.o.outputfile) + + #~ if self.o.outputfile is not None : + #~ Io.rename(toPath, self.o.outputfile) + #~ toPath = self.o.outputfile + + except BadKeyException: + Sys.pwarn((('BadKeyException : ',('wrong key ',Sys.CLZ_WARN_PARAM), ' !'),), False) + done = False except Exception as e : done = False if Sys.g.DEBUG : print(e) - raise e elif not Sys.g.QUIET : Sys.pwarn((str(e),)) + if not done : + if istar : + with tarfile.open(self.a[1], mode='r') as tar: + for tarinfo in tar: + Sys.removeFile(dpath+tarinfo.name) if not Sys.g.QUIET : self.onend_cmd('Kirmah Merge', self.stime, done, toPath) @@ -312,6 +327,7 @@ class CliApp: Sys.print(s, Sys.CLZ_HEAD_LINE) Sys.wlog([(s, Const.CLZ_HEAD_SEP)]) if done and outputfile is not None: + Sys.cli_emit_progress(100) Sys.print(' '*5+Sys.realpath(outputfile), Sys.Clz.fgB1, False) Sys.print(' ('+Sys.getFileSize(outputfile)+')', Sys.Clz.fgB3) bdata = [(' '*5+Sys.realpath(outputfile), 'io'),(' ('+Sys.getFileSize(outputfile)+')','func')] diff --git a/kirmah/conf.py b/kirmah/conf.py index 8d086e9..f0205b9 100755 --- a/kirmah/conf.py +++ b/kirmah/conf.py @@ -4,7 +4,7 @@ # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # software : Kirmah -# version : 2.17 +# version : 2.18 # date : 2013 # licence : GPLv3.0 # author : a-Sansara <[a-sansara]at[clochardprod]dot[net]> @@ -39,7 +39,7 @@ PRG_NAME = 'Kirmah' PRG_PACKAGE = PRG_NAME.lower() PRG_SCRIPT = PRG_NAME.lower() PRG_CLI_NAME = PRG_SCRIPT+'-cli' -PRG_VERS = '2.1' +PRG_VERS = '2.18' PRG_AUTHOR = 'a-Sansara' PRG_COPY = 'pluie.org' PRG_YEAR = '2013' diff --git a/kirmah/crypt.py b/kirmah/crypt.py index 3421403..b6ec3fb 100755 --- a/kirmah/crypt.py +++ b/kirmah/crypt.py @@ -4,7 +4,7 @@ # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # software : Kirmah -# version : 2.17 +# version : 2.18 # date : 2013 # licence : GPLv3.0 # author : a-Sansara <[a-sansara]at[clochardprod]dot[net]> @@ -669,11 +669,13 @@ class Kirmah: clist = literal_eval(data) Sys.removeFile('.cfg') theList = self.ck.getHashList(clist['name'], clist['count'], True) - dirs = Sys.dirname(Sys.realpath(toPath)) if toPath is not None else None ext = '' if toPath is None : toPath = clist['name'] + elif Sys.isdir(toPath) : + toPath += clist['name'] toPath, ext = Sys.getFileExt(toPath) + dirs = (Sys.dirname(Sys.realpath(toPath)) if toPath is not None else Sys.dirname(Sys.realpath(fromPath)))+Sys.sep Sys.cli_emit_progress(10) toPath = self.merge(theList, toPath, ext, uid, dirs) Sys.removeFile(fromPath) @@ -688,16 +690,21 @@ class Kirmah: p = 0 # ensure correct order hlst['data'] = sorted(hlst['data'], key=lambda lst: lst[0]) - - if dirs is not None and dirs!='none' : - dirPath = Sys.join(self.DIR_DEPLOY,dirs)+Sys.sep - Sys.mkdir_p(dirPath) - else: dirPath = self.DIR_DEPLOY - filePath = dirPath+fileName + #~ print(hlst['head']) + #~ for row in hlst['data']: + #~ print(row) + #~ if dirs is not None and dirs!='none' : + #~ dirPath = Sys.join(self.DIR_DEPLOY,dirs)+Sys.sep + #~ Sys.mkdir_p(dirPath) + #~ else: dirPath = self.DIR_DEPLOY + #~ print('dirPath') + #~ print(dirPath) + #~ filePath = dirPath+fileName + filePath = fileName if Io.file_exists(filePath+ext): filePath += '-'+str(uid) - filePath = Sys.abspath(filePath+ext) - depDir = self.DIR_INBOX if not fake else self.DIR_OUTBOX + filePath += ext + depDir = dirs perc = 10 frav = 2.7 with Io.wfile(filePath) as fo : @@ -895,11 +902,9 @@ class Kirmah: if Sys.g.DEBUG : Sys.wlog(Sys.dprint()) if decHeader['smode'] == self.mark[fsize%len(self.mark)] : Sys.pstep('Reading Header', d, True) - #~ print('ok valid') - """""" else : - Sys.pstep('Reading Header', d, False) - raise BadKeyException() + Sys.pstep('Reading Header', d, False, False, False) + raise BadKeyException('wrong key') compend, compstart = not decHeader['cmode']== KirmahHeader.COMP_NONE, decHeader['cmode']== KirmahHeader.COMP_ALL fp, tp = fromPath, self.tmpPath1 @@ -1022,6 +1027,7 @@ class Kirmah: fp, tp, compstart = self.decrypt_sp_start(fromPath, toPath, emit=emit) self.decrypt_mproc(fp, tp, nproc, emit=emit) self.decrypt_sp_end(tp, toPath, compstart, emit=emit) + Sys.cli_emit_progress(100) @@ -1211,4 +1217,4 @@ class Noiser: # ~~ class BadKeyException ~~ class BadKeyException(BaseException): - pass + """""" diff --git a/kirmah/gui.py b/kirmah/gui.py index e070db6..bef588b 100644 --- a/kirmah/gui.py +++ b/kirmah/gui.py @@ -4,7 +4,7 @@ # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # software : Kirmah -# version : 2.17 +# version : 2.18 # date : 2013 # licence : GPLv3.0 # author : a-Sansara <[a-sansara]at[clochardprod]dot[net]> @@ -229,7 +229,7 @@ class AppGui(Gui): if not self.app.splitmode : for n in ['checkbutton2','checkbutton4','comboboxtext1','label12']: self.disable(n, not self.app.encmode) - self.on_new_file_dest(self.get('filechooserbutton3')) + #~ self.on_new_file_dest(self.get('filechooserbutton3')) if self.start: self.refreshProceed() @@ -259,26 +259,22 @@ class AppGui(Gui): try: self.app.setSourceFile(fc.get_filename()) self.IS_SOURCE_DEF = True - self.on_new_file_dest(self.get('filechooserbutton3')) except FileNotFoundException as e: Sys.eprint('FileNotFoundException :' + str(fc.get_filename()), Const.ERROR) self.IS_SOURCE_DEF = False - - - @Log(Const.LOG_UI) - def on_dest_changed(self, fc, data=None): - """""" - self.on_new_file_dest(fc, data) + self.refreshProceed() @Log(Const.LOG_UI) def on_new_file_dest(self, fc, data=None): """""" + try : + self.app.setDestFile(fc.get_filename()) + print(self.app.dst) + except Exception as e : + print(e) + pass if self.start: - try : - self.app.setDestFile(fc.get_filename()) - except : - pass self.IS_DEST_DEF = True self.refreshProceed() @@ -301,6 +297,7 @@ class AppGui(Gui): self.disable('spinbutton1',False) self.disable('filechooserbutton1',False) self.get('filechooserbutton1').set_current_folder(conf.DEFVAL_UKEY_PATH) + self.get('filechooserbutton1').set_filename(conf.DEFVAL_UKEY_PATH+'.rename.key') @Log(Const.LOG_UI) @@ -351,8 +348,8 @@ class AppGui(Gui): @Log(Const.LOG_UI) def refreshProceed(self): """""" - if self.start : - self.get('button1').set_sensitive(self.IS_DEST_DEF and self.IS_SOURCE_DEF) + #~ if self.start : + self.get('button1').set_sensitive(self.IS_DEST_DEF and self.IS_SOURCE_DEF) @Log(Const.LOG_UI) @@ -369,12 +366,12 @@ class AppGui(Gui): self.PROCEED = True self.STOPPED = False btn.set_sensitive(False) - self.on_new_file_dest(self.get('filechooserbutton3')) - self.pb = self.get('progressbar1') - self.pb.set_fraction(0) - self.pb.show() - self.pb.pulse() + self.app.setDestFile(self.get('filechooserbutton3').get_filename()) if not Io.file_exists(self.app.dst) or self.warnDialog('file '+self.app.dst+' already exists', 'Overwrite file ?'): + self.pb = self.get('progressbar1') + self.pb.set_fraction(0) + self.pb.show() + self.pb.pulse() btn.set_sensitive(True) btn.set_label(conf.GUI_LABEL_CANCEL) self.clear_log(self.get('checkbutton3')) @@ -395,6 +392,9 @@ class AppGui(Gui): self.thkmh.cancel() else : self.textbuffer.insert_at_cursor('Kmh Thread is not Alive\n') + self.on_proceed_end(True) + self.pb.hide() + self.show_log() @Log(Const.LOG_UI) diff --git a/kirmah/ui.py b/kirmah/ui.py index 3b2cd44..4e83eea 100644 --- a/kirmah/ui.py +++ b/kirmah/ui.py @@ -4,7 +4,7 @@ # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # software : Kirmah -# version : 2.17 +# version : 2.18 # date : 2013 # licence : GPLv3.0 # author : a-Sansara <[a-sansara]at[clochardprod]dot[net]> @@ -358,7 +358,7 @@ class CliThread(Thread, IdleObject): """""" if self.isAlive(): self.cancel() - if current_thread() .getName()==self.getName(): + if current_thread().getName()==self.getName(): try: self.emit("interrupted") Sys.thread_exit() diff --git a/psr/cli.py b/psr/cli.py index db53796..bba0162 100644 --- a/psr/cli.py +++ b/psr/cli.py @@ -4,7 +4,7 @@ # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # software : Kirmah -# version : 2.17 +# version : 2.18 # date : 2013 # licence : GPLv3.0 # author : a-Sansara <[a-sansara]at[clochardprod]dot[net]> diff --git a/psr/const.py b/psr/const.py index 1630e92..9398699 100644 --- a/psr/const.py +++ b/psr/const.py @@ -4,7 +4,7 @@ # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # software : Kirmah -# version : 2.17 +# version : 2.18 # date : 2013 # licence : GPLv3.0 # author : a-Sansara <[a-sansara]at[clochardprod]dot[net]> @@ -89,6 +89,6 @@ class Const: UNIT_SHORT_TIB = 'TiB' LINE_SEP_LEN = 100 - LINE_SEP_CHAR = '―' - + LINE_SEP_CHAR = '―' + const = Const() diff --git a/psr/io.py b/psr/io.py index 79c127c..fbef095 100644 --- a/psr/io.py +++ b/psr/io.py @@ -4,7 +4,7 @@ # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # software : Kirmah -# version : 2.17 +# version : 2.18 # date : 2013 # licence : GPLv3.0 # author : a-Sansara <[a-sansara]at[clochardprod]dot[net]> @@ -241,6 +241,7 @@ class Io: try: if path is not None : with open(path) as f: exist = True + f.close() except IOError as e: pass return exist diff --git a/psr/log.py b/psr/log.py index d209a06..b266fb2 100644 --- a/psr/log.py +++ b/psr/log.py @@ -4,7 +4,7 @@ # # # # # # # # # # # # # # # # # # # # # # # # # # software : Kirmah -# version : 2.17 +# version : 2.18 # date : 2013 # licence : GPLv3.0 # author : a-Sansara <[a-sansara]at[clochardprod]dot[net]> diff --git a/psr/mproc.py b/psr/mproc.py index daad5ad..27c5d0c 100644 --- a/psr/mproc.py +++ b/psr/mproc.py @@ -4,7 +4,7 @@ # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # software : Kirmah -# version : 2.17 +# version : 2.18 # date : 2013 # licence : GPLv3.0 # author : a-Sansara <[a-sansara]at[clochardprod]dot[net]> diff --git a/psr/sys.py b/psr/sys.py index dc7fad2..23c5e21 100644 --- a/psr/sys.py +++ b/psr/sys.py @@ -4,7 +4,7 @@ # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # software : Kirmah -# version : 2.17 +# version : 2.18 # date : 2013 # licence : GPLv3.0 # author : a-Sansara <[a-sansara]at[clochardprod]dot[net]> @@ -353,18 +353,18 @@ class Sys: if not dbcall : Sys.print(w, clzp, False, False) bdata = [] - if Sys.g.DEBUG : + if not Sys.g.QUIET : bdata.append((w, uiclzp)) for i, line in enumerate(data) : if i > 0 : if not dbcall : Sys.print(' '*len(w), clz, False, False) - if Sys.g.DEBUG : + if not Sys.g.QUIET : bdata.append((' '*len(w), uiclz)) if isinstance(line,str) : s = line.ljust(length-len(w),' ') if not dbcall : Sys.print(s, clz, True, True) - if Sys.g.DEBUG : + if not Sys.g.QUIET : bdata.append((s, uiclz)) Sys.wlog(bdata) bdata = [] @@ -381,7 +381,7 @@ class Sys: sl += len(p[0]) s = ' '.ljust(length-sl-len(w),' ') if not dbcall : Sys.print(s, clz, True, True) - if Sys.g.DEBUG : + if not Sys.g.QUIET : bdata.append((s, uiclz)) Sys.wlog(bdata) bdata = [] diff --git a/psr/w32color.py b/psr/w32color.py index b8eb59c..a1c6e53 100644 --- a/psr/w32color.py +++ b/psr/w32color.py @@ -4,7 +4,7 @@ # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # software : Kirmah -# version : 2.17 +# version : 2.18 # date : 2013 # licence : GPLv3.0 # author : a-Sansara <[a-sansara]at[clochardprod]dot[net]> diff --git a/resources/kirmah/glade/kirmah.glade b/resources/kirmah/glade/kirmah.glade index cac33c0..ec647bb 100644 --- a/resources/kirmah/glade/kirmah.glade +++ b/resources/kirmah/glade/kirmah.glade @@ -720,7 +720,6 @@ vertical select-folder - True @@ -917,6 +916,8 @@ False True + 5 + 5 True diff --git a/setup.py b/setup.py index 1125f83..bf11236 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # software : Kirmah -# version : 2.17 +# version : 2.18 # date : 2013 # licence : GPLv3.0 # author : a-Sansara <[a-sansara]at[clochardprod]dot[net]>