bugfix somes gui issues on destination file

This commit is contained in:
a-Sansara 2013-05-15 20:51:08 +02:00
parent c367db484c
commit db4adc0518
20 changed files with 117 additions and 90 deletions

View File

@ -1,4 +1,4 @@
Kirmah 2.17 (2013-05-06)
Kirmah 2.18 (2013-05-15)
=========================
New General Features

4
README
View File

@ -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

View File

@ -4,7 +4,7 @@
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# software : Kirmah <http://kirmah.sourceforge.net/>
# version : 2.17
# version : 2.18
# date : 2013
# licence : GPLv3.0 <http://www.gnu.org/licenses/>
# 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

View File

@ -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

View File

@ -4,7 +4,7 @@
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# software : Kirmah <http://kirmah.sourceforge.net/>
# version : 2.17
# version : 2.18
# date : 2013
# licence : GPLv3.0 <http://www.gnu.org/licenses/>
# 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

View File

@ -4,7 +4,7 @@
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# software : Kirmah <http://kirmah.sourceforge.net/>
# version : 2.17
# version : 2.18
# date : 2013
# licence : GPLv3.0 <http://www.gnu.org/licenses/>
# author : a-Sansara <[a-sansara]at[clochardprod]dot[net]>

View File

@ -4,7 +4,7 @@
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# software : Kirmah <http://kirmah.sourceforge.net/>
# version : 2.17
# version : 2.18
# date : 2013
# licence : GPLv3.0 <http://www.gnu.org/licenses/>
# 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
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')]

View File

@ -4,7 +4,7 @@
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# software : Kirmah <http://kirmah.sourceforge.net/>
# version : 2.17
# version : 2.18
# date : 2013
# licence : GPLv3.0 <http://www.gnu.org/licenses/>
# 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'

View File

@ -4,7 +4,7 @@
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# software : Kirmah <http://kirmah.sourceforge.net/>
# version : 2.17
# version : 2.18
# date : 2013
# licence : GPLv3.0 <http://www.gnu.org/licenses/>
# 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
""""""

View File

@ -4,7 +4,7 @@
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# software : Kirmah <http://kirmah.sourceforge.net/>
# version : 2.17
# version : 2.18
# date : 2013
# licence : GPLv3.0 <http://www.gnu.org/licenses/>
# 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):
""""""
if self.start:
try :
self.app.setDestFile(fc.get_filename())
except :
print(self.app.dst)
except Exception as e :
print(e)
pass
if self.start:
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,7 +348,7 @@ class AppGui(Gui):
@Log(Const.LOG_UI)
def refreshProceed(self):
""""""
if self.start :
#~ if self.start :
self.get('button1').set_sensitive(self.IS_DEST_DEF and self.IS_SOURCE_DEF)
@ -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.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()
if not Io.file_exists(self.app.dst) or self.warnDialog('file '+self.app.dst+' already exists', 'Overwrite file ?'):
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)

View File

@ -4,7 +4,7 @@
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# software : Kirmah <http://kirmah.sourceforge.net/>
# version : 2.17
# version : 2.18
# date : 2013
# licence : GPLv3.0 <http://www.gnu.org/licenses/>
# 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()

View File

@ -4,7 +4,7 @@
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# software : Kirmah <http://kirmah.sourceforge.net/>
# version : 2.17
# version : 2.18
# date : 2013
# licence : GPLv3.0 <http://www.gnu.org/licenses/>
# author : a-Sansara <[a-sansara]at[clochardprod]dot[net]>

View File

@ -4,7 +4,7 @@
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# software : Kirmah <http://kirmah.sourceforge.net/>
# version : 2.17
# version : 2.18
# date : 2013
# licence : GPLv3.0 <http://www.gnu.org/licenses/>
# author : a-Sansara <[a-sansara]at[clochardprod]dot[net]>

View File

@ -4,7 +4,7 @@
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# software : Kirmah <http://kirmah.sourceforge.net/>
# version : 2.17
# version : 2.18
# date : 2013
# licence : GPLv3.0 <http://www.gnu.org/licenses/>
# 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

View File

@ -4,7 +4,7 @@
# # # # # # # # # # # # # # # # # # # # # # # #
#
# software : Kirmah <http://kirmah.sourceforge.net/>
# version : 2.17
# version : 2.18
# date : 2013
# licence : GPLv3.0 <http://www.gnu.org/licenses/>
# author : a-Sansara <[a-sansara]at[clochardprod]dot[net]>

View File

@ -4,7 +4,7 @@
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# software : Kirmah <http://kirmah.sourceforge.net/>
# version : 2.17
# version : 2.18
# date : 2013
# licence : GPLv3.0 <http://www.gnu.org/licenses/>
# author : a-Sansara <[a-sansara]at[clochardprod]dot[net]>

View File

@ -4,7 +4,7 @@
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# software : Kirmah <http://kirmah.sourceforge.net/>
# version : 2.17
# version : 2.18
# date : 2013
# licence : GPLv3.0 <http://www.gnu.org/licenses/>
# 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 = []

View File

@ -4,7 +4,7 @@
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# software : Kirmah <http://kirmah.sourceforge.net/>
# version : 2.17
# version : 2.18
# date : 2013
# licence : GPLv3.0 <http://www.gnu.org/licenses/>
# author : a-Sansara <[a-sansara]at[clochardprod]dot[net]>

View File

@ -720,7 +720,6 @@
<property name="orientation">vertical</property>
<property name="action">select-folder</property>
<signal name="file-set" handler="on_new_file_dest" swapped="no"/>
<signal name="current-folder-changed" handler="on_dest_changed" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
@ -917,6 +916,8 @@
<object class="GtkProgressBar" id="progressbar1">
<property name="can_focus">False</property>
<property name="no_show_all">True</property>
<property name="margin_left">5</property>
<property name="margin_right">5</property>
</object>
<packing>
<property name="expand">True</property>

View File

@ -4,7 +4,7 @@
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# software : Kirmah <http://kirmah.sourceforge.net/>
# version : 2.17
# version : 2.18
# date : 2013
# licence : GPLv3.0 <http://www.gnu.org/licenses/>
# author : a-Sansara <[a-sansara]at[clochardprod]dot[net]>