v2.17 FIXE multi-thread crash on cli launching with gui

This commit is contained in:
a-Sansara 2013-05-06 04:16:30 +02:00
parent a81cd2f13b
commit 5edfa79af5
24 changed files with 4943 additions and 1463 deletions

12
CHANGELOG Normal file
View File

@ -0,0 +1,12 @@
Kirmah 2.17 (2013-05-06)
=========================
New General Features
-------------------------
*
Bugfixes
-------------------------
* [#] --

27
README Normal file
View File

@ -0,0 +1,27 @@
Kirmah 2.17 (2013-05-06)
=========================
Install on Archlinux
-------------------------
sudo pacman -U http://sourceforge.net/projects/kirmah/files/packages/archlinux/kirmah-2.17-1-any.pkg.tar.xz/download
(re)build instruction
-------------------------
mkdir /tmp/kirmah; cd /tmp/kirmah;
wget http://sourceforge.net/projects/kirmah/files/packages/archlinux/PKGBUILD/download
mv download PKGBUILD
wget http://sourceforge.net/projects/kirmah/files/packages/archlinux/kirmah.install/download
mv download kirmah.install
makepkg -s;
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-cli.py
you can also use python2 disutils and setup.py

View File

@ -1,34 +1,44 @@
#!/usr/bin/env python # !/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # kirmah-cli.py
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# software : Kirmah <http://kirmah.sourceforge.net/> #
# version : 2.1 #
# date : 2013 #
# licence : GPLv3.0 <http://www.gnu.org/licenses/> #
# author : a-Sansara <http://www.a-sansara.net/> #
# copyright : pluie.org <http://www.pluie.org/> #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# This file is part of Kirmah. # software : Kirmah <http://kirmah.sourceforge.net/>
# version : 2.17
# date : 2013
# licence : GPLv3.0 <http://www.gnu.org/licenses/>
# author : a-Sansara <[a-sansara]at[clochardprod]dot[net]>
# copyright : pluie.org <http://www.pluie.org/>
# #
# Kirmah is free software (free as in speech) : you can redistribute it # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of the License,
# or (at your option) any later version.
# #
# Kirmah is distributed in the hope that it will be useful, but WITHOUT # This file is part of Kirmah.
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # Kirmah is free software (free as in speech) : you can redistribute it
# more details. # and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of the License,
# or (at your option) any later version.
#
# Kirmah is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License
# along with Kirmah. If not, see <http://www.gnu.org/licenses/>.
# #
# You should have received a copy of the GNU General Public License
# along with Kirmah. If not, see <http://www.gnu.org/licenses/>.
from psr.sys import init, Sys from psr.sys import Sys, Const
from kirmah.cli import Cli from kirmah.cli import Cli
from kirmah import conf
init(conf.PRG_NAME, False) def main():
Cli('.'+Sys.sep) try:
c = 0
Cli('.'+Sys.sep)
except Exception as e :
Sys.pwarn((('main : ',(str(e),Sys.CLZ_ERROR_PARAM), ' !'),), True)
c = 1
return c
if __name__ == '__main__':
Sys.exit(main())

44
kirmah.py Normal file
View File

@ -0,0 +1,44 @@
# !/usr/bin/env python3
# -*- coding: utf-8 -*-
# kirmah.py
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# software : Kirmah <http://kirmah.sourceforge.net/>
# version : 2.17
# date : 2013
# licence : GPLv3.0 <http://www.gnu.org/licenses/>
# author : a-Sansara <[a-sansara]at[clochardprod]dot[net]>
# copyright : pluie.org <http://www.pluie.org/>
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# This file is part of Kirmah.
#
# Kirmah is free software (free as in speech) : you can redistribute it
# and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of the License,
# or (at your option) any later version.
#
# Kirmah is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License
# along with Kirmah. If not, see <http://www.gnu.org/licenses/>.
#
from psr.sys import Sys, Const
from kirmah.gui import AppGui
def main():
try:
c = 0
AppGui()
except Exception as e:
Sys.pwarn((('main : ',(str(e),Sys.CLZ_ERROR_PARAM), ' !'),), True)
c = 1
return c
if __name__ == '__main__':
Sys.exit(main())

203
kirmah/app.py Normal file
View File

@ -0,0 +1,203 @@
# !/usr/bin/env python
# -*- coding: utf-8 -*-
# kirmah.app.py
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# software : Kirmah <http://kirmah.sourceforge.net/>
# version : 2.17
# date : 2013
# licence : GPLv3.0 <http://www.gnu.org/licenses/>
# author : a-Sansara <[a-sansara]at[clochardprod]dot[net]>
# copyright : pluie.org <http://www.pluie.org/>
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# This file is part of Kirmah.
#
# Kirmah is free software (free as in speech) : you can redistribute it
# and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of the License,
# or (at your option) any later version.
#
# Kirmah is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License
# along with Kirmah. If not, see <http://www.gnu.org/licenses/>.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~ module app ~~
from os.path import splitext
from threading import Thread, Timer, Event, get_ident, enumerate as thread_enum, current_thread
from kirmah import conf
from kirmah.crypt import KeyGen, Kirmah, KirmahHeader
from psr.sys import Sys, Io, Const, init
from psr.log import Log
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~ class KirmahApp ~~
class KirmahApp:
@Log(Const.LOG_BUILD)
def __init__(self, debug=True, color=True, loglvl=Const.LOG_DEFAULT):
""""""
self.encmode = conf.DEFVAL_ENCMODE
self.splitmode = False
self.compression = conf.DEFVAL_COMP
self.mix = conf.DEFVAL_MIXMODE
self.random = conf.DEFVAL_RANDOMMODE
self.nproc = conf.DEFVAL_NPROC
self.src = None
self.dst = None
self.kpath = None
Sys.g.GUI = True
init(conf.PRG_NAME, debug, Sys.getpid(), color, loglvl)
@Log(Const.LOG_DEBUG)
def getDefaultKeyPath(self):
""""""
return conf.DEFVAL_UKEY_PATH+conf.DEFVAL_UKEY_NAME
@Log(Const.LOG_DEBUG)
def createDefaultKeyIfNone(self):
""""""
kpath = self.getDefaultKeyPath()
if not Io.file_exists(kpath):
if Sys.isUnix() :
if not Sys.isdir(conf.DEFVAL_UKEY_PATH) :
Sys.mkdir_p(conf.DEFVAL_UKEY_PATH)
Io.set_data(kpath, KeyGen(conf.DEFVAL_UKEY_LENGHT).key)
self.selectKey(kpath)
@Log(Const.LOG_DEBUG)
def createNewKey(self, filename, size):
""""""
if not Sys.isdir(Sys.dirname(filename)):
Sys.mkdir_p(Sys.dirname(filename))
Io.set_data(filename,KeyGen(size).key[:size])
@Log(Const.LOG_DEBUG)
def getKeyInfos(self, filename=None):
""""""
if filename is None : filename = self.getDefaultKeyPath()
if not Io.file_exists(filename):
raise FileNotFoundException(filename)
k = Io.get_data(filename)
s = len(k)
m = KeyGen(s).getMark(k)
return k, s, m
@Log(Const.LOG_DEBUG)
def selectKey(self, filename):
""""""
if not Io.file_exists(filename):
raise FileNotFoundException(filename)
self.kpath = filename
@Log(Const.LOG_DEBUG)
def setCompression(self, value=1):
""""""
self.compression = value
@Log(Const.LOG_DEBUG)
def setMixMode(self, enable=True):
""""""
self.mix = enable
@Log(Const.LOG_DEBUG)
def setRandomMode(self, enable=True):
""""""
self.random = enable
@Log(Const.LOG_DEBUG)
def setMultiprocessing(self, nproc):
""""""
# disable
if nproc is None or nproc is False or nproc < conf.DEFVAL_NPROC_MIN :
self.nproc = 0
# enable
else :
self.nproc = nproc if nproc <= conf.DEFVAL_NPROC_MAX else conf.DEFVAL_NPROC_MAX
@Log(Const.LOG_DEBUG)
def switchEncMode(self, isEnc=True):
""""""
self.encmode = isEnc
@Log(Const.LOG_DEBUG)
def switchFormatMode(self, isTxt=True):
self.splitmode = not isTxt
@Log(Const.LOG_DEBUG)
def setSourceFile(self, filename):
""""""
if not Io.file_exists(filename) :
raise FileNotFoundException()
else :
self.src = filename
@Log(Const.LOG_DEBUG)
def hasSrcFile(self):
""""""
return Io.file_exists(self.src)
@Log(Const.LOG_DEBUG)
def setDestFile(self, path):
""""""
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])
else :
self.dst, ext = Sys.getFileExt(self.dst)
if Io.file_exists(self.dst):
raise FileNeedOverwriteException(self.dst)
else : self.dst = None
@Log(Const.LOG_DEFAULT)
def getCall(self):
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'
#~ q = '"'
q = ''
call = ['kirmah-cli.py',debug, action,q+self.src+q,comp,mproc,rmode,mmode,'-o',q+self.dst+q]
print('python '+(' '.join(call)))
return call
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~ class FileNotFoundException ~~
class FileNotFoundException(BaseException):
""""""
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~ class FileNeedOverwriteException ~~
class FileNeedOverwriteException(BaseException):
""""""

View File

@ -1,62 +1,68 @@
#!/usr/bin/env python # !/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # kirmah.cli.py
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# software : Kirmah <http://kirmah.sourceforge.net/> #
# version : 2.1 #
# date : 2013 #
# licence : GPLv3.0 <http://www.gnu.org/licenses/> #
# author : a-Sansara <http://www.a-sansara.net/> #
# copyright : pluie.org <http://www.pluie.org/> #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# This file is part of Kirmah. # software : Kirmah <http://kirmah.sourceforge.net/>
# version : 2.17
# date : 2013
# licence : GPLv3.0 <http://www.gnu.org/licenses/>
# author : a-Sansara <[a-sansara]at[clochardprod]dot[net]>
# copyright : pluie.org <http://www.pluie.org/>
# #
# Kirmah is free software (free as in speech) : you can redistribute it # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of the License,
# or (at your option) any later version.
# #
# Kirmah is distributed in the hope that it will be useful, but WITHOUT # This file is part of Kirmah.
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # Kirmah is free software (free as in speech) : you can redistribute it
# more details. # and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of the License,
# or (at your option) any later version.
#
# Kirmah is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License
# along with Kirmah. If not, see <http://www.gnu.org/licenses/>.
# #
# You should have received a copy of the GNU General Public License
# along with Kirmah. If not, see <http://www.gnu.org/licenses/>.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~ package cli ~~ # ~~ module cli ~~
from optparse import OptionParser, OptionGroup from optparse import OptionParser, OptionGroup
import kirmah.conf as conf import kirmah.conf as conf
from kirmah.cliapp import CliApp from kirmah.cliapp import CliApp
from psr.sys import Sys from psr.sys import Sys, Io, Const, init
from psr.io import Io from psr.log import Log
if not Sys.isUnix : Const.LINE_SEP_CHAR = '-'
LINE_SEP_LEN = 120
LINE_SEP_CHAR = ''
if not Sys.isUnix : LINE_SEP_CHAR = '-'
def printLineSep(sep,lenSep): def printLineSep(sep,lenSep):
"""""" """"""
Sys.print(sep*lenSep, Sys.Clz.fgN0) s = sep*lenSep
Sys.print(s, Sys.CLZ_HEAD_LINE)
return [(s, Const.CLZ_HEAD_SEP)]
def printHeaderTitle(title): def printHeaderTitle(title):
"""""" """"""
Sys.print(' == '+title+' == ', Sys.Clz.BG4+Sys.Clz.fgB7, False, True) s = ' == '+title+' == '
Sys.print(s, Sys.CLZ_HEAD_APP, False, True)
return [(s, Const.CLZ_HEAD_APP)]
def printHeaderPart(label,value): def printHeaderPart(label,value):
"""""" """"""
Sys.print(' [' , Sys.Clz.fgB0, False) a, b, c = ' [',':' ,'] '
Sys.print(label, Sys.Clz.fgB3, False) Sys.print(a , Sys.CLZ_HEAD_SEP, False)
Sys.print(':' , Sys.Clz.fgB0, False) Sys.print(label, Sys.CLZ_HEAD_KEY, False)
Sys.print(value, Sys.Clz.fgB4, False) Sys.print(b , Sys.CLZ_HEAD_SEP, False)
Sys.print('] ' , Sys.Clz.fgB0, False) Sys.print(value, Sys.CLZ_HEAD_VAL, False)
Sys.print(c , Sys.CLZ_HEAD_SEP, False)
return [(a,Const.CLZ_HEAD_SEP),(label,Const.CLZ_HEAD_KEY),(b,Const.CLZ_HEAD_SEP),(value,Const.CLZ_HEAD_VAL),(c,Const.CLZ_HEAD_SEP)]
class _OptionParser(OptionParser): class _OptionParser(OptionParser):
@ -65,14 +71,14 @@ class _OptionParser(OptionParser):
def format_description(self, formatter): def format_description(self, formatter):
return self.description return self.description
def format_epilog(self, formatter): def format_epilog(self, formatter):
return self.epilog return self.epilog
def error(self, errMsg, errData=None):
def error(self, errMsg, errData=None):
self.print_usage('') self.print_usage('')
Cli.error_cmd(self, (errMsg,)) Cli.error_cmd(self, (errMsg,))
#~ Sys.exit(1)
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -80,10 +86,16 @@ class _OptionParser(OptionParser):
class Cli: class Cli:
def __init__(self,path): def __init__(self, path, remote=False, rwargs=None, thread=None, loglvl=Const.LOG_DEFAULT):
"""""" """"""
if thread is not None :
Sys.g.THREAD_CLI = thread
Sys.g.GUI = True
else :
Sys.g.GUI = False
self.HOME = Sys.sep+'home'+Sys.sep+Sys.getUserLogin()+Sys.sep
self.HOME = conf.DEFVAL_USER_PATH
self.DIRKEY = self.HOME+'.'+conf.PRG_NAME.lower()+Sys.sep self.DIRKEY = self.HOME+'.'+conf.PRG_NAME.lower()+Sys.sep
if not Sys.isUnix() : if not Sys.isUnix() :
CHQ = '"' CHQ = '"'
@ -91,14 +103,12 @@ class Cli:
self.DIRKEY = self.HOME+'keys'+Sys.sep self.DIRKEY = self.HOME+'keys'+Sys.sep
Sys.mkdir_p(self.DIRKEY) Sys.mkdir_p(self.DIRKEY)
#~ self.ini = util.IniFile(path+'impra.ini')
parser = _OptionParser() parser = _OptionParser()
parser.print_help = self.print_help parser.print_help = self.print_help
parser.print_usage = self.print_usage parser.print_usage = self.print_usage
gpData = OptionGroup(parser, '') gpData = OptionGroup(parser, '')
# metavar='<ARG1> <ARG2>', nargs=2
parser.add_option('-v', '--version' , action='store_true', default=False) parser.add_option('-v', '--version' , action='store_true', default=False)
parser.add_option('-d', '--debug' , action='store_true', default=False) parser.add_option('-d', '--debug' , action='store_true', default=False)
parser.add_option('-f', '--force' , action='store_true', default=False) parser.add_option('-f', '--force' , action='store_true', default=False)
@ -120,10 +130,16 @@ class Cli:
gpData.add_option('-o', '--outputfile' , action='store') gpData.add_option('-o', '--outputfile' , action='store')
parser.add_option_group(gpData) parser.add_option_group(gpData)
# rewrite argv sended by remote
if rwargs is not None :
import sys
sys.argv = rwargs
(o, a) = parser.parse_args() (o, a) = parser.parse_args()
Sys.g.COLOR_MODE = not o.no_color Sys.g.QUIET = o.quiet
Sys.g.DEBUG = o.debug and not o.quiet
init(conf.PRG_NAME, o.debug, remote, not o.no_color, loglvl)
if not a: if not a:
@ -158,12 +174,22 @@ class Cli:
elif a[0]=='dec' : app.onCommandDec() elif a[0]=='dec' : app.onCommandDec()
elif a[0]=='split': app.onCommandSplit() elif a[0]=='split': app.onCommandSplit()
elif a[0]=='merge': app.onCommandMerge() elif a[0]=='merge': app.onCommandMerge()
Sys.dprint('PUT END SIGNAL')
if Sys.g.LOG_QUEUE is not None :
Sys.g.LOG_QUEUE.put(Sys.g.SIGNAL_STOP)
else : else :
self.error_cmd((('unknow command ',(a[0],Sys.Clz.fgb3)),)) self.error_cmd((('unknow command ',(a[0],Sys.Clz.fgb3)),))
if not o.quiet : Sys.dprint() if not o.quiet : Sys.dprint()
def clean(self):
""""""
print('cleaning')
def error_cmd(self, data): def error_cmd(self, data):
"""""" """"""
self.print_usage('') self.print_usage('')
@ -179,15 +205,18 @@ class Cli:
def print_header(self): def print_header(self):
"""""" """"""
printLineSep(LINE_SEP_CHAR,LINE_SEP_LEN) a = printLineSep(Const.LINE_SEP_CHAR,Const.LINE_SEP_LEN)
printHeaderTitle(conf.PRG_CLI_NAME) b = printHeaderTitle(conf.PRG_CLI_NAME)
printHeaderPart('version' ,conf.PRG_VERS) c = printHeaderPart('version' ,conf.PRG_VERS)
printHeaderPart('author' ,conf.PRG_AUTHOR) d = printHeaderPart('author' ,conf.PRG_AUTHOR)
printHeaderPart('license' ,conf.PRG_LICENSE) e = printHeaderPart('license' ,conf.PRG_LICENSE)
printHeaderPart('copyright',conf.PRG_COPY) f = printHeaderPart('copyright',conf.PRG_COPY)
Sys.print(' ', Sys.Clz.OFF) Sys.print(' ', Sys.Clz.OFF)
printLineSep(LINE_SEP_CHAR,LINE_SEP_LEN) printLineSep(Const.LINE_SEP_CHAR,Const.LINE_SEP_LEN)
Sys.dprint() Sys.wlog(a)
Sys.wlog(b + c + d + e + f )
Sys.wlog(a)
Sys.wlog(Sys.dprint())
def print_version(self, data): def print_version(self, data):
@ -199,325 +228,324 @@ class Cli:
"""""" """"""
if not withoutHeader : self.print_header() if not withoutHeader : self.print_header()
Sys.print(' USAGE :\n' , Sys.Clz.fgB3) Sys.print(' USAGE :\n' , Sys.CLZ_HELP_CMD)
Sys.print(' '+conf.PRG_CLI_NAME+' ' , Sys.Clz.fgb7, False) Sys.print(' '+conf.PRG_CLI_NAME+' ' , Sys.CLZ_HELP_PRG, False)
Sys.print('help ' , Sys.Clz.fgB3) Sys.print('help ' , Sys.CLZ_HELP_CMD)
Sys.print(' '+conf.PRG_CLI_NAME+' ' , Sys.Clz.fgb7, False) Sys.print(' '+conf.PRG_CLI_NAME+' ' , Sys.CLZ_HELP_PRG, False)
Sys.print('key ' , Sys.Clz.fgB3, False) Sys.print('key ' , Sys.CLZ_HELP_CMD, False)
Sys.print('[ -l ' , Sys.Clz.fgB3, False) Sys.print('[ -l ' , Sys.CLZ_HELP_ARG, False)
Sys.print('{' , Sys.Clz.fgB1, False) Sys.print('{' , Sys.CLZ_HELP_PARAM, False)
Sys.print('length' , Sys.Clz.fgB1, False) Sys.print('length' , Sys.CLZ_HELP_PARAM, False)
Sys.print('}' , Sys.Clz.fgB1, False) Sys.print('}' , Sys.CLZ_HELP_PARAM, False)
Sys.print(' -o ' , Sys.Clz.fgB3, False) Sys.print(' -o ' , Sys.CLZ_HELP_ARG, False)
Sys.print('{' , Sys.Clz.fgB1, False) Sys.print('{' , Sys.CLZ_HELP_PARAM, False)
Sys.print('outputFile' , Sys.Clz.fgB1, False) Sys.print('outputFile' , Sys.CLZ_HELP_PARAM, False)
Sys.print('}' , Sys.Clz.fgB1, False) Sys.print('}' , Sys.CLZ_HELP_PARAM, False)
Sys.print(']' , Sys.Clz.fgB3) Sys.print(']' , Sys.CLZ_HELP_ARG)
Sys.print(' '+conf.PRG_CLI_NAME+' ' , Sys.Clz.fgb7, False) Sys.print(' '+conf.PRG_CLI_NAME+' ' , Sys.CLZ_HELP_PRG, False)
Sys.print('enc ' , Sys.Clz.fgB3, False) Sys.print('enc ' , Sys.CLZ_HELP_CMD, False)
Sys.print('{' , Sys.Clz.fgB1, False) Sys.print('{' , Sys.CLZ_HELP_PARAM, False)
Sys.print('inputFile' , Sys.Clz.fgB1, False) Sys.print('inputFile' , Sys.CLZ_HELP_PARAM, False)
Sys.print('} ' , Sys.Clz.fgB1, False) Sys.print('} ' , Sys.CLZ_HELP_PARAM, False)
Sys.print('[' , Sys.Clz.fgB3, False) Sys.print('[' , Sys.CLZ_HELP_ARG, False)
Sys.print(' -z|Z|a -r|R -m|M -j ' , Sys.Clz.fgB3, False) Sys.print(' -z|Z|a -r|R -m|M -j ' , Sys.CLZ_HELP_ARG, False)
Sys.print('{' , Sys.Clz.fgB1, False) Sys.print('{' , Sys.CLZ_HELP_PARAM, False)
Sys.print('numProcess' , Sys.Clz.fgB1, False) Sys.print('numProcess' , Sys.CLZ_HELP_PARAM, False)
Sys.print('}' , Sys.Clz.fgB1, False) Sys.print('}' , Sys.CLZ_HELP_PARAM, False)
Sys.print(' -k ' , Sys.Clz.fgB3, False) Sys.print(' -k ' , Sys.CLZ_HELP_ARG, False)
Sys.print('{' , Sys.Clz.fgB1, False) Sys.print('{' , Sys.CLZ_HELP_PARAM, False)
Sys.print('keyFile' , Sys.Clz.fgB1, False) Sys.print('keyFile' , Sys.CLZ_HELP_PARAM, False)
Sys.print('}' , Sys.Clz.fgB1, False) Sys.print('}' , Sys.CLZ_HELP_PARAM, False)
Sys.print(' -o ' , Sys.Clz.fgB3, False) Sys.print(' -o ' , Sys.CLZ_HELP_ARG, False)
Sys.print('{' , Sys.Clz.fgB1, False) Sys.print('{' , Sys.CLZ_HELP_PARAM, False)
Sys.print('outputFile' , Sys.Clz.fgB1, False) Sys.print('outputFile' , Sys.CLZ_HELP_PARAM, False)
Sys.print('}' , Sys.Clz.fgB1, False) Sys.print('}' , Sys.CLZ_HELP_PARAM, False)
Sys.print(']' , Sys.Clz.fgB3) Sys.print(']' , Sys.CLZ_HELP_ARG)
Sys.print(' '+conf.PRG_CLI_NAME+' ' , Sys.Clz.fgb7, False) Sys.print(' '+conf.PRG_CLI_NAME+' ' , Sys.CLZ_HELP_PRG, False)
Sys.print('dec ' , Sys.Clz.fgB3, False) Sys.print('dec ' , Sys.CLZ_HELP_CMD, False)
Sys.print('{' , Sys.Clz.fgB1, False) Sys.print('{' , Sys.CLZ_HELP_PARAM, False)
Sys.print('inputFile' , Sys.Clz.fgB1, False) Sys.print('inputFile' , Sys.CLZ_HELP_PARAM, False)
Sys.print('} ' , Sys.Clz.fgB1, False) Sys.print('} ' , Sys.CLZ_HELP_PARAM, False)
Sys.print('[' , Sys.Clz.fgB3, False) Sys.print('[' , Sys.CLZ_HELP_ARG, False)
Sys.print(' -j ' , Sys.Clz.fgB3, False) Sys.print(' -j ' , Sys.CLZ_HELP_ARG, False)
Sys.print('{' , Sys.Clz.fgB1, False) Sys.print('{' , Sys.CLZ_HELP_PARAM, False)
Sys.print('numProcess' , Sys.Clz.fgB1, False) Sys.print('numProcess' , Sys.CLZ_HELP_PARAM, False)
Sys.print('}' , Sys.Clz.fgB1, False) Sys.print('}' , Sys.CLZ_HELP_PARAM, False)
Sys.print(' -k ' , Sys.Clz.fgB3, False) Sys.print(' -k ' , Sys.CLZ_HELP_ARG, False)
Sys.print('{' , Sys.Clz.fgB1, False) Sys.print('{' , Sys.CLZ_HELP_PARAM, False)
Sys.print('keyFile' , Sys.Clz.fgB1, False) Sys.print('keyFile' , Sys.CLZ_HELP_PARAM, False)
Sys.print('}' , Sys.Clz.fgB1, False) Sys.print('}' , Sys.CLZ_HELP_PARAM, False)
Sys.print(' -o ' , Sys.Clz.fgB3, False) Sys.print(' -o ' , Sys.CLZ_HELP_ARG, False)
Sys.print('{' , Sys.Clz.fgB1, False) Sys.print('{' , Sys.CLZ_HELP_PARAM, False)
Sys.print('outputFile' , Sys.Clz.fgB1, False) Sys.print('outputFile' , Sys.CLZ_HELP_PARAM, False)
Sys.print('}' , Sys.Clz.fgB1, False) Sys.print('}' , Sys.CLZ_HELP_PARAM, False)
Sys.print(']' , Sys.Clz.fgB3) Sys.print(']' , Sys.CLZ_HELP_ARG)
Sys.print(' '+conf.PRG_CLI_NAME+' ' , Sys.Clz.fgb7, False) Sys.print(' '+conf.PRG_CLI_NAME+' ' , Sys.CLZ_HELP_PRG, False)
Sys.print('split ' , Sys.Clz.fgB3, False) Sys.print('split ' , Sys.CLZ_HELP_CMD, False)
Sys.print('{' , Sys.Clz.fgB1, False) Sys.print('{' , Sys.CLZ_HELP_PARAM, False)
Sys.print('inputFile' , Sys.Clz.fgB1, False) Sys.print('inputFile' , Sys.CLZ_HELP_PARAM, False)
Sys.print('} ' , Sys.Clz.fgB1, False) Sys.print('} ' , Sys.CLZ_HELP_PARAM, False)
Sys.print('[' , Sys.Clz.fgB3, False) Sys.print('[' , Sys.CLZ_HELP_ARG, False)
Sys.print(' -p ' , Sys.Clz.fgB3, False) Sys.print(' -p ' , Sys.CLZ_HELP_ARG, False)
Sys.print('{' , Sys.Clz.fgB1, False) Sys.print('{' , Sys.CLZ_HELP_PARAM, False)
Sys.print('numParts' , Sys.Clz.fgB1, False) Sys.print('numParts' , Sys.CLZ_HELP_PARAM, False)
Sys.print('}' , Sys.Clz.fgB1, False) Sys.print('}' , Sys.CLZ_HELP_PARAM, False)
Sys.print(' -k ' , Sys.Clz.fgB3, False) Sys.print(' -k ' , Sys.CLZ_HELP_ARG, False)
Sys.print('{' , Sys.Clz.fgB1, False) Sys.print('{' , Sys.CLZ_HELP_PARAM, False)
Sys.print('keyFile' , Sys.Clz.fgB1, False) Sys.print('keyFile' , Sys.CLZ_HELP_PARAM, False)
Sys.print('}' , Sys.Clz.fgB1, False) Sys.print('}' , Sys.CLZ_HELP_PARAM, False)
Sys.print(' -o ' , Sys.Clz.fgB3, False) Sys.print(' -o ' , Sys.CLZ_HELP_ARG, False)
Sys.print('{' , Sys.Clz.fgB1, False) Sys.print('{' , Sys.CLZ_HELP_PARAM, False)
Sys.print('tarOutputFile' , Sys.Clz.fgB1, False) Sys.print('tarOutputFile' , Sys.CLZ_HELP_PARAM, False)
Sys.print('}' , Sys.Clz.fgB1, False) Sys.print('}' , Sys.CLZ_HELP_PARAM, False)
Sys.print(']' , Sys.Clz.fgB3) Sys.print(']' , Sys.CLZ_HELP_ARG)
Sys.print(' '+conf.PRG_CLI_NAME+' ' , Sys.Clz.fgb7, False) Sys.print(' '+conf.PRG_CLI_NAME+' ' , Sys.CLZ_HELP_PRG, False)
Sys.print('merge ' , Sys.Clz.fgB3, False) Sys.print('merge ' , Sys.CLZ_HELP_CMD, False)
Sys.print('{' , Sys.Clz.fgB1, False) Sys.print('{' , Sys.CLZ_HELP_PARAM, False)
Sys.print('inputFile' , Sys.Clz.fgB1, False) Sys.print('inputFile' , Sys.CLZ_HELP_PARAM, False)
Sys.print('} ' , Sys.Clz.fgB1, False) Sys.print('} ' , Sys.CLZ_HELP_PARAM, False)
Sys.print('[' , Sys.Clz.fgB3, False) Sys.print('[' , Sys.CLZ_HELP_ARG, False)
Sys.print(' -k ' , Sys.Clz.fgB3, False) Sys.print(' -k ' , Sys.CLZ_HELP_ARG, False)
Sys.print('{' , Sys.Clz.fgB1, False) Sys.print('{' , Sys.CLZ_HELP_PARAM, False)
Sys.print('keyFile' , Sys.Clz.fgB1, False) Sys.print('keyFile' , Sys.CLZ_HELP_PARAM, False)
Sys.print('}' , Sys.Clz.fgB1, False) Sys.print('}' , Sys.CLZ_HELP_PARAM, False)
Sys.print(' -o ' , Sys.Clz.fgB3, False) Sys.print(' -o ' , Sys.CLZ_HELP_ARG, False)
Sys.print('{' , Sys.Clz.fgB1, False) Sys.print('{' , Sys.CLZ_HELP_PARAM, False)
Sys.print('outputFile' , Sys.Clz.fgB1, False) Sys.print('outputFile' , Sys.CLZ_HELP_PARAM, False)
Sys.print('}' , Sys.Clz.fgB1, False) Sys.print('}' , Sys.CLZ_HELP_PARAM, False)
Sys.print(']' , Sys.Clz.fgB3) Sys.print(']' , Sys.CLZ_HELP_ARG)
def print_options(self): def print_options(self):
"""""" """"""
Sys.dprint('\n') Sys.dprint('\n')
printLineSep(LINE_SEP_CHAR,LINE_SEP_LEN) printLineSep(Const.LINE_SEP_CHAR,Const.LINE_SEP_LEN)
Sys.print(' MAIN OPTIONS :\n' , Sys.Clz.fgB3) Sys.print(' MAIN OPTIONS :\n' , Sys.CLZ_HELP_CMD)
Sys.print(' '*4+'-v'.ljust(13,' ')+', --version' , Sys.Clz.fgB3) Sys.print(' '*4+'-v'.ljust(13,' ')+', --version' , Sys.CLZ_HELP_ARG)
Sys.print(' '*50+'display programm version' , Sys.Clz.fgB7) Sys.print(' '*50+'display programm version' , Sys.CLZ_HELP_ARG_INFO)
Sys.print(' '*4+'-d'.ljust(13,' ')+', --debug' , Sys.Clz.fgB3) Sys.print(' '*4+'-d'.ljust(13,' ')+', --debug' , Sys.CLZ_HELP_ARG)
Sys.print(' '*50+'enable debug mode' , Sys.Clz.fgB7) Sys.print(' '*50+'enable debug mode' , Sys.CLZ_HELP_ARG_INFO)
Sys.print(' '*4+'-f'.ljust(13,' ')+', --force' , Sys.Clz.fgB3) Sys.print(' '*4+'-f'.ljust(13,' ')+', --force' , Sys.CLZ_HELP_ARG)
Sys.print(' '*50+'force rewriting existing files without alert' , Sys.Clz.fgB7) Sys.print(' '*50+'force rewriting existing files without alert' , Sys.CLZ_HELP_ARG_INFO)
Sys.print(' '*4+'-q'.ljust(13,' ')+', --quiet' , Sys.Clz.fgB3) Sys.print(' '*4+'-q'.ljust(13,' ')+', --quiet' , Sys.CLZ_HELP_ARG)
Sys.print(' '*50+'don\'t print status messages to stdout' , Sys.Clz.fgB7) Sys.print(' '*50+'don\'t print status messages to stdout' , Sys.CLZ_HELP_ARG_INFO)
Sys.print(' '*4+'-h'.ljust(13,' ')+', --help' , Sys.Clz.fgB3) Sys.print(' '*4+'-h'.ljust(13,' ')+', --help' , Sys.CLZ_HELP_ARG)
Sys.print(' '*50+'display help' , Sys.Clz.fgB7) Sys.print(' '*50+'display help' , Sys.CLZ_HELP_ARG_INFO)
Sys.dprint('\n') Sys.dprint('\n')
Sys.print(' KEY OPTIONS :\n' , Sys.Clz.fgB3) Sys.print(' KEY OPTIONS :\n' , Sys.CLZ_HELP_CMD)
Sys.print(' '*4+'-l ' , Sys.Clz.fgB3, False) Sys.print(' '*4+'-l ' , Sys.CLZ_HELP_ARG, False)
Sys.print('LENGTH'.ljust(10,' ') , Sys.Clz.fgB1, False) Sys.print('LENGTH'.ljust(10,' ') , Sys.CLZ_HELP_PARAM, False)
Sys.print(', --length'.ljust(18,' ') , Sys.Clz.fgB3, False) Sys.print(', --length'.ljust(18,' ') , Sys.CLZ_HELP_ARG, False)
Sys.print('LENGTH'.ljust(10,' ') , Sys.Clz.fgB1) Sys.print('LENGTH'.ljust(10,' ') , Sys.CLZ_HELP_PARAM)
Sys.print(' '*50+'specified key length (128 to 4096 - default:1024)' , Sys.Clz.fgB7) Sys.print(' '*50+'specified key length (128 to 4096 - default:1024)' , Sys.CLZ_HELP_ARG_INFO)
Sys.print(' '*4+'-o ' , Sys.Clz.fgB3, False) Sys.print(' '*4+'-o ' , Sys.CLZ_HELP_ARG, False)
Sys.print('FILE'.ljust(10,' ') , Sys.Clz.fgB1, False) Sys.print('FILE'.ljust(10,' ') , Sys.CLZ_HELP_PARAM, False)
Sys.print(', --outputfile'.ljust(18,' ') , Sys.Clz.fgB3, False) Sys.print(', --outputfile'.ljust(18,' ') , Sys.CLZ_HELP_ARG, False)
Sys.print('FILE'.ljust(10,' ') , Sys.Clz.fgB1) Sys.print('FILE'.ljust(10,' ') , Sys.CLZ_HELP_PARAM)
Sys.print(' '*50+'specified key output filename' , Sys.Clz.fgB7) Sys.print(' '*50+'specified key output filename' , Sys.CLZ_HELP_ARG_INFO)
Sys.dprint('\n') Sys.dprint('\n')
Sys.print(' ENCRYPT OPTIONS :\n' , Sys.Clz.fgB3) Sys.print(' ENCRYPT OPTIONS :\n' , Sys.CLZ_HELP_CMD)
Sys.print(' '*4+'-a'.ljust(13,' ')+', --fullcompress' , Sys.Clz.fgB3) Sys.print(' '*4+'-a'.ljust(13,' ')+', --fullcompress' , Sys.CLZ_HELP_ARG)
Sys.print(' '*50+'enable full compression mode' , Sys.Clz.fgB7) Sys.print(' '*50+'enable full compression mode' , Sys.CLZ_HELP_ARG_INFO)
Sys.print(' '*4+'-z'.ljust(13,' ')+', --compress' , Sys.Clz.fgB3) Sys.print(' '*4+'-z'.ljust(13,' ')+', --compress' , Sys.CLZ_HELP_ARG)
Sys.print(' '*50+'enable compression mode' , Sys.Clz.fgB7) Sys.print(' '*50+'enable compression mode' , Sys.CLZ_HELP_ARG_INFO)
Sys.print(' '*4+'-Z'.ljust(13,' ')+', --nocompress' , Sys.Clz.fgB3) Sys.print(' '*4+'-Z'.ljust(13,' ')+', --nocompress' , Sys.CLZ_HELP_ARG)
Sys.print(' '*50+'disable compression mode' , Sys.Clz.fgB7) Sys.print(' '*50+'disable compression mode' , Sys.CLZ_HELP_ARG_INFO)
Sys.print(' '*4+'-r'.ljust(13,' ')+', --random' , Sys.Clz.fgB3) Sys.print(' '*4+'-r'.ljust(13,' ')+', --random' , Sys.CLZ_HELP_ARG)
Sys.print(' '*50+'enable random mode' , Sys.Clz.fgB7) Sys.print(' '*50+'enable random mode' , Sys.CLZ_HELP_ARG_INFO)
Sys.print(' '*4+'-R'.ljust(13,' ')+', --norandom' , Sys.Clz.fgB3) Sys.print(' '*4+'-R'.ljust(13,' ')+', --norandom' , Sys.CLZ_HELP_ARG)
Sys.print(' '*50+'disable random mode' , Sys.Clz.fgB7) Sys.print(' '*50+'disable random mode' , Sys.CLZ_HELP_ARG_INFO)
Sys.print(' '*4+'-m'.ljust(13,' ')+', --mix' , Sys.Clz.fgB3) Sys.print(' '*4+'-m'.ljust(13,' ')+', --mix' , Sys.CLZ_HELP_ARG)
Sys.print(' '*50+'enable mix mode' , Sys.Clz.fgB7) Sys.print(' '*50+'enable mix mode' , Sys.CLZ_HELP_ARG_INFO)
Sys.print(' '*4+'-M'.ljust(13,' ')+', --nomix' , Sys.Clz.fgB3) Sys.print(' '*4+'-M'.ljust(13,' ')+', --nomix' , Sys.CLZ_HELP_ARG)
Sys.print(' '*50+'disable mix mode' , Sys.Clz.fgB7) Sys.print(' '*50+'disable mix mode' , Sys.CLZ_HELP_ARG_INFO)
Sys.print(' '*4+'-j ' , Sys.Clz.fgB3, False) Sys.print(' '*4+'-j ' , Sys.CLZ_HELP_ARG, False)
Sys.print('COUNT'.ljust(10,' ') , Sys.Clz.fgB1, False) Sys.print('COUNT'.ljust(10,' ') , Sys.CLZ_HELP_PARAM, False)
Sys.print(', --multiprocess'.ljust(18,' ') , Sys.Clz.fgB3, False) Sys.print(', --multiprocess'.ljust(18,' ') , Sys.CLZ_HELP_ARG, False)
Sys.print('COUNT'.ljust(10,' ') , Sys.Clz.fgB1) Sys.print('COUNT'.ljust(10,' ') , Sys.CLZ_HELP_PARAM)
Sys.print(' '*50+'number of process for encryption (2 to 8)' , Sys.Clz.fgB7) Sys.print(' '*50+'number of process for encryption (2 to 8)' , Sys.CLZ_HELP_ARG_INFO)
Sys.print(' '*4+'-k ' , Sys.Clz.fgB3, False) Sys.print(' '*4+'-k ' , Sys.CLZ_HELP_ARG, False)
Sys.print('FILE'.ljust(10,' ') , Sys.Clz.fgB1, False) Sys.print('FILE'.ljust(10,' ') , Sys.CLZ_HELP_PARAM, False)
Sys.print(', --keyfile'.ljust(18,' ') , Sys.Clz.fgB3, False) Sys.print(', --keyfile'.ljust(18,' ') , Sys.CLZ_HELP_ARG, False)
Sys.print('FILE'.ljust(10,' ') , Sys.Clz.fgB1) Sys.print('FILE'.ljust(10,' ') , Sys.CLZ_HELP_PARAM)
Sys.print(' '*50+'key filename used to encrypt' , Sys.Clz.fgB7) Sys.print(' '*50+'key filename used to encrypt' , Sys.CLZ_HELP_ARG_INFO)
Sys.print(' '*4+'-o ' , Sys.Clz.fgB3, False) Sys.print(' '*4+'-o ' , Sys.CLZ_HELP_ARG, False)
Sys.print('FILE'.ljust(10,' ') , Sys.Clz.fgB1, False) Sys.print('FILE'.ljust(10,' ') , Sys.CLZ_HELP_PARAM, False)
Sys.print(', --outputfile'.ljust(18,' ') , Sys.Clz.fgB3, False) Sys.print(', --outputfile'.ljust(18,' ') , Sys.CLZ_HELP_ARG, False)
Sys.print('FILE'.ljust(10,' ') , Sys.Clz.fgB1) Sys.print('FILE'.ljust(10,' ') , Sys.CLZ_HELP_PARAM)
Sys.print(' '*50+'specified encrypted output filename' , Sys.Clz.fgB7) Sys.print(' '*50+'specified encrypted output filename' , Sys.CLZ_HELP_ARG_INFO)
Sys.dprint('\n') Sys.dprint('\n')
Sys.print(' DECRYPT OPTIONS :\n' , Sys.Clz.fgB3) Sys.print(' DECRYPT OPTIONS :\n' , Sys.CLZ_HELP_CMD)
Sys.print(' '*4+'-j ' , Sys.Clz.fgB3, False) Sys.print(' '*4+'-j ' , Sys.CLZ_HELP_ARG, False)
Sys.print('COUNT'.ljust(10,' ') , Sys.Clz.fgB1, False) Sys.print('COUNT'.ljust(10,' ') , Sys.CLZ_HELP_PARAM, False)
Sys.print(', --multiprocess'.ljust(18,' ') , Sys.Clz.fgB3, False) Sys.print(', --multiprocess'.ljust(18,' ') , Sys.CLZ_HELP_ARG, False)
Sys.print('COUNT'.ljust(10,' ') , Sys.Clz.fgB1) Sys.print('COUNT'.ljust(10,' ') , Sys.CLZ_HELP_PARAM)
Sys.print(' '*50+'number of process for decryption (2 to 8)' , Sys.Clz.fgB7) Sys.print(' '*50+'number of process for decryption (2 to 8)' , Sys.CLZ_HELP_ARG_INFO)
Sys.print(' '*4+'-k ' , Sys.Clz.fgB3, False) Sys.print(' '*4+'-k ' , Sys.CLZ_HELP_ARG, False)
Sys.print('FILE'.ljust(10,' ') , Sys.Clz.fgB1, False) Sys.print('FILE'.ljust(10,' ') , Sys.CLZ_HELP_PARAM, False)
Sys.print(', --keyfile'.ljust(18,' ') , Sys.Clz.fgB3, False) Sys.print(', --keyfile'.ljust(18,' ') , Sys.CLZ_HELP_ARG, False)
Sys.print('FILE'.ljust(10,' ') , Sys.Clz.fgB1) Sys.print('FILE'.ljust(10,' ') , Sys.CLZ_HELP_PARAM)
Sys.print(' '*50+'key filename used to decrypt' , Sys.Clz.fgB7) Sys.print(' '*50+'key filename used to decrypt' , Sys.CLZ_HELP_ARG_INFO)
Sys.print(' '*4+'-o ' , Sys.Clz.fgB3, False) Sys.print(' '*4+'-o ' , Sys.CLZ_HELP_ARG, False)
Sys.print('FILE'.ljust(10,' ') , Sys.Clz.fgB1, False) Sys.print('FILE'.ljust(10,' ') , Sys.CLZ_HELP_PARAM, False)
Sys.print(', --outputfile'.ljust(18,' ') , Sys.Clz.fgB3, False) Sys.print(', --outputfile'.ljust(18,' ') , Sys.CLZ_HELP_ARG, False)
Sys.print('FILE'.ljust(10,' ') , Sys.Clz.fgB1) Sys.print('FILE'.ljust(10,' ') , Sys.CLZ_HELP_PARAM)
Sys.print(' '*50+'specified decrypted output filename' , Sys.Clz.fgB7) Sys.print(' '*50+'specified decrypted output filename' , Sys.CLZ_HELP_ARG_INFO)
Sys.dprint('\n') Sys.dprint('\n')
Sys.print(' SPLIT OPTIONS :\n' , Sys.Clz.fgB3) Sys.print(' SPLIT OPTIONS :\n' , Sys.CLZ_HELP_CMD)
Sys.print(' '*4+'-p ' , Sys.Clz.fgB3, False) Sys.print(' '*4+'-p ' , Sys.CLZ_HELP_ARG, False)
Sys.print('COUNT'.ljust(10,' ') , Sys.Clz.fgB1, False) Sys.print('COUNT'.ljust(10,' ') , Sys.CLZ_HELP_PARAM, False)
Sys.print(', --part'.ljust(18,' ') , Sys.Clz.fgB3, False) Sys.print(', --part'.ljust(18,' ') , Sys.CLZ_HELP_ARG, False)
Sys.print('COUNT'.ljust(10,' ') , Sys.Clz.fgB1) Sys.print('COUNT'.ljust(10,' ') , Sys.CLZ_HELP_PARAM)
Sys.print(' '*50+'count part to split' , Sys.Clz.fgB7) Sys.print(' '*50+'count part to split' , Sys.CLZ_HELP_ARG_INFO)
Sys.print(' '*4+'-k ' , Sys.Clz.fgB3, False) Sys.print(' '*4+'-k ' , Sys.CLZ_HELP_ARG, False)
Sys.print('FILE'.ljust(10,' ') , Sys.Clz.fgB1, False) Sys.print('FILE'.ljust(10,' ') , Sys.CLZ_HELP_PARAM, False)
Sys.print(', --keyfile'.ljust(18,' ') , Sys.Clz.fgB3, False) Sys.print(', --keyfile'.ljust(18,' ') , Sys.CLZ_HELP_ARG, False)
Sys.print('FILE'.ljust(10,' ') , Sys.Clz.fgB1) Sys.print('FILE'.ljust(10,' ') , Sys.CLZ_HELP_PARAM)
Sys.print(' '*50+'key filename used to split' , Sys.Clz.fgB7) Sys.print(' '*50+'key filename used to split' , Sys.CLZ_HELP_ARG_INFO)
Sys.print(' '*4+'-o ' , Sys.Clz.fgB3, False) Sys.print(' '*4+'-o ' , Sys.CLZ_HELP_ARG, False)
Sys.print('TARFILE'.ljust(10,' ') , Sys.Clz.fgB1, False) Sys.print('TARFILE'.ljust(10,' ') , Sys.CLZ_HELP_PARAM, False)
Sys.print(', --outputfile'.ljust(18,' ') , Sys.Clz.fgB3, False) Sys.print(', --outputfile'.ljust(18,' ') , Sys.CLZ_HELP_ARG, False)
Sys.print('TARFILE'.ljust(10,' ') , Sys.Clz.fgB1) Sys.print('TARFILE'.ljust(10,' ') , Sys.CLZ_HELP_PARAM)
Sys.print(' '*50+'specified tar output filename' , Sys.Clz.fgB7) Sys.print(' '*50+'specified tar output filename' , Sys.CLZ_HELP_ARG_INFO)
Sys.dprint('\n') Sys.dprint('\n')
Sys.print(' MERGE OPTIONS :\n' , Sys.Clz.fgB3) Sys.print(' MERGE OPTIONS :\n' , Sys.CLZ_HELP_CMD)
Sys.print(' '*4+'-k ' , Sys.Clz.fgB3, False) Sys.print(' '*4+'-k ' , Sys.CLZ_HELP_ARG, False)
Sys.print('FILE'.ljust(10,' ') , Sys.Clz.fgB1, False) Sys.print('FILE'.ljust(10,' ') , Sys.CLZ_HELP_PARAM, False)
Sys.print(', --keyfile'.ljust(18,' ') , Sys.Clz.fgB3, False) Sys.print(', --keyfile'.ljust(18,' ') , Sys.CLZ_HELP_ARG, False)
Sys.print('FILE'.ljust(10,' ') , Sys.Clz.fgB1) Sys.print('FILE'.ljust(10,' ') , Sys.CLZ_HELP_PARAM)
Sys.print(' '*50+'key filename used to merge' , Sys.Clz.fgB7) Sys.print(' '*50+'key filename used to merge' , Sys.CLZ_HELP_ARG_INFO)
Sys.print(' '*4+'-o ' , Sys.Clz.fgB3, False) Sys.print(' '*4+'-o ' , Sys.CLZ_HELP_ARG, False)
Sys.print('FILE'.ljust(10,' ') , Sys.Clz.fgB1, False) Sys.print('FILE'.ljust(10,' ') , Sys.CLZ_HELP_PARAM, False)
Sys.print(', --outputfile'.ljust(18,' ') , Sys.Clz.fgB3, False) Sys.print(', --outputfile'.ljust(18,' ') , Sys.CLZ_HELP_ARG, False)
Sys.print('FILE'.ljust(10,' ') , Sys.Clz.fgB1) Sys.print('FILE'.ljust(10,' ') , Sys.CLZ_HELP_PARAM)
Sys.print(' '*50+'specified decrypted output filename' , Sys.Clz.fgB7) Sys.print(' '*50+'specified decrypted output filename' , Sys.CLZ_HELP_ARG_INFO)
Sys.dprint('\n') Sys.dprint('\n')
def print_help(self): def print_help(self):
"""""" """"""
self.print_header() self.print_header()
Sys.print(conf.PRG_DESC, Sys.Clz.fgN1) Sys.print(conf.PRG_DESC, Sys.CLZ_HELP_DESC)
self.print_usage('',True) self.print_usage('',True)
self.print_options() self.print_options()
printLineSep(LINE_SEP_CHAR,LINE_SEP_LEN) printLineSep(Const.LINE_SEP_CHAR,Const.LINE_SEP_LEN)
Sys.dprint() Sys.dprint()
Sys.print(' EXEMPLES :\n', Sys.Clz.fgB3) Sys.print(' EXEMPLES :\n', Sys.CLZ_HELP_CMD)
CHQ = "'" CHQ = "'"
Sys.print(' '*4+'command key :', Sys.Clz.fgB3) Sys.print(' '*4+'command key :', Sys.CLZ_HELP_CMD)
Sys.print(' '*8+'# generate a new crypted key of 2048 length', Sys.Clz.fgn7) Sys.print(' '*8+'# generate a new crypted key of 2048 length', Sys.CLZ_HELP_COMMENT)
Sys.print(' '*8+conf.PRG_CLI_NAME+' ', Sys.Clz.fgB7, False) Sys.print(' '*8+conf.PRG_CLI_NAME+' ', Sys.CLZ_HELP_PRG, False)
Sys.print('key -l ', Sys.Clz.fgB3, False) Sys.print('key -l ', Sys.CLZ_HELP_CMD, False)
Sys.print('2048 ', Sys.Clz.fgB1) Sys.print('2048 ', Sys.CLZ_HELP_PARAM)
Sys.print(' '*8+'# generate a new crypted key (default length is 1024) in a specified location', Sys.Clz.fgn7) Sys.print(' '*8+'# generate a new crypted key (default length is 1024) in a specified location', Sys.CLZ_HELP_COMMENT)
Sys.print(' '*8+conf.PRG_CLI_NAME+' ', Sys.Clz.fgB7, False) Sys.print(' '*8+conf.PRG_CLI_NAME+' ', Sys.CLZ_HELP_PRG, False)
Sys.print('key -o ', Sys.Clz.fgB3, False) Sys.print('key -o ', Sys.CLZ_HELP_CMD, False)
Sys.print(self.DIRKEY+'.myNewKey', Sys.Clz.fgB1) Sys.print(self.DIRKEY+'.myNewKey', Sys.CLZ_HELP_PARAM)
printLineSep(LINE_SEP_CHAR,LINE_SEP_LEN) printLineSep(Const.LINE_SEP_CHAR,Const.LINE_SEP_LEN)
Sys.print('\n'+' '*4+'command encrypt :', Sys.Clz.fgB3) Sys.print('\n'+' '*4+'command encrypt :', Sys.CLZ_HELP_CMD)
Sys.print(' '*8+'# encrypt specified file with default crypted key and default options', Sys.Clz.fgn7) Sys.print(' '*8+'# encrypt specified file with default crypted key and default options', Sys.CLZ_HELP_COMMENT)
Sys.print(' '*8+conf.PRG_CLI_NAME+' ', Sys.Clz.fgB7, False) Sys.print(' '*8+conf.PRG_CLI_NAME+' ', Sys.CLZ_HELP_PRG, False)
Sys.print('enc ', Sys.Clz.fgB3, False) Sys.print('enc ', Sys.CLZ_HELP_CMD, False)
Sys.print(self.HOME+'mySecretTextFile.txt', Sys.Clz.fgB1) Sys.print(self.HOME+'mySecretTextFile.txt', Sys.CLZ_HELP_PARAM)
Sys.print(' '*8+'# encrypt specified file with specified crypted key (full compression, no random but mix mode)', Sys.Clz.fgn7) Sys.print(' '*8+'# encrypt specified file with specified crypted key (full compression, no random but mix mode)', Sys.CLZ_HELP_COMMENT)
Sys.print(' '*8+'# on specified output location', Sys.Clz.fgn7) Sys.print(' '*8+'# on specified output location', Sys.CLZ_HELP_COMMENT)
Sys.print(' '*8+conf.PRG_CLI_NAME+' ', Sys.Clz.fgB7, False) Sys.print(' '*8+conf.PRG_CLI_NAME+' ', Sys.CLZ_HELP_PRG, False)
Sys.print('enc ', Sys.Clz.fgB3, False) Sys.print('enc ', Sys.CLZ_HELP_CMD, False)
Sys.print('mySecretTextFile.txt', Sys.Clz.fgB1, False) Sys.print('mySecretTextFile.txt', Sys.CLZ_HELP_PARAM, False)
Sys.print(' -aRm -k ' , Sys.Clz.fgB3, False) Sys.print(' -aRm -k ' , Sys.CLZ_HELP_ARG, False)
Sys.print(self.DIRKEY+'.myNewKey', Sys.Clz.fgB1, False) Sys.print(self.DIRKEY+'.myNewKey', Sys.CLZ_HELP_PARAM, False)
Sys.print(' -o ' , Sys.Clz.fgB3, False) Sys.print(' -o ' , Sys.CLZ_HELP_ARG, False)
Sys.print('test.kmh', Sys.Clz.fgB1) Sys.print('test.kmh', Sys.CLZ_HELP_PARAM)
Sys.print(' '*8+'# encrypt specified file with default crypted key (no compression but random & mix mode and multiprocessing)', Sys.Clz.fgn7) Sys.print(' '*8+'# encrypt specified file with default crypted key (no compression but random & mix mode and multiprocessing)', Sys.CLZ_HELP_COMMENT)
Sys.print(' '*8+conf.PRG_CLI_NAME+' ', Sys.Clz.fgB7, False) Sys.print(' '*8+conf.PRG_CLI_NAME+' ', Sys.CLZ_HELP_PRG, False)
Sys.print('enc ', Sys.Clz.fgB3, False) Sys.print('enc ', Sys.CLZ_HELP_CMD, False)
Sys.print('myBigTextFile.txt', Sys.Clz.fgB1, False) Sys.print('myBigTextFile.txt', Sys.CLZ_HELP_PARAM, False)
Sys.print(' -Zrm -j ' , Sys.Clz.fgB3, False) Sys.print(' -Zrm -j ' , Sys.CLZ_HELP_ARG, False)
Sys.print('4', Sys.Clz.fgB1) Sys.print('4', Sys.CLZ_HELP_PARAM)
printLineSep(LINE_SEP_CHAR,LINE_SEP_LEN) printLineSep(Const.LINE_SEP_CHAR,Const.LINE_SEP_LEN)
Sys.print('\n'+' '*4+'command decrypt :', Sys.Clz.fgB3) Sys.print('\n'+' '*4+'command decrypt :', Sys.CLZ_HELP_CMD)
Sys.print(' '*8+'# decrypt specified file with default crypted key', Sys.Clz.fgn7) Sys.print(' '*8+'# decrypt specified file with default crypted key', Sys.CLZ_HELP_COMMENT)
Sys.print(' '*8+conf.PRG_CLI_NAME+' ', Sys.Clz.fgB7, False) Sys.print(' '*8+conf.PRG_CLI_NAME+' ', Sys.CLZ_HELP_PRG, False)
Sys.print('dec ', Sys.Clz.fgB3, False) Sys.print('dec ', Sys.CLZ_HELP_CMD, False)
Sys.print(self.HOME+'mySecretFile.kmh', Sys.Clz.fgB1) Sys.print(self.HOME+'mySecretFile.kmh', Sys.CLZ_HELP_PARAM)
Sys.print(' '*8+'# decrypt specified file with specified crypted key on specified output location', Sys.Clz.fgn7) Sys.print(' '*8+'# decrypt specified file with specified crypted key on specified output location', Sys.CLZ_HELP_COMMENT)
Sys.print(' '*8+conf.PRG_CLI_NAME+' ', Sys.Clz.fgB7, False) Sys.print(' '*8+conf.PRG_CLI_NAME+' ', Sys.CLZ_HELP_PRG, False)
Sys.print('dec ', Sys.Clz.fgB3, False) Sys.print('dec ', Sys.CLZ_HELP_CMD, False)
Sys.print('myEncryptedSecretFile.kmh', Sys.Clz.fgB1, False) Sys.print('myEncryptedSecretFile.kmh', Sys.CLZ_HELP_PARAM, False)
Sys.print(' -k ' , Sys.Clz.fgB3, False) Sys.print(' -k ' , Sys.CLZ_HELP_ARG, False)
Sys.print(self.HOME+'.kirmah'+Sys.sep+'.myNewKey', Sys.Clz.fgB1, False) Sys.print(self.HOME+'.kirmah'+Sys.sep+'.myNewKey', Sys.CLZ_HELP_PARAM, False)
Sys.print(' -o ' , Sys.Clz.fgB3, False) Sys.print(' -o ' , Sys.CLZ_HELP_ARG, False)
Sys.print('myDecryptedSecretFile.txt', Sys.Clz.fgB1) Sys.print('myDecryptedSecretFile.txt', Sys.CLZ_HELP_PARAM)
Sys.print(' '*8+'# decrypt specified file with default crypted key and multiprocessing', Sys.Clz.fgn7) Sys.print(' '*8+'# decrypt specified file with default crypted key and multiprocessing', Sys.CLZ_HELP_COMMENT)
Sys.print(' '*8+conf.PRG_CLI_NAME+' ', Sys.Clz.fgB7, False) Sys.print(' '*8+conf.PRG_CLI_NAME+' ', Sys.CLZ_HELP_PRG, False)
Sys.print('dec ', Sys.Clz.fgB3, False) Sys.print('dec ', Sys.CLZ_HELP_CMD, False)
Sys.print('myEncryptedSecretFile.kmh', Sys.Clz.fgB1, False) Sys.print('myEncryptedSecretFile.kmh', Sys.CLZ_HELP_PARAM, False)
Sys.print(' -j ' , Sys.Clz.fgB3, False) Sys.print(' -j ' , Sys.CLZ_HELP_ARG, False)
Sys.print('4' , Sys.Clz.fgB1) Sys.print('4' , Sys.CLZ_HELP_PARAM)
printLineSep(LINE_SEP_CHAR,LINE_SEP_LEN) printLineSep(Const.LINE_SEP_CHAR,Const.LINE_SEP_LEN)
Sys.print('\n'+' '*4+'command split :', Sys.Clz.fgB3) Sys.print('\n'+' '*4+'command split :', Sys.CLZ_HELP_CMD)
Sys.print(' '*8+'# split specified file with default crypted key', Sys.Clz.fgn7) Sys.print(' '*8+'# split specified file with default crypted key', Sys.CLZ_HELP_COMMENT)
Sys.print(' '*8+conf.PRG_CLI_NAME+' ', Sys.Clz.fgB7, False) Sys.print(' '*8+conf.PRG_CLI_NAME+' ', Sys.CLZ_HELP_PRG, False)
Sys.print('split ', Sys.Clz.fgB3, False) Sys.print('split ', Sys.CLZ_HELP_CMD, False)
Sys.print(self.HOME+'myBigBinaryFile.avi', Sys.Clz.fgB1) Sys.print(self.HOME+'myBigBinaryFile.avi', Sys.CLZ_HELP_PARAM)
Sys.print(' '*8+'# split specified file on 55 parts with specified crypted key on specified output location', Sys.Clz.fgn7) Sys.print(' '*8+'# split specified file on 55 parts with specified crypted key on specified output location', Sys.CLZ_HELP_COMMENT)
Sys.print(' '*8+conf.PRG_CLI_NAME+' ', Sys.Clz.fgB7, False) Sys.print(' '*8+conf.PRG_CLI_NAME+' ', Sys.CLZ_HELP_PRG, False)
Sys.print('split ', Sys.Clz.fgB3, False) Sys.print('split ', Sys.CLZ_HELP_CMD, False)
Sys.print('myBigBinaryFile.avi', Sys.Clz.fgB1, False) Sys.print('myBigBinaryFile.avi', Sys.CLZ_HELP_PARAM, False)
Sys.print(' -p ' , Sys.Clz.fgB3, False) Sys.print(' -p ' , Sys.CLZ_HELP_ARG, False)
Sys.print('55' , Sys.Clz.fgB1, False) Sys.print('55' , Sys.CLZ_HELP_PARAM, False)
Sys.print(' -k ' , Sys.Clz.fgB3, False) Sys.print(' -k ' , Sys.CLZ_HELP_ARG, False)
Sys.print(self.DIRKEY+'.myNewKey', Sys.Clz.fgB1, False) Sys.print(self.DIRKEY+'.myNewKey', Sys.CLZ_HELP_PARAM, False)
Sys.print(' -o ' , Sys.Clz.fgB3, False) Sys.print(' -o ' , Sys.CLZ_HELP_ARG, False)
Sys.print('myBigBinaryFile.encrypted', Sys.Clz.fgB1) Sys.print('myBigBinaryFile.encrypted', Sys.CLZ_HELP_PARAM)
printLineSep(LINE_SEP_CHAR,LINE_SEP_LEN) printLineSep(Const.LINE_SEP_CHAR,Const.LINE_SEP_LEN)
Sys.print('\n'+' '*4+'command merge :', Sys.Clz.fgB3) Sys.print('\n'+' '*4+'command merge :', Sys.CLZ_HELP_CMD)
Sys.print(' '*8+'# merge specified splitted file with default crypted key', Sys.Clz.fgn7) Sys.print(' '*8+'# merge specified splitted file with default crypted key', Sys.CLZ_HELP_COMMENT)
Sys.print(' '*8+conf.PRG_CLI_NAME+' ', Sys.Clz.fgB7, False) Sys.print(' '*8+conf.PRG_CLI_NAME+' ', Sys.CLZ_HELP_PRG, False)
Sys.print('merge ', Sys.Clz.fgB3, False) Sys.print('merge ', Sys.CLZ_HELP_CMD, False)
Sys.print(self.HOME+'6136bd1b53d84ecbad5380594eea7256176c19e0266c723ea2e982f8ca49922b.kcf', Sys.Clz.fgB1) Sys.print(self.HOME+'6136bd1b53d84ecbad5380594eea7256176c19e0266c723ea2e982f8ca49922b.kcf', Sys.CLZ_HELP_PARAM)
Sys.print(' '*8+'# merge specified tark splitted file with specified crypted key on specified output location', Sys.Clz.fgn7) Sys.print(' '*8+'# merge specified tark splitted file with specified crypted key on specified output location', Sys.CLZ_HELP_COMMENT)
Sys.print(' '*8+conf.PRG_CLI_NAME+' ', Sys.Clz.fgB7, False) Sys.print(' '*8+conf.PRG_CLI_NAME+' ', Sys.CLZ_HELP_PRG, False)
Sys.print('merge ', Sys.Clz.fgB3, False) Sys.print('merge ', Sys.CLZ_HELP_CMD, False)
Sys.print('myBigBinaryFile.encrypted.tark', Sys.Clz.fgB1, False) Sys.print('myBigBinaryFile.encrypted.tark', Sys.CLZ_HELP_PARAM, False)
Sys.print(' -k ' , Sys.Clz.fgB3, False) Sys.print(' -k ' , Sys.CLZ_HELP_ARG, False)
Sys.print(self.DIRKEY+'.myNewKey', Sys.Clz.fgB1, False) Sys.print(self.DIRKEY+'.myNewKey', Sys.CLZ_HELP_PARAM, False)
Sys.print(' -o ' , Sys.Clz.fgB3, False) Sys.print(' -o ' , Sys.CLZ_HELP_ARG, False)
Sys.print('myBigBinaryFile.decrypted.avi', Sys.Clz.fgB1) Sys.print('myBigBinaryFile.decrypted.avi', Sys.CLZ_HELP_PARAM)
printLineSep(LINE_SEP_CHAR,LINE_SEP_LEN) printLineSep(Const.LINE_SEP_CHAR,Const.LINE_SEP_LEN)
Sys.dprint() Sys.dprint()

View File

@ -1,46 +1,48 @@
#!/usr/bin/env python # !/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # kirmah/cliapp.py
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# software : Kirmah <http://kirmah.sourceforge.net/> #
# version : 2.1 #
# date : 2013 #
# licence : GPLv3.0 <http://www.gnu.org/licenses/> #
# author : a-Sansara <http://www.a-sansara.net/> #
# copyright : pluie.org <http://www.pluie.org/> #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# This file is part of Kirmah. # software : Kirmah <http://kirmah.sourceforge.net/>
# version : 2.17
# date : 2013
# licence : GPLv3.0 <http://www.gnu.org/licenses/>
# author : a-Sansara <[a-sansara]at[clochardprod]dot[net]>
# copyright : pluie.org <http://www.pluie.org/>
# #
# Kirmah is free software (free as in speech) : you can redistribute it # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of the License,
# or (at your option) any later version.
# #
# Kirmah is distributed in the hope that it will be useful, but WITHOUT # This file is part of Kirmah.
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # Kirmah is free software (free as in speech) : you can redistribute it
# more details. # and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of the License,
# or (at your option) any later version.
#
# Kirmah is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License
# along with Kirmah. If not, see <http://www.gnu.org/licenses/>.
# #
# You should have received a copy of the GNU General Public License
# along with Kirmah. If not, see <http://www.gnu.org/licenses/>.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~ package cliapp ~~ # ~~ module cliapp ~~
import kirmah.conf as conf import kirmah.conf as conf
from kirmah.crypt import KirmahHeader, Kirmah, BadKeyException, represents_int, KeyGen from kirmah.crypt import KirmahHeader, Kirmah, BadKeyException, represents_int, KeyGen
from kirmah.kctrl import KCtrl from psr.sys import Sys, Const, Io
from psr.sys import Sys from psr.log import Log
from psr.io import Io import tarfile
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~ class CliApp ~~ # ~~ class CliApp ~~
class CliApp: class CliApp:
@Log(Const.LOG_BUILD)
def __init__(self, home, path, parser, a, o): def __init__(self, home, path, parser, a, o):
"""""" """"""
self.parser = parser self.parser = parser
@ -52,6 +54,7 @@ class CliApp:
self.o.keyfile = self.home+'.kirmah'+Sys.sep+'.default.key' self.o.keyfile = self.home+'.kirmah'+Sys.sep+'.default.key'
@Log(Const.LOG_DEBUG)
def onCommandKey(self): def onCommandKey(self):
"""""" """"""
if int(self.o.length) >= 128 and int(self.o.length) <= 4096 : if int(self.o.length) >= 128 and int(self.o.length) <= 4096 :
@ -77,11 +80,16 @@ class CliApp:
self.parser.error_cmd((('invalid option ',('-l, --length', Sys.Clz.fgb3), ' value (', ('128',Sys.Clz.fgb3),' to ', ('4096',Sys.Clz.fgb3),')'),)) self.parser.error_cmd((('invalid option ',('-l, --length', Sys.Clz.fgb3), ' value (', ('128',Sys.Clz.fgb3),' to ', ('4096',Sys.Clz.fgb3),')'),))
@Log(Const.LOG_DEBUG)
def onCommandEnc(self): def onCommandEnc(self):
"""""" """"""
done = True done = True
if self.o.outputfile is None : if self.o.outputfile is None :
self.o.outputfile = Sys.basename(self.a[1])+Kirmah.EXT self.o.outputfile = Sys.basename(self.a[1])
if self.o.outputfile[-len(Kirmah.EXT):] != Kirmah.EXT :
print(self.o.outputfile[-len(Kirmah.EXT):])
self.o.outputfile += Kirmah.EXT
print(self.o.outputfile)
d = self.getDefaultOption((self.o.compress,self.o.fullcompress,self.o.nocompress)) d = self.getDefaultOption((self.o.compress,self.o.fullcompress,self.o.nocompress))
compress = (KirmahHeader.COMP_END if d == 0 or (d is None and Io.is_binary(self.a[1])) else (KirmahHeader.COMP_ALL if d==1 or d is None else KirmahHeader.COMP_NONE)) compress = (KirmahHeader.COMP_END if d == 0 or (d is None and Io.is_binary(self.a[1])) else (KirmahHeader.COMP_ALL if d==1 or d is None else KirmahHeader.COMP_NONE))
@ -93,7 +101,7 @@ class CliApp:
nproc = int(self.o.multiprocess) if not self.o.multiprocess is None and int(self.o.multiprocess)>=2 and int(self.o.multiprocess) <=8 else 1 nproc = int(self.o.multiprocess) if not self.o.multiprocess is None and int(self.o.multiprocess)>=2 and int(self.o.multiprocess) <=8 else 1
if not self.o.quiet : self.parser.print_header() if not Sys.g.QUIET : self.parser.print_header()
if Io.file_exists(self.o.outputfile) and not self.o.force: if Io.file_exists(self.o.outputfile) and not self.o.force:
Sys.pwarn((('the file ',(self.o.outputfile, Sys.Clz.fgb3), ' already exists !'),)) Sys.pwarn((('the file ',(self.o.outputfile, Sys.Clz.fgb3), ' already exists !'),))
@ -103,42 +111,30 @@ class CliApp:
if done : if done :
try : try :
if not self.o.quiet and not Sys.g.DEBUG : Sys.print(' Processing, please wait...\n', Sys.Clz.fgB2) Sys.ptask()
key = Io.get_data(self.o.keyfile) key = Io.get_data(self.o.keyfile)
km = Kirmah(key, None, compress, random, mix) km = Kirmah(key, None, compress, random, mix)
if nproc > 1 : km.encrypt(self.a[1], self.o.outputfile, nproc)
from gi.repository.Gdk import threads_enter, threads_leave
from gi.repository.GLib import threads_init
from gi.repository.Gtk import main as gtk_main, main_quit as gtk_quit
threads_init()
threads_enter()
kctrl = KCtrl(nproc, None)
kctrl.encrypt(self.a[1], self.o.outputfile, km, None, self.onend_mproc)
gtk_main()
threads_leave()
else :
km.encrypt(self.a[1],self.o.outputfile)
except Exception as e : except Exception as e :
done = False done = False
print(e) print(e)
pass pass
if not self.o.quiet : if not Sys.g.QUIET :
self.onend_cmd('Encrypting file', self.stime, done, self.o.outputfile) self.onend_cmd('Encrypting file', self.stime, done, self.o.outputfile)
@Log(Const.LOG_DEBUG)
def onCommandDec(self): def onCommandDec(self):
"""""" """"""
done = True done = True
if self.o.outputfile is None : if self.o.outputfile is None :
self.o.outputfile = self.a[1][:-4] if self.a[1][-4:] == Kirmah.EXT else self.a[1] self.o.outputfile = self.a[1][:-4] if self.a[1][-4:] == Kirmah.EXT else self.a[1]
if not self.o.quiet : self.parser.print_header() if not Sys.g.QUIET : self.parser.print_header()
if Io.file_exists(self.o.outputfile) and not self.o.force: if Io.file_exists(self.o.outputfile) and not self.o.force:
Sys.pwarn((('the file ',(self.o.outputfile, Sys.Clz.fgb3), ' already exists !'),)) Sys.pwarn((('the file ',(self.o.outputfile, Sys.Clz.fgb3), ' already exists !'),))
@ -154,25 +150,12 @@ class CliApp:
nproc = int(self.o.multiprocess) if not self.o.multiprocess is None and int(self.o.multiprocess)>=2 and int(self.o.multiprocess) <=8 else 1 nproc = int(self.o.multiprocess) if not self.o.multiprocess is None and int(self.o.multiprocess)>=2 and int(self.o.multiprocess) <=8 else 1
if not self.o.quiet and not Sys.g.DEBUG : Sys.print(' Processing, please wait...\n', Sys.Clz.fgB2) Sys.ptask()
key = Io.get_data(self.o.keyfile) key = Io.get_data(self.o.keyfile)
km = Kirmah(key) km = Kirmah(key)
if nproc > 1 : km.decrypt(self.a[1], self.o.outputfile, nproc)
from gi.repository.Gdk import threads_enter, threads_leave
from gi.repository.GLib import threads_init
from gi.repository.Gtk import main as gtk_main, main_quit as gtk_quit
threads_init()
threads_enter()
kctrl = KCtrl(nproc, None)
kctrl.decrypt(self.a[1], self.o.outputfile, km, self.onend_mproc)
gtk_main()
threads_leave()
else :
km.decrypt(self.a[1],self.o.outputfile)
except BadKeyException as e : except BadKeyException as e :
done = False done = False
@ -180,20 +163,20 @@ class CliApp:
if Sys.g.DEBUG : if Sys.g.DEBUG :
raise e raise e
if not self.o.quiet : if not Sys.g.QUIET :
self.onend_cmd('Decrypting file', self.stime, done, self.o.outputfile) self.onend_cmd('Decrypting file', self.stime, done, self.o.outputfile)
@Log(Const.LOG_DEBUG)
def onCommandSplit(self): def onCommandSplit(self):
"""""" """"""
done = True done = True
Sys.cli_emit_progress(1)
if not self.o.parts is None and not(int(self.o.parts)>=12 and int(self.o.parts) <=62) : if not self.o.parts is None and not(int(self.o.parts)>=12 and int(self.o.parts) <=62) :
self.error_cmd((('invalid option ',('-p, --parts', Sys.Clz.fgb3), ' value (', ('12',Sys.Clz.fgb3),' to ', ('62',Sys.Clz.fgb3),')'),)) self.error_cmd((('invalid option ',('-p, --parts', Sys.Clz.fgb3), ' value (', ('12',Sys.Clz.fgb3),' to ', ('62',Sys.Clz.fgb3),')'),))
else : self.o.parts = int(self.o.parts) else : self.o.parts = int(self.o.parts)
if not self.o.quiet : self.parser.print_header() if not Sys.g.QUIET : self.parser.print_header()
if self.o.outputfile is not None : if self.o.outputfile is not None :
if self.o.outputfile[-5:]!='.tark' : self.o.outputfile += '.tark' if self.o.outputfile[-5:]!='.tark' : self.o.outputfile += '.tark'
if Io.file_exists(self.o.outputfile) and not self.o.force: if Io.file_exists(self.o.outputfile) and not self.o.force:
@ -204,80 +187,110 @@ class CliApp:
if done : if done :
try : try :
if not self.o.quiet and not Sys.g.DEBUG : Sys.print(' Processing, please wait...\n', Sys.Clz.fgB2) Sys.ptask()
Sys.cli_emit_progress(2)
key = Io.get_data(self.o.keyfile) key = Io.get_data(self.o.keyfile)
km = Kirmah(key) km = Kirmah(key)
hlst = km.ck.getHashList(Sys.basename(self.a[1]), self.o.parts, True) hlst = km.ck.getHashList(Sys.basename(self.a[1]), self.o.parts, True)
Sys.cli_emit_progress(3)
kcf = km.splitFile(self.a[1], hlst) kcf = km.splitFile(self.a[1], hlst)
t = int(Sys.time()) t = int(Sys.time())
times = (t,t) times = (t,t)
p = 85
Sys.cli_emit_progress(p)
Io.touch(kcf, times) Io.touch(kcf, times)
frav = 0.24
for row in hlst['data']: for row in hlst['data']:
p += frav
Io.touch(row[1]+km.EXT,times) Io.touch(row[1]+km.EXT,times)
Sys.cli_emit_progress(p)
if self.o.outputfile is not None : if self.o.outputfile is not None :
import tarfile d = Sys.datetime.now()
if Sys.g.DEBUG : Sys.wlog(Sys.dprint())
Sys.ptask('Preparing tark file')
hlst['data'] = sorted(hlst['data'], key=lambda lst: lst[4]) hlst['data'] = sorted(hlst['data'], key=lambda lst: lst[4])
with tarfile.open(self.o.outputfile, mode='w') as tar: with tarfile.open(self.o.outputfile, mode='w') as tar:
tar.add(kcf) tar.add(kcf, arcname=Sys.basename(kcf))
Io.removeFile(kcf) p = 90
for row in hlst['data']: for row in hlst['data']:
tar.add(row[1]+km.EXT) tar.add(row[1]+km.EXT, arcname=Sys.basename(row[1]+km.EXT))
Io.removeFile(row[1]+km.EXT) p += frav
Sys.cli_emit_progress(p)
Sys.pstep('Packing destination file', d, True)
d = Sys.datetime.now()
Sys.ptask('Finalize')
for row in hlst['data']:
Io.removeFile(row[1]+km.EXT)
p += frav
Sys.cli_emit_progress(p)
Io.removeFile(kcf)
Sys.pstep('Cleaning', d, True)
except Exception as e : except Exception as e :
done = False done = False
if Sys.g.DEBUG : if Sys.g.DEBUG :
raise e print('split exception')
elif not self.o.quiet : print(e)
#~ raise e
elif not Sys.g.QUIET :
Sys.pwarn((str(e),)) Sys.pwarn((str(e),))
if not self.o.quiet : if not Sys.g.QUIET:
self.onend_cmd('Splitting file', self.stime, done, self.o.outputfile) Sys.cli_emit_progress(100)
self.onend_cmd('Kirmah Split', self.stime, done, self.o.outputfile)
@Log(Const.LOG_DEBUG)
def onCommandMerge(self): def onCommandMerge(self):
"""""" """"""
done = True done = True
if not self.o.quiet : self.parser.print_header() if not Sys.g.QUIET : self.parser.print_header()
if done : if done :
toPath = None
try : try :
if not self.o.quiet and not Sys.g.DEBUG : Sys.print(' Processing, please wait...\n', Sys.Clz.fgB2) Sys.ptask()
key = Io.get_data(self.o.keyfile) key = Io.get_data(self.o.keyfile)
km = Kirmah(key) km = Kirmah(key)
try: try:
import tarfile import tarfile
with tarfile.open(self.a[1], mode='r') as tar: with tarfile.open(self.a[1], mode='r') as tar:
path = Sys.dirname(self.o.outputfile) if self.o.outputfile is not None else '.' dpath = Sys.dirname(Sys.realpath(self.o.outputfile))+Sys.sep if self.o.outputfile is not None else '.'+Sys.sep
tar.extractall(path=path) print(dpath)
tar.extractall(path=dpath)
kcf = None
for tarinfo in tar: for tarinfo in tar:
print(tarinfo.name)
if tarinfo.isreg() and tarinfo.name[-4:]=='.kcf': if tarinfo.isreg() and tarinfo.name[-4:]=='.kcf':
toPath = km.mergeFile(path+Sys.sep+tarinfo.name) kcf = dpath+tarinfo.name
except : if kcf is not None :
pass 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]) toPath = km.mergeFile(self.a[1])
if self.o.outputfile is not None :
Io.rename(toPath, self.o.outputfile)
toPath = self.o.outputfile
except Exception as e : except Exception as e :
done = False done = False
if Sys.g.DEBUG : if Sys.g.DEBUG :
print(e)
raise e raise e
elif not self.o.quiet : elif not Sys.g.QUIET :
Sys.pwarn((str(e),)) Sys.pwarn((str(e),))
if not self.o.quiet : if not Sys.g.QUIET :
self.onend_cmd('Merging file', self.stime, done, toPath) self.onend_cmd('Merging file', self.stime, done, toPath)
def onend_mproc(self, tstart, done): @Log(Const.LOG_ALL)
""""""
from gi.repository.Gtk import main_quit as gtk_quit
gtk_quit()
def getDefaultOption(self, args): def getDefaultOption(self, args):
"""""" """"""
c = None c = None
@ -288,10 +301,18 @@ class CliApp:
return c return c
@Log(Const.LOG_DEBUG)
def onend_cmd(self, title, stime, done, outputfile): def onend_cmd(self, title, stime, done, outputfile):
"""""" """"""
if Sys.g.DEBUG : Sys.dprint() s = Const.LINE_SEP_CHAR*Const.LINE_SEP_LEN
Sys.pstep(title, stime, done) Sys.print(s, Sys.CLZ_HEAD_LINE)
if done : Sys.wlog([(s, Const.CLZ_HEAD_SEP)])
Sys.pstep(title, stime, done, True)
Sys.print(s, Sys.CLZ_HEAD_LINE)
Sys.wlog([(s, Const.CLZ_HEAD_SEP)])
if done and outputfile is not None:
Sys.print(' '*5+Sys.realpath(outputfile), Sys.Clz.fgB1, False) Sys.print(' '*5+Sys.realpath(outputfile), Sys.Clz.fgB1, False)
Sys.print(' ('+Sys.getFileSize(outputfile)+')', Sys.Clz.fgB3) Sys.print(' ('+Sys.getFileSize(outputfile)+')', Sys.Clz.fgB3)
bdata = [(' '*5+Sys.realpath(outputfile), 'io'),(' ('+Sys.getFileSize(outputfile)+')','func')]
Sys.wlog(bdata)
Sys.wlog(Sys.dprint())

View File

@ -1,49 +1,64 @@
#!/usr/bin/env python # !/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # kirmah/conf.py
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# software : Kirmah <http://kirmah.sourceforge.net/> #
# version : 2.1 #
# date : 2013 #
# licence : GPLv3.0 <http://www.gnu.org/licenses/> #
# author : a-Sansara <http://www.a-sansara.net/> #
# copyright : pluie.org <http://www.pluie.org/> #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# This file is part of Kirmah. # software : Kirmah <http://kirmah.sourceforge.net/>
# version : 2.17
# date : 2013
# licence : GPLv3.0 <http://www.gnu.org/licenses/>
# author : a-Sansara <[a-sansara]at[clochardprod]dot[net]>
# copyright : pluie.org <http://www.pluie.org/>
# #
# Kirmah is free software (free as in speech) : you can redistribute it # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of the License,
# or (at your option) any later version.
# #
# Kirmah is distributed in the hope that it will be useful, but WITHOUT # This file is part of Kirmah.
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # Kirmah is free software (free as in speech) : you can redistribute it
# more details. # and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of the License,
# or (at your option) any later version.
#
# Kirmah is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License
# along with Kirmah. If not, see <http://www.gnu.org/licenses/>.
# #
# You should have received a copy of the GNU General Public License
# along with Kirmah. If not, see <http://www.gnu.org/licenses/>.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~ module conf ~~ # ~~ module conf ~~
from getpass import getuser as getUserLogin from getpass import getuser as getUserLogin
from os import sep
from os.path import dirname, realpath
PRG_NAME = 'Kirmah' PRG_NAME = 'Kirmah'
PRG_CLI_NAME = 'kirmah-cli' PRG_PACKAGE = PRG_NAME.lower()
PRG_SCRIPT = PRG_NAME.lower()
PRG_CLI_NAME = PRG_SCRIPT+'-cli'
PRG_VERS = '2.1' PRG_VERS = '2.1'
PRG_AUTHOR = 'a-Sansara' PRG_AUTHOR = 'a-Sansara'
PRG_COPY = 'pluie.org 2013' PRG_COPY = 'pluie.org'
PRG_YEAR = '2013'
PRG_WEBSITE = 'http://kirmah.sourceforge.net' PRG_WEBSITE = 'http://kirmah.sourceforge.net'
PRG_LICENSE = 'GNU GPL v3' PRG_LICENSE = 'GNU GPL v3'
PRG_LICENSE_PATH = 'gpl.txt' PRG_RESOURCES_PATH = '/usr/share/pixmaps/'+PRG_PACKAGE+'/'
PRG_LOGO_PATH = 'kirmah.png' try:
PRG_LOGO_ICON_PATH = 'kirmah_ico.png' with open(PRG_RESOURCES_PATH) as f:
pass
except IOError as e:
PRG_RESOURCES_PATH = dirname(dirname(realpath(__file__)))+sep+'resources'+sep
pass
print(PRG_RESOURCES_PATH)
PRG_GLADE_PATH = PRG_RESOURCES_PATH+PRG_PACKAGE+sep+'glade'+sep+PRG_PACKAGE+'.glade'
PRG_LICENSE_PATH = PRG_RESOURCES_PATH+PRG_PACKAGE+'/LICENSE'
PRG_LOGO_PATH = PRG_RESOURCES_PATH+'pixmaps'+sep+PRG_PACKAGE+sep+PRG_PACKAGE+'.png'
PRG_LOGO_ICON_PATH = PRG_RESOURCES_PATH+'pixmaps'+sep+PRG_PACKAGE+sep+PRG_PACKAGE+'_ico.png'
PRG_ABOUT_LOGO_SIZE = 160 PRG_ABOUT_LOGO_SIZE = 160
PRG_ABOUT_COPYRIGHT = '(c) '+PRG_AUTHOR+' - '+PRG_COPY+' 2013' PRG_ABOUT_COPYRIGHT = '(c) '+PRG_AUTHOR+' - '+PRG_COPY+' '+PRG_YEAR
PRG_ABOUT_COMMENTS = ''.join(['Kirmah simply encrypt/decrypt files','\n', 'license ',PRG_LICENSE]) PRG_ABOUT_COMMENTS = ''.join(['Kirmah simply encrypt/decrypt files','\n', 'license ',PRG_LICENSE])
PRG_DESC = """ PRG_DESC = """
Encryption with symmetric-key algorithm Kirmah. Encryption with symmetric-key algorithm Kirmah.
@ -81,7 +96,6 @@ PRG_DESC = """
the merge command is the opposite process. the merge command is the opposite process.
""" """
PRG_GLADE_PATH = 'kirmah.glade'
DEFVAL_NPROC = 2 DEFVAL_NPROC = 2
@ -89,9 +103,10 @@ DEFVAL_NPROC_MAX = 8
DEFVAL_NPROC_MIN = 2 DEFVAL_NPROC_MIN = 2
DEFVAL_COMP = False DEFVAL_COMP = False
DEFVAL_ENCMODE = True DEFVAL_ENCMODE = True
DEFVAL_MIXDATA = False DEFVAL_MIXMODE = True
DEFVAL_USER_PATH = ''.join(['/home/', getUserLogin(), '/']) DEFVAL_RANDOMMODE = True
DEFVAL_UKEY_PATH = ''.join([DEFVAL_USER_PATH, '.', PRG_NAME.lower(), '/']) DEFVAL_USER_PATH = ''.join([sep,'home',sep,getUserLogin(),sep])
DEFVAL_UKEY_PATH = ''.join([DEFVAL_USER_PATH, '.', PRG_PACKAGE,sep])
DEFVAL_UKEY_NAME = '.default.key' DEFVAL_UKEY_NAME = '.default.key'
DEFVAL_UKEY_LENGHT = 1024 DEFVAL_UKEY_LENGHT = 1024
DEFVAL_CRYPT_EXT = '.kmh' DEFVAL_CRYPT_EXT = '.kmh'
@ -99,3 +114,14 @@ DEFVAL_CRYPT_EXT = '.kmh'
DEBUG = True DEBUG = True
UI_TRACE = True UI_TRACE = True
PCOLOR = True PCOLOR = True
GUI_LABEL_PROCEED = 'Proceed'
GUI_LABEL_OK = 'OK'
GUI_LABEL_CANCEL = 'Cancel'
def redefinePaths(path):
PRG_GLADE_PATH = path+PRG_PACKAGE+sep+'glade'+sep+PRG_PACKAGE+'.glade'
PRG_LICENSE_PATH = path+PRG_PACKAGE+sep+'LICENSE'
PRG_LOGO_PATH = path+'pixmaps'+sep+PRG_PACKAGE+sep+PRG_PACKAGE+'.png'
PRG_LOGO_ICON_PATH = path+'pixmaps'+sep+PRG_PACKAGE+sep+PRG_PACKAGE+'_ico.png'

File diff suppressed because one or more lines are too long

415
kirmah/gui.py Normal file
View File

@ -0,0 +1,415 @@
# !/usr/bin/env python
# -*- coding: utf-8 -*-
# kirmah.gui.py
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# software : Kirmah <http://kirmah.sourceforge.net/>
# version : 2.17
# date : 2013
# licence : GPLv3.0 <http://www.gnu.org/licenses/>
# author : a-Sansara <[a-sansara]at[clochardprod]dot[net]>
# copyright : pluie.org <http://www.pluie.org/>
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# This file is part of Kirmah.
#
# Kirmah is free software (free as in speech) : you can redistribute it
# and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of the License,
# or (at your option) any later version.
#
# Kirmah is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License
# along with Kirmah. If not, see <http://www.gnu.org/licenses/>.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~ module gui ~~
from gi.repository import Gtk, GObject, GLib, Gdk, Pango
from os import sep, remove
from os.path import abspath, dirname, join, realpath, basename, getsize, isdir, splitext
from base64 import b64decode, b64encode
from time import time, sleep
from getpass import getuser as getUserLogin
from mmap import mmap
from math import ceil
from threading import Thread, Event, Timer, Condition, RLock, current_thread, get_ident, enumerate as thread_enum
from kirmah.crypt import KeyGen, Kirmah, KirmahHeader, ConfigKey, BadKeyException, b2a_base64, a2b_base64, hash_sha256_file
from kirmah.app import KirmahApp, FileNotFoundException, FileNeedOverwriteException
from kirmah.ui import Gui, CliThread
from kirmah import conf
from psr.sys import Sys, Io, Const
from psr.log import Log
from psr.mproc import Manager, Lock
import pdb
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~ class AppGui ~~
class AppGui(Gui):
DEFAULT_KEY = 0
EXISTING_KEY = 1
NEW_KEY = 2
IS_SOURCE_DEF = False
IS_DEST_DEF = True
MODE_CRYPT = True
COMPRESSION = True
NPROC = 2
PROCEED = False
curKey = 0
start = False
poslog = 0
@Log(Const.LOG_BUILD)
def __init__(self, wname='window1'):
""""""
self.app = KirmahApp(conf.DEBUG, conf.PCOLOR)
super().__init__(wname)
@Log(Const.LOG_UI)
def on_start(self):
""""""
self.app.createDefaultKeyIfNone()
key, size, mark = self.app.getKeyInfos()
self.curKey = self.DEFAULT_KEY
self.get('filechooserbutton1').set_filename(self.app.getDefaultKeyPath())
self.get('filechooserbutton3').set_current_folder(conf.DEFVAL_USER_PATH)
devPath = '/home/dev/git_repos/kirmah2.15/'
#~ self.get('filechooserbutton3').set_current_folder(devPath)
self.get('checkbutton1').set_active(conf.DEFVAL_NPROC>=2)
self.get('checkbutton3').set_active(True)
self.get('checkbutton4').set_active(True)
self.get('spinbutton2').set_value(conf.DEFVAL_NPROC)
if conf.DEFVAL_NPROC >= 2:
self.disable('spinbutton2', False)
self.get('checkbutton2').set_active(conf.DEFVAL_MIXMODE)
self.get('checkbutton4').set_active(conf.DEFVAL_RANDOMMODE)
self.get('entry1').set_text(mark)
Sys.g.UI_AUTO_SCROLL = True
self.textview = self.get('textview1')
self.textview.override_background_color(Gtk.StateFlags.NORMAL, Gdk.RGBA(0, 0, 0, 1.0))
self.textview.modify_font(Pango.font_description_from_string ('DejaVu Sans Mono Book 11'))
self.textbuffer = self.textview.get_buffer()
self.tags = self.buildTxtTags(self.textbuffer)
self.progressbar = self.get('progressbar1')
cbt = self.get('comboboxtext1')
cbt.connect("changed", self.on_compression_changed)
tree_iter = cbt.get_model().get_iter_first()
print(cbt.get_model().get_string_from_iter(tree_iter))
tree_iter = cbt.get_model().get_iter_from_string('3')
cbt.set_active_iter(tree_iter)
cbt = self.get('comboboxtext2')
cbt.connect("changed", self.on_logging_changed)
tree_iter = cbt.get_model().get_iter_first()
cbt.set_active_iter(tree_iter)
Sys.clear()
Sys.dprint('INIT UI')
self.start = True
self.thkmh = None
@Log(Const.LOG_UI)
def launch_thread(self, *args):
self.progressbar.show()
def getKmhThread(on_completed, on_interrupted, on_progress, userData, *args):
thread = CliThread(*args)
thread.connect("completed" , on_completed , userData)
thread.connect("interrupted", on_interrupted , userData)
thread.connect("progress" , on_progress , userData)
return thread
cliargs = ['kirmah-cli.py', 'split', '-df', '/media/Hermes/webbakup/The Raven.avi', '-z', '-r', '-m', '-o', '/home/dev/git_repos/kirmah2.15/The Raven.avi.kmh']
cliargs = self.app.getCall()
self.thkmh = getKmhThread(self.thread_finished, self.thread_interrupted, self.thread_progress, None, cliargs)
self.thkmh.start()
@Log(Const.LOG_UI)
def on_mixdata_changed(self, checkbox):
""""""
self.app.setMixMode(not checkbox.get_active())
if self.start: self.refreshProceed()
@Log(Const.LOG_UI)
def on_randomdata_changed(self, checkbox):
""""""
self.app.setRandomMode(not checkbox.get_active())
if self.start: self.refreshProceed()
@Log(Const.LOG_UI)
def on_multiproc_changed(self, checkbox, data = None):
""""""
disabled = checkbox.get_active()
self.disable('spinbutton2',disabled)
self.app.setMultiprocessing(int(self.get('spinbutton2').get_value()) if not disabled else 0)
if self.start: self.refreshProceed()
@Log(Const.LOG_UI)
def on_logging_changed(self, combo):
""""""
tree_iter = combo.get_active_iter()
if tree_iter != None:
v = combo.get_model()[tree_iter][:2][0]
if v =='DISABLED' :
Sys.g.DEBUG = False
elif hasattr(Const, v):
Sys.g.DEBUG = True
exec('Sys.g.LOG_LEVEL = Const.'+v)
else :
Sys.g.LOG_LEVEL = Const.LOG_DEFAULT
if self.start: self.refreshProceed()
@Log(Const.LOG_DEFAULT)
def on_compression_changed(self, combo):
tree_iter = combo.get_active_iter()
if tree_iter != None:
model = combo.get_model()
comp = KirmahHeader.COMP_END if model[tree_iter][:2][0]=='yes' else (KirmahHeader.COMP_NONE if model[tree_iter][:2][0]=='no' else KirmahHeader.COMP_ALL)
print(comp)
self.app.setCompression(comp)
if self.start: self.refreshProceed()
@Log(Const.LOG_UI)
def on_nproc_changed(self, spin):
""""""
self.app.setMultiprocessing(int(spin.get_value()))
if self.start: self.refreshProceed()
@Log(Const.LOG_UI)
def on_keylen_changed(self, spin):
""""""
filename = self.get('filechooserbutton1').get_filename()
if Io.file_exists(filename):
self.app.createNewKey(filename, int(self.get('spinbutton1').get_value()))
if self.start: self.refreshProceed()
@Log(Const.LOG_UI)
def on_new_file_key(self, fc):
""""""
filename = fc.get_filename()
if self.curKey == self.NEW_KEY:
self.app.createNewKey(filename, int(self.get('spinbutton1').get_value()))
self.app.selectKey(filename)
k, s, m = self.app.getKeyInfos(filename)
self.get('spinbutton1').set_value(s)
self.get('entry1').set_text(m)
self.get('filechooserbutton1').set_filename(filename)
if self.curKey == self.NEW_KEY:
self.get('radiobutton2').set_active(True)
self.disable('spinbutton1', True)
if self.start: self.refreshProceed()
@Log(Const.LOG_UI)
def on_switch_mode(self, s, data):
""""""
self.app.switchEncMode(not s.get_active())
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'))
if self.start: self.refreshProceed()
@Log(Const.LOG_UI)
def on_switch_format(self, s, data):
""""""
self.app.switchFormatMode(not s.get_active())
if self.app.encmode :
for n in ['checkbutton1', 'spinbutton2', 'checkbutton2','checkbutton4','comboboxtext1','label12']:
self.disable(n, self.app.splitmode)
if not s.get_active() :
self.get('label8').set_text('encrypt')
self.get('label9').set_text('decrypt')
self.get('checkbutton1').set_sensitive(True)
self.get('spinbutton2').set_sensitive(True)
else :
self.get('label8').set_text('split')
self.get('label9').set_text('merge')
self.get('checkbutton1').set_sensitive(False)
self.get('spinbutton2').set_sensitive(False)
if self.start: self.refreshProceed()
@Log(Const.LOG_UI)
def on_new_file_source(self, fc, data=None):
""""""
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)
@Log(Const.LOG_UI)
def on_new_file_dest(self, fc, data=None):
""""""
if self.start:
try :
self.app.setDestFile(fc.get_filename())
except :
pass
self.IS_DEST_DEF = True
self.refreshProceed()
@Log(Const.LOG_UI)
def on_existing_key(self, button):
""""""
self.curKey = self.EXISTING_KEY
self.disable('spinbutton1',True)
self.disable('filechooserbutton1',False)
self.get('filechooserbutton1').set_filename(self.app.kpath)
fc = self.get('filechooserbutton1')
self.on_new_file_key(fc)
@Log(Const.LOG_UI)
def on_new_key(self, button):
""""""
self.curKey = self.NEW_KEY
self.disable('spinbutton1',False)
self.disable('filechooserbutton1',False)
self.get('filechooserbutton1').set_current_folder(conf.DEFVAL_UKEY_PATH)
@Log(Const.LOG_UI)
def on_default_key(self, button):
""""""
self.curKey = self.DEFAULT_KEY
self.disable('spinbutton1',True)
self.disable('filechooserbutton1',True)
fc = self.get('filechooserbutton1')
fc.set_filename(self.app.getDefaultKeyPath())
self.on_new_file_key(fc)
@Log(Const.LOG_UI)
def on_autoscroll_changed(self, btn):
""""""
Sys.g.UI_AUTO_SCROLL = not btn.get_active()
@Log(Const.LOG_NEVER)
def clear_log(self, btn):
""""""
self.textbuffer.set_text('')
@Log(Const.LOG_UI)
def show_log(self):
""""""
btn = self.get('button1')
if not self.PROCEED :
self.get('frame3').hide()
self.get('frame1').show()
self.get('frame2').show()
self.get('checkbutton3').hide()
self.repack('frame4', True)
btn.set_sensitive(self.IS_DEST_DEF and self.IS_SOURCE_DEF)
else :
self.repack('frame4', False)
self.get('frame1').hide()
self.get('frame2').hide()
self.get('frame3').show()
self.get('checkbutton3').show()
if btn.get_label() == conf.GUI_LABEL_PROCEED :
btn.set_sensitive(False)
@Log(Const.LOG_UI)
def refreshProceed(self):
""""""
if self.start :
self.get('button1').set_sensitive(self.IS_DEST_DEF and self.IS_SOURCE_DEF)
@Log(Const.LOG_UI)
def on_proceed(self, btn):
""""""
if btn.get_label() == conf.GUI_LABEL_OK :
btn = self.get('button1')
btn.set_label(conf.GUI_LABEL_PROCEED)
self.PROCEED = False
self.pb.hide()
self.show_log()
else :
if not self.PROCEED :
self.list_threads()
self.PROCEED = True
self.STOPPED = False
btn.set_sensitive(False)
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'))
self.show_log()
self.launch_thread()
else :
self.on_proceed_end(True)
else :
self.halt_thread()
@Log(Const.LOG_UI)
def halt_thread(self, *args):
Sys.wlog(Sys.dprint())
Sys.pwarn(('thread interrupt',), False)
self.get('button1').set_sensitive(False)
if self.thkmh is not None and self.thkmh.isAlive():
self.thkmh.cancel()
else :
self.textbuffer.insert_at_cursor('Kmh Thread is not Alive\n')
@Log(Const.LOG_UI)
def on_proceed_end(self, abort=False):
""""""
try :
btn = self.get('button1')
btn.set_label('Proceed')
btn.set_sensitive(True)
self.PROCEED = False
btn.set_label(conf.GUI_LABEL_OK)
self.get('checkbutton3').hide()
except Exception as e:
Sys.pwarn((('on_proceed_end : ',(str(e),Sys.CLZ_WARN_PARAM), ' !'),), False)
pass
return False

362
kirmah/ui.py Normal file
View File

@ -0,0 +1,362 @@
# !/usr/bin/env python
# -*- coding: utf-8 -*-
# kirmah/ui.py
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# software : Kirmah <http://kirmah.sourceforge.net/>
# version : 2.17
# date : 2013
# licence : GPLv3.0 <http://www.gnu.org/licenses/>
# author : a-Sansara <[a-sansara]at[clochardprod]dot[net]>
# copyright : pluie.org <http://www.pluie.org/>
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# This file is part of Kirmah.
#
# Kirmah is free software (free as in speech) : you can redistribute it
# and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of the License,
# or (at your option) any later version.
#
# Kirmah is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License
# along with Kirmah. If not, see <http://www.gnu.org/licenses/>.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~ module ui ~~
from gi.repository import Pango
from gi.repository.Gdk import threads_enter, threads_leave
from gi.repository.Gtk import AboutDialog, Builder, main as main_enter, main_quit, MessageDialog, MessageType, ButtonsType, ResponseType, PackType
from gi.repository.GdkPixbuf import Pixbuf
from gi.repository.GObject import threads_init, GObject, idle_add, SIGNAL_RUN_LAST, TYPE_NONE, TYPE_STRING, TYPE_FLOAT, TYPE_BOOLEAN
from threading import Thread, current_thread, enumerate as thread_enum
from psr.sys import Sys, Io, Const
from psr.log import Log
from kirmah import conf
from kirmah.cli import Cli
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~ class Gui ~~
class Gui():
@Log(Const.LOG_BUILD)
def __init__(self, wname):
""""""
threads_init()
self.wname = wname
self.builder = Builder()
self.builder.add_from_file(conf.PRG_GLADE_PATH)
self.builder.connect_signals(self)
self.win = self.get(wname)
self.win.connect('destroy', self.onDeleteWindow)
self.win.connect('delete-event', self.onDeleteWindow)
self.win.set_title(conf.PRG_NAME+' v'+conf.PRG_VERS)
self.win.show_all()
self.on_start()
main_enter()
@Log(Const.LOG_DEBUG)
def buildTxtTags(self, textbuffer):
tags = {}
tags[Const.CLZ_TIME] = textbuffer.create_tag(Const.CLZ_TIME , foreground="#208420", weight=Pango.Weight.BOLD)
tags[Const.CLZ_SEC] = textbuffer.create_tag(Const.CLZ_SEC , foreground="#61B661", weight=Pango.Weight.BOLD)
tags[Const.CLZ_DEFAULT] = textbuffer.create_tag(Const.CLZ_DEFAULT , foreground="#FFEDD0")
tags[Const.CLZ_IO] = textbuffer.create_tag(Const.CLZ_IO , foreground="#EB3A3A", weight=Pango.Weight.BOLD)
tags[Const.CLZ_FUNC] = textbuffer.create_tag(Const.CLZ_FUNC , foreground="#EBEB3A", weight=Pango.Weight.BOLD)
tags[Const.CLZ_CFUNC] = textbuffer.create_tag(Const.CLZ_CFUNC , foreground="#EBB33A", weight=Pango.Weight.BOLD)
tags[Const.CLZ_DELTA] = textbuffer.create_tag(Const.CLZ_DELTA , foreground="#397BE8", weight=Pango.Weight.BOLD)
tags[Const.CLZ_ARGS] = textbuffer.create_tag(Const.CLZ_ARGS , foreground="#A1A1A1")
tags[Const.CLZ_ERROR] = textbuffer.create_tag(Const.CLZ_ERROR , background="#830005", foreground="#FFFFFF", weight=Pango.Weight.BOLD)
tags[Const.CLZ_ERROR_PARAM] = textbuffer.create_tag(Const.CLZ_ERROR_PARAM , background="#830005", foreground="#EBEB3A", weight=Pango.Weight.BOLD)
tags[Const.CLZ_WARN] = textbuffer.create_tag(Const.CLZ_WARN , background="#A81459", foreground="#FFFFFF", weight=Pango.Weight.BOLD)
tags[Const.CLZ_WARN_PARAM] = textbuffer.create_tag(Const.CLZ_WARN_PARAM , background="#A81459", foreground="#EBEB3A", weight=Pango.Weight.BOLD)
tags[Const.CLZ_PID] = textbuffer.create_tag(Const.CLZ_PID , background="#5B0997", foreground="#E4C0FF", weight=Pango.Weight.BOLD)
tags[Const.CLZ_CPID] = textbuffer.create_tag(Const.CLZ_CPID , background="#770997", foreground="#F4CDFF", weight=Pango.Weight.BOLD)
tags[Const.CLZ_SYMBOL] = textbuffer.create_tag(Const.CLZ_SYMBOL , background="#61B661", foreground="#FFFFFF", weight=Pango.Weight.BOLD)
tags[Const.CLZ_OK] = textbuffer.create_tag(Const.CLZ_OK , background="#167B3B", foreground="#FFFFFF", weight=Pango.Weight.BOLD)
tags[Const.CLZ_KO] = textbuffer.create_tag(Const.CLZ_KO , background="#7B1716", foreground="#FFFFFF", weight=Pango.Weight.BOLD)
tags[Const.CLZ_TITLE] = textbuffer.create_tag(Const.CLZ_TITLE , foreground="#FFFFFF", weight=Pango.Weight.BOLD)
tags[Const.CLZ_TASK] = textbuffer.create_tag(Const.CLZ_TASK , foreground="#61B661", weight=Pango.Weight.BOLD)
tags[Const.CLZ_HEAD_APP] = textbuffer.create_tag(Const.CLZ_HEAD_APP , background="#2B5BAB", foreground="#FFFFFF", weight=Pango.Weight.BOLD)
tags[Const.CLZ_HEAD_SEP] = textbuffer.create_tag(Const.CLZ_HEAD_SEP , foreground="#A1A1A1")
tags[Const.CLZ_HEAD_KEY] = textbuffer.create_tag(Const.CLZ_HEAD_KEY , foreground="#EBEB3A", weight=Pango.Weight.BOLD)
tags[Const.CLZ_HEAD_VAL] = textbuffer.create_tag(Const.CLZ_HEAD_VAL , foreground="#397BE8", weight=Pango.Weight.BOLD)
return tags
@Log(Const.LOG_UI)
def onDeleteWindow(self, *args):
""""""
mthread = current_thread()
try:
self.join_threads(True)
self.cleanResources()
except Exception as e:
pass
finally:
main_quit(*args)
@Log(Const.LOG_UI)
def list_threads(self):
""""""
print('thread list : ')
for th in thread_enum():
print(th)
@Log(Const.LOG_UI)
def join_threads(self, join_main=False):
""""""
mthread = current_thread()
try:
for th in thread_enum():
if th is not mthread :
th.join()
if join_main: mthread.join()
except Exception as e:
pass
@Log(Const.LOG_UI)
def on_about(self, btn):
""""""
about = AboutDialog()
about.set_program_name(conf.PRG_NAME)
about.set_version('v '+conf.PRG_VERS)
about.set_copyright(conf.PRG_ABOUT_COPYRIGHT)
about.set_comments(conf.PRG_ABOUT_COMMENTS)
about.set_website(conf.PRG_WEBSITE)
about.set_website_label(conf.PRG_WEBSITE)
about.set_license(Io.get_data(conf.PRG_LICENSE_PATH))
pixbuf = Pixbuf.new_from_file_at_size(conf.PRG_LOGO_PATH, conf.PRG_ABOUT_LOGO_SIZE, conf.PRG_ABOUT_LOGO_SIZE)
about.set_logo(pixbuf)
pixbuf = Pixbuf.new_from_file_at_size(conf.PRG_LOGO_PATH, conf.PRG_ABOUT_LOGO_SIZE, conf.PRG_ABOUT_LOGO_SIZE)
about.set_icon(pixbuf)
about.run()
about.destroy()
@Log(Const.LOG_DEBUG)
def get(self, name):
""""""
return self.builder.get_object(name)
@Log(Const.LOG_DEBUG)
def disable(self, name, disabled):
""""""
self.get(name).set_sensitive(not disabled)
@Log(Const.LOG_DEBUG)
def repack(self, name, expandfill=False, packStart=True):
w = self.get(name)
w.get_parent().set_child_packing(w, expandfill, expandfill, 0, PackType.START if packStart else PackType.END )
return w
@Log(Const.LOG_DEBUG)
def detachWidget(self, name, hideParent=True):
w = self.get(name)
wp = w.get_parent()
if wp is not None :
wp.remove(w)
w.unparent()
if hideParent : wp.hide()
@Log(Const.LOG_DEBUG)
def attachWidget(self, widget, parentName, expandfill=None, showParent=True):
if widget is not None :
wp = self.get(parentName)
if wp is not None :
if expandfill is None : wp.add(widget)
else :
wp.pack_start(widget,expandfill,expandfill,0)
if showParent : wp.show()
@Log(Const.LOG_UI)
def thread_finished(self, thread, ref):
thread = None
self.on_proceed_end(False)
@Log(Const.LOG_UI)
def on_proceed_end(self, abort=False):
""""""
@Log(Const.LOG_UI)
def thread_interrupted(self, thread, ref):
thread = None
self.end_progress()
self.on_proceed_end(False)
@Log(Const.LOG_NEVER)
def thread_progress(self, thread, progress, ref):
while not Sys.g.LOG_QUEUE.empty():
data = Sys.g.LOG_QUEUE.get()
if data is not None :
if data is not Sys.g.SIGNAL_STOP :
for item in data :
ei = self.textbuffer.get_end_iter()
offs = ei.get_offset()
self.textbuffer.insert_at_cursor(item[0])
ei = self.textbuffer.get_end_iter()
oi = self.textbuffer.get_iter_at_offset(offs)
tagName = item[1]
self.textbuffer.apply_tag(self.tags[tagName], oi, ei)
self.textbuffer.insert_at_cursor('\n')
self.scroll_end()
else :
Sys.dprint('STOP')
thread.cancel()
self.update_progress(progress)
@Log(Const.LOG_NEVER)
def update_progress(self, progress, lvl=50):
if progress > 0 :
self.progressbar.set_text(str(progress))
lp = self.progressbar.get_fraction()
diff = (progress/100.0 - lp)
for i in range(lvl):
nf = lp+(i*diff/lvl)
if nf < progress/100.0 :
self.progressbar.set_fraction(nf)
self.progressbar.set_fraction(progress/100.0)
@Log(Const.LOG_NEVER)
def end_progress(self):
self.update_progress(100, 10)
@Log(Const.LOG_NEVER)
def scroll_end(self):
if Sys.g.UI_AUTO_SCROLL :
if self.textbuffer is not None :
insert_mark = self.textbuffer.get_insert()
ei = self.textbuffer.get_end_iter()
if ei is not None and insert_mark is not None:
self.textbuffer.place_cursor(ei)
self.textview.scroll_to_mark(insert_mark , 0.0, True, 0.0, 1.0)
@Log(Const.LOG_UI)
def cleanResources(self):
""""""
@Log(Const.LOG_UI)
def on_start(self):
""""""
@Log(Const.LOG_UI)
def warnDialog(self, intro, ask):
""""""
dialog = MessageDialog(self.get(self.wname), 0, MessageType.WARNING, ButtonsType.OK_CANCEL, intro)
dialog.format_secondary_text(ask)
response = dialog.run()
dialog.destroy()
return response == ResponseType.OK;
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~ class IdleObject ~~
class IdleObject(GObject):
"""
Override gi.repository.GObject to always emit signals in the main thread
by emmitting on an idle handler
"""
@Log(Const.LOG_UI)
def __init__(self):
""""""
GObject.__init__(self)
@Log(Const.LOG_NEVER)
def emit(self, *args):
""""""
idle_add(GObject.emit, self, *args)
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~ class CliThread ~~
class CliThread(Thread, IdleObject):
"""
Cancellable thread which uses gobject signals to return information
to the GUI.
"""
__gsignals__ = { # signal type signal return signal args
"completed" : ( SIGNAL_RUN_LAST, TYPE_NONE, ()),
"interrupted" : ( SIGNAL_RUN_LAST, TYPE_NONE, ()),
"progress" : ( SIGNAL_RUN_LAST, TYPE_NONE, (TYPE_FLOAT,))
}
@Log(Const.LOG_DEBUG)
def __init__(self, rwargs):
Thread.__init__(self)
IdleObject.__init__(self)
self.setName('CliThread')
self.cliargs = rwargs
@Log(Const.LOG_DEBUG)
def run(self):
""""""
self.cancelled = False
print(Sys.g.LOG_LEVEL)
Cli('./', Sys.getpid(), self.cliargs, self, Sys.g.LOG_LEVEL)
self.emit("completed")
@Log(Const.LOG_NEVER)
def progress(self, value):
""""""
self.emit("progress", value)
@Log(Const.LOG_NEVER)
def cancel(self):
"""
Threads in python are not cancellable, so we implement our own
cancellation logic
"""
self.cancelled = True
@Log(Const.LOG_NEVER)
def stop(self):
""""""
if self.isAlive():
self.cancel()
if current_thread() .getName()==self.getName():
try:
self.emit("interrupted")
Sys.thread_exit()
except RuntimeError as e :
print(str(self.getName()) + ' COULD NOT BE TERMINATED')
raise e

View File

@ -1 +1,3 @@

94
psr/const.py Normal file
View File

@ -0,0 +1,94 @@
# !/usr/bin/env python
# -*- coding: utf-8 -*-
# psr/const.py
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# software : Kirmah <http://kirmah.sourceforge.net/>
# version : 2.17
# date : 2013
# licence : GPLv3.0 <http://www.gnu.org/licenses/>
# author : a-Sansara <[a-sansara]at[clochardprod]dot[net]>
# copyright : pluie.org <http://www.pluie.org/>
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# This file is part of Kirmah.
#
# Kirmah is free software (free as in speech) : you can redistribute it
# and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of the License,
# or (at your option) any later version.
#
# Kirmah is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License
# along with Kirmah. If not, see <http://www.gnu.org/licenses/>.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~ module const ~~
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~ class Const ~~
class Const:
LOG_NEVER = -1
LOG_ALL = 0
LOG_BUILD = 1
LOG_PRIVATE = 2
LOG_DEBUG = 3
LOG_WARN = 4
LOG_UI = 5
LOG_DEFAULT = 6
LOG_APP = 7
CLZ_TIME = 'time'
CLZ_SEC = 'sec'
CLZ_CPID = 'cpid'
CLZ_PID = 'pid'
CLZ_IO = 'io'
CLZ_FUNC = 'func'
CLZ_CFUNC = 'cfunc'
CLZ_ARGS = 'args'
CLZ_DELTA = 'delta'
CLZ_ERROR = 'error'
CLZ_ERROR_PARAM = 'errorp'
CLZ_WARN = 'warn'
CLZ_WARN_PARAM = 'warnp'
CLZ_DEFAULT = 'default'
CLZ_TITLE = 'title'
CLZ_OK = 'ok'
CLZ_KO = 'ko'
CLZ_TASK = 'task'
CLZ_SYMBOL = 'symbol'
CLZ_HEAD_APP = 'headapp'
CLZ_HEAD_SEP = 'headsep'
CLZ_HEAD_KEY = 'headkey'
CLZ_HEAD_VAL = 'headval'
ERROR = 'ERROR'
WARN = 'WARNING'
OK = 'OK'
KO = 'KO'
LOG_LIM_ARG_LENGTH = 20
LF = """
"""
LF_STR = '\n'
UNIT_SHORT_B = 'B'
UNIT_SHORT_KIB = 'KiB'
UNIT_SHORT_MIB = 'MiB'
UNIT_SHORT_GIB = 'GiB'
UNIT_SHORT_TIB = 'TiB'
LINE_SEP_LEN = 100
LINE_SEP_CHAR = ''
const = Const()

View File

@ -1,31 +1,35 @@
#!/usr/bin/env python # !/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # psr/io.py
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# software : Kirmah <http://kirmah.sourceforge.net/> #
# version : 2.1 #
# date : 2013 #
# licence : GPLv3.0 <http://www.gnu.org/licenses/> #
# author : a-Sansara <http://www.a-sansara.net/> #
# copyright : pluie.org <http://www.pluie.org/> #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# This file is part of Kirmah. # software : Kirmah <http://kirmah.sourceforge.net/>
# version : 2.17
# date : 2013
# licence : GPLv3.0 <http://www.gnu.org/licenses/>
# author : a-Sansara <[a-sansara]at[clochardprod]dot[net]>
# copyright : pluie.org <http://www.pluie.org/>
# #
# Kirmah is free software (free as in speech) : you can redistribute it # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of the License,
# or (at your option) any later version.
# #
# Kirmah is distributed in the hope that it will be useful, but WITHOUT # This file is part of Kirmah.
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # Kirmah is free software (free as in speech) : you can redistribute it
# more details. # and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of the License,
# or (at your option) any later version.
#
# Kirmah is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License
# along with Kirmah. If not, see <http://www.gnu.org/licenses/>.
# #
# You should have received a copy of the GNU General Public License
# along with Kirmah. If not, see <http://www.gnu.org/licenses/>.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~ module io ~~
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~ class Io ~~ # ~~ class Io ~~
@ -36,7 +40,7 @@ class Io:
from gzip import compress as gzcompress, decompress as gzdecompress from gzip import compress as gzcompress, decompress as gzdecompress
from bz2 import compress as bzcompress, decompress as bzdecompress from bz2 import compress as bzcompress, decompress as bzdecompress
from errno import EEXIST from errno import EEXIST
from os import remove as removeFile, utime from os import remove as removeFile, utime, rename
from mmap import mmap, PROT_READ from mmap import mmap, PROT_READ
def __init__(self): def __init__(self):
@ -44,7 +48,8 @@ class Io:
@staticmethod @staticmethod
def read_in_chunks(f, chsize=1024, utf8=False): def read_in_chunks(f, chsize=1024, utf8=False):
"""Lazy function (generator) to read a file piece by piece. """Lazy function (generator) to read a file piece by piece in
Utf-8 bytes
Default chunk size: 1k.""" Default chunk size: 1k."""
c = 0 c = 0
while True: while True:
@ -66,6 +71,7 @@ class Io:
yield data, c yield data, c
c += 1 c += 1
@staticmethod @staticmethod
def read_utf8_chr(f, chsize=0, p=0): def read_utf8_chr(f, chsize=0, p=0):
"""""" """"""
@ -77,16 +83,19 @@ class Io:
if c > 0 : b += mmp.read(c) if c > 0 : b += mmp.read(c)
yield str(b,'utf-8') yield str(b,'utf-8')
@staticmethod @staticmethod
def is_utf8_continuation_byte(b): def is_utf8_continuation_byte(b):
"""""" """"""
return b >= 0x80 and b <= 0xbf return b >= 0x80 and b <= 0xbf
@staticmethod @staticmethod
def is_utf8_start_sequence(b): def is_utf8_start_sequence(b):
"""""" """"""
return (b >= 0x00 and b <= 0x7f) or (b>= 0xc2 and b <= 0xf4) return (b >= 0x00 and b <= 0x7f) or (b>= 0xc2 and b <= 0xf4)
@staticmethod @staticmethod
def count_utf8_continuation_bytes(b): def count_utf8_continuation_bytes(b):
"""""" """"""
@ -99,6 +108,7 @@ class Io:
else : c = 3 else : c = 3
return c return c
@staticmethod @staticmethod
def get_data(path, binary=False, remove=False): def get_data(path, binary=False, remove=False):
"""Get file content from `path` """Get file content from `path`
@ -111,13 +121,19 @@ class Io:
Io.removeFile(path) Io.removeFile(path)
return d return d
@staticmethod @staticmethod
def get_file_obj(path, binary=False, writing=False, update=False, truncate=False): def get_file_obj(path, binary=False, writing=False, update=False, truncate=False):
"""""" """"""
if not writing : if not writing :
f = open(path, mode='rt' if not binary else 'rb') f = open(path, mode='rt' if not binary else 'rb')
else : else :
#~ if not Io.file_exists(path): Io.set_data(path, '#') if update and not Io.file_exists(path):
if binary :
f = open(path, mode='wb')
else :
f = open(path, mode='wt', encoding='utf-8')
return f
m = ('w' if truncate else 'r')+('+' if update else '')+('b' if binary else 't') m = ('w' if truncate else 'r')+('+' if update else '')+('b' if binary else 't')
if not binary : if not binary :
f = open(path, mode=m, encoding='utf-8') f = open(path, mode=m, encoding='utf-8')
@ -125,27 +141,32 @@ class Io:
f = open(path, mode=m) f = open(path, mode=m)
return f return f
@staticmethod @staticmethod
def wfile(path, binary=True): def wfile(path, binary=True):
"""""" """"""
return Io.get_file_obj(path, binary, True, True, True) return Io.get_file_obj(path, binary, True, True, True)
@staticmethod @staticmethod
def ufile(path, binary=True): def ufile(path, binary=True):
"""""" """"""
return Io.get_file_obj(path, binary, True, True, False) return Io.get_file_obj(path, binary, True, True, False)
@staticmethod @staticmethod
def rfile(path, binary=True): def rfile(path, binary=True):
"""""" """"""
return Io.get_file_obj(path, binary) return Io.get_file_obj(path, binary)
@staticmethod @staticmethod
def set_data(path, content, binary=False): def set_data(path, content, binary=False):
"""""" """"""
with Io.wfile(path, binary) as f: with Io.wfile(path, binary) as f:
f.write(content) f.write(content)
@staticmethod @staticmethod
def readmmline(f, pos=0): def readmmline(f, pos=0):
"""""" """"""
@ -156,6 +177,7 @@ class Io:
pos = mmp.tell() pos = mmp.tell()
yield pos, Io.str(line[:-1]) yield pos, Io.str(line[:-1])
@staticmethod @staticmethod
def copy(fromPath, toPath): def copy(fromPath, toPath):
"""""" """"""
@ -165,16 +187,19 @@ class Io:
fo.write(fi.read()) fo.write(fi.read())
else : raise Exception('can\t copy to myself') else : raise Exception('can\t copy to myself')
@staticmethod @staticmethod
def bytes(sdata, encoding='utf-8'): def bytes(sdata, encoding='utf-8'):
"""""" """"""
return bytes(sdata,encoding) return bytes(sdata,encoding)
@staticmethod @staticmethod
def str(bdata, encoding='utf-8'): def str(bdata, encoding='utf-8'):
"""""" """"""
return str(bdata,encoding) if isinstance(bdata, bytes) else str(bdata) return str(bdata,encoding) if isinstance(bdata, bytes) else str(bdata)
@staticmethod @staticmethod
def printableBytes(bdata): def printableBytes(bdata):
"""""" """"""
@ -186,13 +211,13 @@ class Io:
hexv = [] hexv = []
for i in bdata[1:] : for i in bdata[1:] :
hexv.append(hex(i)[2:].rjust(2,'0')) hexv.append(hex(i)[2:].rjust(2,'0'))
#~ self.app.g.UI_TXTBUF.insert_at_cursor('\n')
data = ' '.join(hexv) data = ' '.join(hexv)
pass pass
else : else :
data = bdata data = bdata
return bdata return bdata
@staticmethod @staticmethod
def is_binary(filename): def is_binary(filename):
"""Check if given filename is binary.""" """Check if given filename is binary."""
@ -208,6 +233,7 @@ class Io:
f.close() f.close()
return done return done
@staticmethod @staticmethod
def file_exists(path): def file_exists(path):
"""""" """"""
@ -221,6 +247,6 @@ class Io:
@staticmethod @staticmethod
def touch(fname, times=None): def touch(fname, times=None):
"""""" """ only existing files """
if Io.file_exists(fname): if Io.file_exists(fname):
Io.utime(fname, times) Io.utime(fname, times)

123
psr/log.py Normal file
View File

@ -0,0 +1,123 @@
# !/usr/bin/env python
# -*- coding: utf-8 -*-
# psr/log.py
# # # # # # # # # # # # # # # # # # # # # # # #
#
# software : Kirmah <http://kirmah.sourceforge.net/>
# version : 2.17
# date : 2013
# licence : GPLv3.0 <http://www.gnu.org/licenses/>
# author : a-Sansara <[a-sansara]at[clochardprod]dot[net]>
# copyright : pluie.org <http://www.pluie.org/>
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# This file is part of Kirmah.
#
# Kirmah is free software (free as in speech) : you can redistribute it
# and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of the License,
# or (at your option) any later version.
#
# Kirmah is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License
# along with Kirmah. If not, see <http://www.gnu.org/licenses/>.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~ module log ~~
try :
from inspect import signature
except :
# < python 3.3
signature = None
pass
from psr.sys import Sys, Const
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~ Class Log ~~
class Log:
def __init__(self, level=Const.LOG_DEFAULT, debug=True, wtime=True):
self.debug = debug
self.level = level
self.wtime = wtime
def __call__(self, func, *args):
def wrapped_func(*args, **kwargs):
debug, wtime = self.debug and Sys.g.DEBUG and self.level >= Sys.g.LOG_LEVEL, self.wtime and Sys.g.LOG_TIME
self.debug_start_time = None if not wtime else Sys.datetime.now()
if debug :
# >= python 3.3
if signature is not None :
l = [p.name for p in signature(func).parameters.values()]
# < python 3.3
# !! BAD FIX !!
else :
l = ['self' if args[0].__class__ is not None else '']
n = args+tuple(kwargs.items())
if len(n)>0 and l[0] == 'self':
n = n[1:]
s = args[0].__class__.__name__ +'.'+func.__name__
else:
s = func.__name__
Log._write(s, self.debug_start_time, True, n)
f = func(*args, **kwargs)
if debug :
Log._write(s, self.debug_start_time, False)
return f
return wrapped_func
@staticmethod
def _formatArgs(args):
""""""
args = list(args)
for i,a in enumerate(args) :
if not (isinstance(a, str) or isinstance(a, bytes)):
a = str(a)
if len(a) > Sys.g.LOG_LIM_ARG_LENGTH :
args[i] = a[:Sys.g.LOG_LIM_ARG_LENGTH]+'...' if isinstance(a, str) else b'...'
args = str(args)[1:-1]
if args[-1:] == ',' : args = args[:-1]
return args
@staticmethod
def _write(sign, t=None, enter=True, args=''):
""""""
if Sys.g.DEBUG :
#~ DONT USE Sys.g.RLOCK
isChildProc = not Sys.g_is_main_proc()
bind_data = []
if t is not None :
bind_data += Sys.pdate(t.timetuple() if enter else Sys.datetime.now().timetuple(), isChildProc)
a, b, c, d, e = ('=> ' if enter else '<= '), '['+str(Sys.getpid())+']', ' '+sign+'(', Log._formatArgs(args), ') '
if not isChildProc :
Sys.print(a , Sys.CLZ_IO , False)
Sys.print(b , Sys.CLZ_PID if not isChildProc else Sys.CLZ_CPID, False)
Sys.print(c , Sys.CLZ_FUNC, False)
Sys.print(d , Sys.CLZ_ARGS, False)
Sys.print(e , Sys.CLZ_FUNC, False)
bind_data += [(a, Const.CLZ_IO),(b, Const.CLZ_CPID if isChildProc else Const.CLZ_PID),(c , Const.CLZ_CFUNC if isChildProc else Const.CLZ_FUNC),(d , Const.CLZ_ARGS),(e , Const.CLZ_CFUNC if isChildProc else Const.CLZ_FUNC)]
if not enter and t is not None :
bind_data += Sys.pdelta(t, '', isChildProc)
else :
bind_data += Sys.dprint(dbcall=isChildProc)
if isChildProc :
Sys.sendMainProcMsg(1, bind_data)
else :
Sys.wlog(bind_data)

View File

@ -1,153 +1,155 @@
#!/usr/bin/env python # !/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # psr/mproc.py
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# software : Kirmah <http://kirmah.sourceforge.net/> #
# version : 2.1 #
# date : 2013 #
# licence : GPLv3.0 <http://www.gnu.org/licenses/> #
# author : a-Sansara <http://www.a-sansara.net/> #
# copyright : pluie.org <http://www.pluie.org/> #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# This file is part of Kirmah. # software : Kirmah <http://kirmah.sourceforge.net/>
# version : 2.17
# date : 2013
# licence : GPLv3.0 <http://www.gnu.org/licenses/>
# author : a-Sansara <[a-sansara]at[clochardprod]dot[net]>
# copyright : pluie.org <http://www.pluie.org/>
# #
# Kirmah is free software (free as in speech) : you can redistribute it # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of the License,
# or (at your option) any later version.
# #
# Kirmah is distributed in the hope that it will be useful, but WITHOUT # This file is part of Kirmah.
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # Kirmah is free software (free as in speech) : you can redistribute it
# more details. # and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of the License,
# or (at your option) any later version.
#
# Kirmah is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License
# along with Kirmah. If not, see <http://www.gnu.org/licenses/>.
# #
# You should have received a copy of the GNU General Public License
# along with Kirmah. If not, see <http://www.gnu.org/licenses/>.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~ module mproc ~~ # ~~ module mproc ~~
from gi.repository.GObject import timeout_add from multiprocessing import Process, current_process, Pipe, Lock
from multiprocessing import Process, Lock, Queue from multiprocessing.connection import wait
from threading import current_thread
from psr.decorate import log from psr.sys import Sys, Const, init
from psr.sys import Sys from psr.log import Log
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~ class Ctrl ~~ # ~~ class Worker ~~
class Ctrl: class Worker:
""""""
@log @Log(Const.LOG_BUILD)
def __init__(self, nproc, npqueue_bind=None, task=None, *args, **kwargs ): def __init__(self, appname, debug, gui, color, loglvl, ppid, lock, id, wp, delay, task, *args, **kwargs):
def mptask(id, *args, **kwargs):
Sys.sendMainProcMsg(Manager.MSG_INIT, None)
otask = task(id=id, lock=lock, *args, **kwargs)
Sys.sendMainProcMsg(Manager.MSG_END, None)
return otask
init(appname, debug, ppid, color, loglvl)
Sys.g.WPIPE = wp
Sys.g.CPID = id
Sys.g.GUI = gui
Sys.g.RLOCK = lock
if delay : Sys.sleep(delay)
mptask(id, *args, **kwargs)
# don't directly close pipe 'cause of eventual loging
# pipe will auto close on terminating child process
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~ class Manager ~~
class Manager:
MSG_INIT = 0
MSG_PRINT = 1
MSG_DATA = 2
MSG_END = 3
TYPE_MSG = list(range(4))
K_ID = 0
K_TYPE = 1
K_DATA = 2
K_PROC = 0
K_PIPE = 1
checktime = None
@Log(Const.LOG_UI)
def __init__(self, task, nproc=2, delay=None, lock=None, *args, **kwargs):
"""""" """"""
self.plist = [] self.readers = []
self.queue = Queue() self.plist = []
self.npqueue = Queue() self.onstart_bind = None
self.nproc = nproc self.onrun_bind = None
self.done = False self.onend_bind = None
self.npq_bind = npqueue_bind for id in range(nproc):
if task is not None : r, w = Pipe(duplex=False)
self.bind_task(task, *args, **kwargs) self.readers.append(r)
# (process, wpipe)
p = Process(target=Worker, args=tuple([Sys.g.PRJ_NAME, Sys.g.DEBUG, Sys.g.GUI, Sys.g.COLOR_MODE, Sys.g.LOG_LEVEL, Sys.getpid(), lock, id, w, delay, task])+tuple(args), kwargs=kwargs)
self.plist.append((p, w))
def bind_task(self, task, *args, **kwargs): @Log(Const.LOG_APP)
def run(self, checktime=None, onstart_bind=None, onrun_bind=None, onend_bind=None):
self.checktime = checktime
self.onstart_bind = onstart_bind
self.onrun_bind = onrun_bind
self.onend_bind = onend_bind
for p, w in self.plist:
p.start()
w.close()
self.wait()
@Log(Const.LOG_DEBUG)
def wait(self):
"""""" """"""
if len(self.plist) > 0 : while self.readers:
del self.plist self.wait_childs()
self.plist = [] if self.checktime is not None : Sys.sleep(self.checktime)
del self.queue
self.queue = Queue()
del self.npqueue
self.npqueue = Queue()
def mptask(npqueue, mproc_pid, mproc_queue, *args, **kwargs):
def wrapped(*args, **kwargs):
"""Only queue need result"""
def orgtask(*args, **kwargs):
Sys.g.MAIN_PROC = None
Sys.g.NPQUEUE = npqueue
return task(*args, **kwargs)
mproc_queue.put_nowait([mproc_pid, orgtask(*args, **kwargs)])
return wrapped(*args, **kwargs)
for i in range(self.nproc):
self.plist.append(Process(target=mptask, args=tuple([self.npqueue,i,self.queue,i])+tuple(args), kwargs=kwargs))
@log def getcpid(self, id):
def start(self, timeout=100, delay=None, maincb=None, childcb=None):
"""""" """"""
if childcb is not None : self.on_child_end = childcb return self.plist[id][self.K_PROC].pid
if maincb is not None : self.on_end = maincb
if delay is None :
self.launch(timeout)
else :
timeout_add(delay, self.launch, timeout)
#~ @log
def launch(self, timeout): @Log(Const.LOG_ALL)
def wait_childs(self):
"""""" """"""
for p in self.plist:p.start() for r in wait(self.readers):
self.list_process() try:
self.tid = timeout_add(timeout, self.check) msg = r.recv()
return False except EOFError:
self.readers.remove(r)
else:
if len(msg)==3 and msg[self.K_TYPE] in self.TYPE_MSG :
#~ @log cpid = self.getcpid(msg[self.K_ID])
def list_process(self):
""""""
if Sys.g.DEBUG :
Sys.pcontent('current pid :'+str(Sys.getpid()))
Sys.pcontent('childs pid :')
for p in self.plist:
Sys.pcontent(str(p.pid))
#~ @log if msg[self.K_TYPE] == self.MSG_INIT :
def end_process(self): if hasattr(self.onstart_bind, '__call__'):
"""""" self.onstart_bind(msg[self.K_ID], cpid, msg[self.K_DATA])
if not self.queue.empty():
d = self.queue.get_nowait()
if d is not None :
self.on_child_end(d[0], d[1])
p = self.plist[d[0]]
if p.is_alive(): p.join()
#~ @log elif msg[self.K_TYPE] == self.MSG_PRINT :
def on_child_end(self, pid, data): if Sys.g.DEBUG :
"""""" if not Sys.g.GUI :
for item in msg[self.K_DATA] :
#~ @log Sys.print(item[0], Sys.clzdic[item[1]], False, True)
def end_task(self): Sys.dprint('')
"""""" #~ else :
self.queue.close() Sys.wlog(msg[self.K_DATA])
self.queue.join_thread()
self.done = True
self.on_end()
#~ @log
def on_end(self):
""""""
print(self)
print('all child process terminated')
#~ @log
def check(self):
""""""
leave = True
# child process log queue
if self.npq_bind is not None :
while not self.npqueue.empty():
d = self.npqueue.get_nowait()
if d is not None: self.npq_bind(d)
# ctrl queue
if not self.queue.empty():
self.end_process()
for p in self.plist: leave = leave and not p.is_alive()
if leave :
while not self.queue.empty():
self.end_process()
self.end_task()
else : leave = False
return not leave
elif msg[self.K_TYPE] == self.MSG_DATA :
if hasattr(self.onrun_bind, '__call__'):
self.onrun_bind(msg[self.K_ID], cpid, msg[self.K_DATA])
elif msg[self.K_TYPE] == self.MSG_END :
if hasattr(self.onend_bind, '__call__'):
self.onend_bind(msg[self.K_ID], cpid, msg[self.K_DATA])

View File

@ -1,36 +1,45 @@
#!/usr/bin/env python # !/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # psr/sys.py
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# software : Kirmah <http://kirmah.sourceforge.net/> #
# version : 2.1 #
# date : 2013 #
# licence : GPLv3.0 <http://www.gnu.org/licenses/> #
# author : a-Sansara <http://www.a-sansara.net/> #
# copyright : pluie.org <http://www.pluie.org/> #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# This file is part of Kirmah. # software : Kirmah <http://kirmah.sourceforge.net/>
# version : 2.17
# date : 2013
# licence : GPLv3.0 <http://www.gnu.org/licenses/>
# author : a-Sansara <[a-sansara]at[clochardprod]dot[net]>
# copyright : pluie.org <http://www.pluie.org/>
# #
# Kirmah is free software (free as in speech) : you can redistribute it # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of the License,
# or (at your option) any later version.
# #
# Kirmah is distributed in the hope that it will be useful, but WITHOUT # This file is part of Kirmah.
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # Kirmah is free software (free as in speech) : you can redistribute it
# more details. # and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of the License,
# or (at your option) any later version.
#
# Kirmah is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License
# along with Kirmah. If not, see <http://www.gnu.org/licenses/>.
# #
# You should have received a copy of the GNU General Public License
# along with Kirmah. If not, see <http://www.gnu.org/licenses/>.
from psr.io import Io # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~ module sys ~~
def init(name, debug): from psr.io import Io
Sys.g_init(name, debug) from psr.const import Const
Sys.g_set_main_proc() from threading import RLock
from multiprocessing import RLock as MPRLock
from queue import Queue
def init(name, debug, remote=False, color=True, loglvl=Const.LOG_DEFAULT):
Sys.g_init(name, debug, remote, color, loglvl)
Sys.g_set_main_proc(remote)
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~ class Sys ~~ # ~~ class Sys ~~
@ -38,86 +47,130 @@ def init(name, debug):
class Sys: class Sys:
"""""" """"""
from platform import system as getSysName from platform import system as getSysName
from os import system as sysCall, remove as removeFile, makedirs, sep, getpid from os import system as sysCall, remove as removeFile, makedirs, sep, getpid
from getpass import getuser as getUserLogin from getpass import getuser as getUserLogin
from time import strftime, mktime, time, localtime, sleep from time import strftime, mktime, time, localtime, sleep
from datetime import datetime from datetime import datetime
from sys import exit from sys import exit
from os.path import abspath, dirname, join, realpath, basename, getsize, isdir from os.path import abspath, dirname, join, realpath, basename, getsize, isdir, splitext
from math import log, floor, ceil from math import log, floor, ceil
from ast import literal_eval from _thread import exit as thread_exit
import builtins as g import builtins as g
ERROR = 'error' g.DEBUG = False
WARN = 'warn' g.LOG_LEVEL = Const.LOG_DEFAULT
NOTICE = 'notice' g.LOG_TIME = False
g.LOG_LIM_ARG_LENGTH = Const.LOG_LIM_ARG_LENGTH
g.QUIET = False
g.RLOCK = None
g.MPRLOCK = None
g.WPIPE = None
g.THREAD_CLI = None
g.UI_AUTO_SCROLL = True
g.CPID = None
g.SIGNAL_STOP = 0
g.SIGNAL_START = 1
g.SIGNAL_RUN = 2
g.GUI = False
g.GUI_PRINT_STDOUT = True
g.MPRLOCK = MPRLock()
g.DEBUG = False
def __init__(self): @staticmethod
def g_init(prjName, debug=True, remote=False, color=True, loglvl=Const.LOG_DEFAULT):
"""""" """"""
Sys.g.PRJ_NAME = prjName
Sys.g.DEBUG = debug
Sys.g.COLOR_MODE = color
Sys.g.LOG_LEVEL = loglvl
Sys.g.LOG_TIME = True
Sys.g.MAIN_PROC = None
Sys.g.RLOCK = RLock()
Sys.g.LOG_QUEUE = Queue() if Sys.g.GUI else None
@staticmethod @staticmethod
def g_init(prjName, debug=False, ui_trace=None, bind=None, color=True): def sendMainProcMsg(type, data):
Sys.g.PRJ_NAME = prjName """"""
Sys.g.DEBUG = debug if not Sys.g_is_main_proc() and Sys.g.WPIPE is not None and Sys.g.CPID is not None and type in range(4) :
Sys.g.LOG_FILE = '.'+prjName+'.log' Sys.g.WPIPE.send((Sys.g.CPID, type, data))
Sys.g.LOG_FO = Io.wfile(Sys.g.LOG_FILE, False) if bind is not None else None
#~ Sys.g.LOG_FO.write('# log '+prjName+'\n')
Sys.g.UI_TRACE = ui_trace
Sys.g.UI_BIND = bind
Sys.g.COLOR_MODE = color
#~ Sys.DEBUG = Debug(True,Debug.NOTICE)
from queue import Queue
Sys.g.QUEUE = Queue(0)
Sys.g.NPQUEUE = Queue(0)
Sys.g.MAIN_PROC = None
@staticmethod @staticmethod
def g_set_main_proc(): def g_set_main_proc(ppid=None):
Sys.g.MAIN_PROC = Sys.getpid() """"""
Sys.g.MAIN_PROC = Sys.getpid() if ppid is None or ppid is False else ppid
@staticmethod @staticmethod
def g_is_main_proc(): def g_is_main_proc():
""""""
try : try :
return Sys.g.MAIN_PROC is None return Sys.g.MAIN_PROC == Sys.getpid()
except : except :
return False return False
@staticmethod @staticmethod
def g_has_ui_bind(): def g_has_ui_trace():
""""""
try: try:
return Sys.g.UI_BIND is not None and Sys.g.DEBUG return Sys.g.GUI and Sys.g.DEBUG
except Exception as e: except Exception as e:
return False return False
@staticmethod
def cli_emit_progress(value=0):
""""""
if Sys.g.THREAD_CLI is not None : Sys.g.THREAD_CLI.progress(value)
@staticmethod
def is_cli_cancel(mprlock=None):
""""""
if mprlock is None :
return Sys.g.THREAD_CLI is not None and Sys.g.THREAD_CLI.cancelled
else :
with mprlock :
try:
print(Sys.g.THREAD_CLI)
print(Sys.g.THREAD_CLI.cancelled)
except:
pass
return Sys.g.THREAD_CLI is not None and Sys.g.THREAD_CLI.cancelled
@staticmethod @staticmethod
def isUnix(): def isUnix():
"""""" """"""
return not Sys.getSysName() == 'Windows' return not Sys.getSysName() == 'Windows'
@staticmethod @staticmethod
def clear(): def clear():
return Sys.sysCall('cls' if not Sys.isUnix() else 'clear') return Sys.sysCall('cls' if not Sys.isUnix() else 'clear')
@staticmethod @staticmethod
def mkdir_p(path): def mkdir_p(path):
"""""" """"""
try: try:
Sys.makedirs(path) Sys.makedirs(path)
except OSError as e: # Python >2.5 except OSError as e:
if e.errno == Io.EEXIST: if e.errno == Io.EEXIST:
pass pass
else: raise else: raise
@staticmethod @staticmethod
def readableBytes(b, p=2): def readableBytes(b, p=2):
"""Give a human representation of bytes size `b` """Give a human representation of bytes size `b`
:Returns: `str` :Returns: `str`
""" """
units = ['B', 'KiB', 'MiB', 'GiB', 'TiB']; units = [Const.UNIT_SHORT_B, Const.UNIT_SHORT_KIB, Const.UNIT_SHORT_MIB, Const.UNIT_SHORT_GIB, Const.UNIT_SHORT_TIB];
b = max(b,0); b = max(b,0);
if b == 0 : lb= 0 if b == 0 : lb= 0
else : lb = Sys.log(b) else : lb = Sys.log(b)
@ -128,11 +181,19 @@ class Sys:
#b /= (1 << (10 * p)) #b /= (1 << (10 * p))
return str(round(b, 1))+' '+units[p] return str(round(b, 1))+' '+units[p]
@staticmethod
def getFileExt(fromPath):
""""""
return Sys.splitext(fromPath)
@staticmethod @staticmethod
def getFileSize(path): def getFileSize(path):
"""""" """"""
return Sys.readableBytes(Sys.getsize(path)) return Sys.readableBytes(Sys.getsize(path))
@staticmethod @staticmethod
def getPrintableBytes(bdata): def getPrintableBytes(bdata):
"""""" """"""
@ -150,6 +211,7 @@ class Sys:
data = bdata data = bdata
return data return data
@staticmethod @staticmethod
def getHexaBytes(bdata): def getHexaBytes(bdata):
"""""" """"""
@ -163,10 +225,22 @@ class Sys:
data = bdata data = bdata
return data return data
@staticmethod @staticmethod
# never log this func -> maximum recursion
def wlog(data): def wlog(data):
"""""" """"""
Sys.g.LOG_FO.write(str(data)+'\n') if not Sys.is_cli_cancel():
if Sys.g.LOG_QUEUE is not None :
try :
Sys.g.LOG_QUEUE.put(data)
Sys.cli_emit_progress()
except Exception as e:
Sys.pwarn((('wlog exception ',(str(e),Sys.CLZ_ERROR_PARAM), ' !'),), True)
else :
Sys.g.THREAD_CLI.stop()
@staticmethod @staticmethod
def print(data, colors, endLF=True, endClz=True): def print(data, colors, endLF=True, endClz=True):
@ -180,96 +254,89 @@ class Sys:
if data is None: data = '' if data is None: data = ''
if endClz : data += Sys.Clz._uOFF if endClz : data += Sys.Clz._uOFF
if Sys.g.COLOR_MODE : if Sys.g.COLOR_MODE :
Sys.dprint(eval('Sys.Clz._u'+'+Sys.Clz._u'.join(tokens))+data,end=ev, dbcall=True) Sys.dprint(eval('Sys.Clz._u'+'+Sys.Clz._u'.join(tokens))+data,end=ev, dbcall=False)
else : else :
Sys.dprint(data,end=ev, dbcall=True) Sys.dprint(data,end=ev, dbcall=False)
else : else :
if Sys.g.COLOR_MODE : Sys.Clz.setColor(eval('Sys.Clz._w'+'|Sys.Clz._w'.join(tokens))) if Sys.g.COLOR_MODE : Sys.Clz.setColor(eval('Sys.Clz._w'+'|Sys.Clz._w'.join(tokens)))
Sys.dprint(data,end=ev, dbcall=True) Sys.dprint(data,end=ev, dbcall=False)
stdout.flush() stdout.flush()
if endClz and Sys.g.COLOR_MODE : Sys.Clz.setColor(Sys.Clz._wOFF) if endClz and Sys.g.COLOR_MODE : Sys.Clz.setColor(Sys.Clz._wOFF)
#~ else:
#~ self.dprint(data,end=ev)
@staticmethod @staticmethod
def dprint(d='',end='\n', dbcall=False): def dprint(d='',end=Const.LF, dbcall=False):
"""""" """"""
print(d,end=end) if not dbcall :
if Sys.g_has_ui_bind(): if not Sys.g.GUI or Sys.g.GUI_PRINT_STDOUT :
bdata = [(d,'default')] with Sys.g.RLOCK :
if not dbcall : if not Sys.g.QUIET : print(d,end=end)
Sys.wlog(bdata)
else : bdata = [(d,Const.CLZ_DEFAULT)]
return bdata return bdata
@staticmethod @staticmethod
def eprint(d='', label='warn', dbcall=False): def eprint(d='', label=Const.WARN, dbcall=False):
"""""" """"""
c = Sys.CLZ_ERROR if label is Sys.ERROR else Sys.CLZ_WARN c = Sys.CLZ_ERROR if label is Const.ERROR else Sys.CLZ_WARN
Sys.print(' '+label+' : ', c, False, False) Sys.print(' '+label+' : ', c, False, False)
Sys.print(str(d)+' ', c, True, True) Sys.print(str(d)+' ', c, True, True)
if Sys.g_has_ui_bind():
bdata = [(label+' : ' , label),(str(d)+' ', label)] bdata = [(label+' : ' , label),(str(d)+' ', label)]
if not dbcall : return bdata
Sys.wlog(bdata)
else :
return bdata
@staticmethod @staticmethod
def pdate(t, dbcall = False): def pdate(t, dbcall = False):
"""""" """"""
t, s = Sys.strftime('%H:%M',t), Sys.strftime(':%S ',t) t, s = Sys.strftime('%H:%M',t), Sys.strftime(':%S ',t)
Sys.print(t , Sys.CLZ_TIME, False) if not dbcall :
Sys.print(s , Sys.CLZ_SEC , False) Sys.print(t , Sys.CLZ_TIME, False)
if Sys.g_has_ui_bind(): Sys.print(s , Sys.CLZ_SEC , False)
bdata = [(t , 'time'),(s , 'sec')]
if not dbcall : bdata = [(t , Const.CLZ_TIME),(s , Const.CLZ_SEC)]
Sys.wlog(bdata) return bdata
else :
return bdata
@staticmethod @staticmethod
def pkval(label, value, pad=40, dbcall= False): def pkval(label, value, pad=40, dbcall= False):
"""""" """"""
l, v = label.rjust(pad,' '), ' '+str(value) l, v = label.rjust(pad,' '), ' '+str(value)
Sys.print(l, Sys.CLZ_SEC , False) if not dbcall :
Sys.print(v, Sys.CLZ_TIME , True) Sys.print(l, Sys.CLZ_SEC , False)
if Sys.g_has_ui_bind(): Sys.print(v, Sys.CLZ_TIME , True)
bdata = [(l, 'sec'),(v, 'time')]
if not dbcall : bdata = [(l, Const.CLZ_SEC),(v, Const.CLZ_TIME)]
Sys.wlog(bdata) return bdata
else :
return bdata
@staticmethod @staticmethod
def pdelta(t, label='', dbcall= False): def pdelta(t, label='', dbcall= False):
"""""" """"""
if len(label)>0 : Sys.print(label+' ', Sys.CLZ_IO, False) if len(label)>0 and not dbcall : Sys.print(label+' ', Sys.CLZ_IO, False)
v = ''.join(["{:.5f}".format(Sys.time()-(Sys.mktime(t.timetuple())+1e-6*t.microsecond)),' s']) v = ''.join(['{:.5f}'.format(Sys.time()-(Sys.mktime(t.timetuple())+1e-6*t.microsecond)),' s'])
Sys.print(v, Sys.CLZ_DELTA) if not dbcall :
if Sys.g_has_ui_bind(): Sys.print(v, Sys.CLZ_DELTA)
bdata = []
if len(label)>0 : bdata = []
bdata.append((label+' ', 'io')) if len(label)>0 :
bdata.append((v, 'delta')) bdata.append((label+' ', Const.CLZ_IO))
if not dbcall : bdata.append((v, Const.CLZ_DELTA))
Sys.wlog(bdata) return bdata
else :
return bdata
@staticmethod @staticmethod
def pcontent(content, color=None, bcolor='default', dbcall= False): def pcontent(content, color=None, bcolor=Const.CLZ_DEFAULT, dbcall= False):
"""""" """"""
Sys.print(content, Sys.CLZ_SEC if color is None else color) if not dbcall : Sys.print(content, Sys.CLZ_SEC if color is None else color)
if Sys.g_has_ui_bind():
bdata = [(content, bcolor)] bdata = [(content, bcolor)]
if not dbcall : return bdata
Sys.wlog(bdata)
else :
return bdata
@staticmethod @staticmethod
def pwarn(data, isError=False, length=120): def pwarn(data, isError=False, length=Const.LINE_SEP_LEN, dbcall=False):
""" data struct : """ data struct :
( # line0 ( # line0
'simple line', # LF 'simple line', # LF
@ -280,34 +347,60 @@ class Sys:
'other simple line ' 'other simple line '
) )
""" """
w = ' WARNING : ' if not isError else ' ERROR : ' w = ' '+(Const.WARN if not isError else Const.ERROR)+' : '
bg = Sys.Clz.bg5 if not isError else Sys.Clz.bg1 clz = Sys.CLZ_WARN if not isError else Sys.CLZ_ERROR
clzp = Sys.CLZ_WARN_PARAM if not isError else Sys.CLZ_ERROR_PARAM
uiclz = Const.CLZ_WARN if not isError else Const.CLZ_ERROR
uiclzp = Const.CLZ_WARN_PARAM if not isError else Const.CLZ_ERROR_PARAM
Sys.print(w, bg+Sys.Clz.fgb3, False, False) if not dbcall : Sys.print(w, clzp, False, False)
bdata = []
if Sys.g.DEBUG :
bdata.append((w, uiclzp))
for i, line in enumerate(data) : for i, line in enumerate(data) :
if i > 0 : if i > 0 :
Sys.print(' '*len(w), bg+Sys.Clz.fgb7, False, False) if not dbcall : Sys.print(' '*len(w), clz, False, False)
if Sys.g.DEBUG :
bdata.append((' '*len(w), uiclz))
if isinstance(line,str) : if isinstance(line,str) :
Sys.print(line.ljust(length-len(w),' '), bg+Sys.Clz.fgb7, True, True) s = line.ljust(length-len(w),' ')
if not dbcall : Sys.print(s, clz, True, True)
if Sys.g.DEBUG :
bdata.append((s, uiclz))
Sys.wlog(bdata)
bdata = []
else : else :
sl = 0 sl = 0
for p in line : for p in line :
if isinstance(p,str) : if isinstance(p,str) :
Sys.print(p, bg+Sys.Clz.fgb7, False, False) Sys.print(p, clz, False, False)
bdata.append((p, uiclz))
sl += len(p) sl += len(p)
else : else :
Sys.print(p[0], bg+p[1], False, False) Sys.print(p[0], clzp+p[1], False, False)
bdata.append((p[0], uiclzp))
sl += len(p[0]) sl += len(p[0])
Sys.print(' '.ljust(length-sl-len(w),' '), bg+Sys.Clz.fgb7, True, True) s = ' '.ljust(length-sl-len(w),' ')
if not dbcall : Sys.print(s, clz, True, True)
if Sys.g.DEBUG :
bdata.append((s, uiclz))
Sys.wlog(bdata)
bdata = []
if not dbcall : Sys.dprint()
if Sys.g.DEBUG : Sys.wlog([('',Const.CLZ_DEFAULT)])
Sys.dprint()
@staticmethod @staticmethod
def _psymbol(ch): def _psymbol(ch, done=True):
"""""" """"""
Sys.print(' ', Sys.Clz.fgb7, False, False) Sys.print(' ', Sys.CLZ_DEFAULT, False, False)
Sys.print(' '+ch+' ', Sys.Clz.BG4+Sys.Clz.fgb7, False, True) Sys.print(' '+ch+' ', Sys.CLZ_HEAD_APP if done else Sys.CLZ_SYMBOL, False, True)
Sys.print(' ', Sys.Clz.fgb7, False, True) Sys.print(' ', Sys.CLZ_DEFAULT, False, True)
bdata = [(' ', Const.CLZ_DEFAULT),(' '+ch+' ', Const.CLZ_HEAD_APP if done else Sys.CLZ_SYMBOL),(' ', Const.CLZ_DEFAULT)]
return bdata
@staticmethod @staticmethod
def pask(ask, yesValue='yes', noValue='no'): def pask(ask, yesValue='yes', noValue='no'):
@ -322,25 +415,39 @@ class Sys:
Sys.dprint() Sys.dprint()
return answer.lower()==yesValue.lower() return answer.lower()==yesValue.lower()
@staticmethod @staticmethod
def pstep(title, stime, done, exitOnFailed=True, length=120): def pstep(title, stime, done, noelf=False, exitOnFailed=True, length=100):
"""""" """"""
if stime is not None : if stime is not None :
v = ' ('+''.join(["{:.5f}".format(Sys.time()-(Sys.mktime(stime.timetuple())+1e-6*stime.microsecond)),' s'])+')' v = ' ('+''.join(['{:.5f}'.format(Sys.time()-(Sys.mktime(stime.timetuple())+1e-6*stime.microsecond)),' s'])+')'
else : v = '' else : v = ''
Sys._psymbol('¤') bdata = Sys._psymbol('¤')
Sys.print(title, Sys.Clz.fgB7, False, False) Sys.print(title, Sys.CLZ_TITLE, False, False)
Sys.print(v+' '.ljust(length-len(title)-20-len(v), ' '),Sys.CLZ_DELTA, False, True) Sys.print(v+' '.ljust(length-len(title)-20-len(v), ' '),Sys.CLZ_DELTA, False, True)
if done : if done :
Sys.print(' == OK == ', Sys.Clz.bg2+Sys.Clz.fgb7) Sys.print(' == '+Const.OK+' == ', Sys.CLZ_OK)
else : else :
Sys.print(' == KO == ', Sys.Clz.bg1+Sys.Clz.fgb7) Sys.print(' == '+Const.KO+' == ', Sys.CLZ_KO)
Sys.dprint()
bdata = bdata + [(title, Const.CLZ_TITLE),(v+' '.ljust(length-len(title)-20-len(v)), Const.CLZ_DELTA),(' == '+(Const.OK if done else Const.KO)+' == ', (Const.CLZ_OK if done else Const.CLZ_KO))]
Sys.wlog(bdata)
if not noelf :
Sys.wlog(Sys.dprint())
if exitOnFailed and not done: if exitOnFailed and not done:
#~ Sys.dprint(' '.ljust(length-14, ' '),end='') Sys.exit(1)
#~ Sys.print(' == EXIT == ', Sys.Clz.bg1+Sys.Clz.fgb7)
#~ Sys.dprint()
Sys.exit(1) @staticmethod
def ptask(title='Processing, please wait'):
if not Sys.g.QUIET :
s = ' '+title+'...'
Sys.print(s, Sys.CLZ_TASK )
Sys.wlog([(s, Const.CLZ_TASK)])
Sys.wlog(Sys.dprint())
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~ class Coloriz ~~ # ~~ class Coloriz ~~
@ -361,7 +468,7 @@ class Coloriz:
"""""" """"""
_wOFF = None _wOFF = None
"""""" """"""
_LF = '\n' _LF = Const.LF
"""""" """"""
OFF = _MARKER+_MARKER[0]+'OFF'+_SEP+_MARKER OFF = _MARKER+_MARKER[0]+'OFF'+_SEP+_MARKER
"""""" """"""
@ -382,23 +489,17 @@ class Coloriz:
self.BG0 -> self.BG7 self.BG0 -> self.BG7
default colors : default colors :
self.OFF self.OFF
usage :
pc = PColor()
pc.print('%smon label%s:%sma value%s' % (pc.BG4+pc.fgN7, pc.OFF+pc.fgn1, pc.fgb4, pc.OFF))
""" """
global Sys
if not Sys.isUnix(): if not Sys.isUnix():
j = 0 j = 0
for i in (0,4,2,6,1,5,3,7): for i in (0,4,2,6,1,5,3,7):
exec('self._wf%i = 0x000%i' % (i,j) + '\nself._wb%i = 0x00%i0' % (i,j) + '\nself._wF%i = 0x000%i | self._wFH' % (i,j) + '\nself._wB%i = 0x00%i0 | self._wBH' % (i,j)) exec('self._wf%i = 0x000%i' % (i,j) + Const.LF+'self._wb%i = 0x00%i0' % (i,j) + Const.LF+'self._wF%i = 0x000%i | self._wFH' % (i,j) + Const.LF+'self._wB%i = 0x00%i0 | self._wBH' % (i,j))
# normal eq bold # normal eq bold
exec('self._wn%i = self._wf%i' % (i,i)) exec('self._wn%i = self._wf%i' % (i,i))
# normal high intensity eq bold high intensity # normal high intensity eq bold high intensity
exec('self._wN%i = self._wF%i' % (i,i)) exec('self._wN%i = self._wF%i' % (i,i))
j += 1 j += 1
import impra.w32color as w32cons import psr.w32color as w32cons
self._wOFF = w32cons.get_text_attr() self._wOFF = w32cons.get_text_attr()
self._wOFFbg = self._wOFF & 0x0070 self._wOFFbg = self._wOFF & 0x0070
self._wOFFfg = self._wOFF & 0x0007 self._wOFFfg = self._wOFF & 0x0007
@ -424,13 +525,38 @@ class Coloriz:
exec('self.BG%i = self._MARKER + self._MARKER[0] + "B%i" + self._SEP + self._MARKER' % (i,i)) exec('self.BG%i = self._MARKER + self._MARKER[0] + "B%i" + self._SEP + self._MARKER' % (i,i))
if True or Sys.isUnix() : exec('self._uB%i = "\\033[0;10%im"' % (i,i)) if True or Sys.isUnix() : exec('self._uB%i = "\\033[0;10%im"' % (i,i))
Sys.Clz = Coloriz() Sys.Clz = Coloriz()
Sys.CLZ_TIME = Sys.Clz.fgN2+Sys.Clz.bg0 Sys.CLZ_TIME = Sys.Clz.fgN2+Sys.Clz.bg0
Sys.CLZ_SEC = Sys.Clz.fgb7+Sys.Clz.bg0 Sys.CLZ_SEC = Sys.Clz.fgb7+Sys.Clz.bg0
Sys.CLZ_IO = Sys.Clz.fgB1+Sys.Clz.bg0 Sys.CLZ_PID = Sys.Clz.fgb1+Sys.Clz.bg0
Sys.CLZ_FUNC = Sys.Clz.fgb3+Sys.Clz.bg0 Sys.CLZ_PPID = Sys.Clz.fgb1+Sys.Clz.bg0
Sys.CLZ_ARGS = Sys.Clz.fgn7+Sys.Clz.bg0 Sys.CLZ_CPID = Sys.Clz.fgb7+Sys.Clz.bg0
Sys.CLZ_DELTA = Sys.Clz.fgN4+Sys.Clz.bg0 Sys.CLZ_IO = Sys.Clz.fgB1+Sys.Clz.bg0
Sys.CLZ_ERROR = Sys.Clz.fgb7+Sys.Clz.bg1 Sys.CLZ_FUNC = Sys.Clz.fgb3+Sys.Clz.bg0
Sys.CLZ_WARN = Sys.Clz.fgb7+Sys.Clz.bg5 Sys.CLZ_CFUNC = Sys.Clz.fgb3+Sys.Clz.bg0
Sys.CLZ_DEFAULT = Sys.Clz.fgb7+Sys.Clz.bg0 Sys.CLZ_ARGS = Sys.Clz.fgn7+Sys.Clz.bg0
Sys.CLZ_DELTA = Sys.Clz.fgN4+Sys.Clz.bg0
Sys.CLZ_TASK = Sys.Clz.fgB2+Sys.Clz.bg0
Sys.CLZ_ERROR = Sys.Clz.fgb7+Sys.Clz.bg1
Sys.CLZ_ERROR_PARAM = Sys.Clz.fgb3+Sys.Clz.bg1
Sys.CLZ_WARN = Sys.Clz.fgb7+Sys.Clz.bg5
Sys.CLZ_WARN_PARAM = Sys.Clz.fgb3+Sys.Clz.bg5
Sys.CLZ_DEFAULT = Sys.Clz.fgb7+Sys.Clz.bg0
Sys.CLZ_TITLE = Sys.Clz.fgB7+Sys.Clz.bg0
Sys.CLZ_SYMBOL = Sys.Clz.BG4+Sys.Clz.fgB7
Sys.CLZ_OK = Sys.Clz.bg2+Sys.Clz.fgb7
Sys.CLZ_KO = Sys.Clz.bg1+Sys.Clz.fgb7
Sys.CLZ_HELP_PRG = Sys.Clz.fgb7
Sys.CLZ_HELP_CMD = Sys.Clz.fgB3
Sys.CLZ_HELP_PARAM = Sys.Clz.fgB1
Sys.CLZ_HELP_ARG = Sys.Clz.fgB3
Sys.CLZ_HELP_COMMENT = Sys.Clz.fgn7
Sys.CLZ_HELP_ARG_INFO = Sys.Clz.fgb7
Sys.CLZ_HELP_DESC = Sys.Clz.fgN1
Sys.CLZ_HEAD_APP = Sys.Clz.BG4+Sys.Clz.fgB7
Sys.CLZ_HEAD_KEY = Sys.Clz.fgB3
Sys.CLZ_HEAD_VAL = Sys.Clz.fgB4
Sys.CLZ_HEAD_SEP = Sys.Clz.fgB0
Sys.CLZ_HEAD_LINE = Sys.Clz.fgN0
Sys.clzdic = { Const.CLZ_TASK : Sys.CLZ_TASK, Const.CLZ_SYMBOL: Sys.CLZ_SYMBOL, Const.CLZ_TIME : Sys.CLZ_TIME, Const.CLZ_SEC : Sys.CLZ_SEC, Const.CLZ_IO : Sys.CLZ_IO, Const.CLZ_CPID : Sys.CLZ_CPID, Const.CLZ_PID : Sys.CLZ_PID, Const.CLZ_CFUNC : Sys.CLZ_CFUNC, Const.CLZ_FUNC : Sys.CLZ_FUNC, Const.CLZ_ARGS : Sys.CLZ_ARGS, Const.CLZ_DELTA : Sys.CLZ_DELTA, Const.CLZ_ERROR : Sys.CLZ_ERROR, Const.CLZ_WARN : Sys.CLZ_WARN, Const.CLZ_ERROR_PARAM : Sys.CLZ_ERROR_PARAM, Const.CLZ_WARN_PARAM : Sys.CLZ_WARN_PARAM, Const.CLZ_DEFAULT : Sys.CLZ_DEFAULT }

71
psr/w32color.py Normal file
View File

@ -0,0 +1,71 @@
# !/usr/bin/env python
# -*- coding: utf-8 -*-
# psr/w32color.py
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# software : Kirmah <http://kirmah.sourceforge.net/>
# version : 2.17
# date : 2013
# licence : GPLv3.0 <http://www.gnu.org/licenses/>
# author : a-Sansara <[a-sansara]at[clochardprod]dot[net]>
# copyright : pluie.org <http://www.pluie.org/>
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# This file is part of Kirmah.
#
# Kirmah is free software (free as in speech) : you can redistribute it
# and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of the License,
# or (at your option) any later version.
#
# Kirmah is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License
# along with Kirmah. If not, see <http://www.gnu.org/licenses/>.
#
"""
Colors text in console mode application (win32).
Uses ctypes and Win32 methods SetConsoleTextAttribute and
GetConsoleScreenBufferInfo.
"""
from ctypes import windll, Structure as Struct, c_short as SHORT, c_ushort as WORD, byref
class Coord(Struct):
"""struct in wincon.h."""
_fields_ = [("X", SHORT),("Y", SHORT)]
class SmallRect(Struct):
"""struct in wincon.h."""
_fields_ = [("Left", SHORT),("Top", SHORT),("Right", SHORT),("Bottom", SHORT)]
class ConsoleScreenBufferInfo(Struct):
"""struct in wincon.h."""
_fields_ = [("dwSize", Coord),("dwCursorPosition", Coord),("wAttributes", WORD),("srWindow", SmallRect),("dwMaximumWindowSize", Coord)]
# winbase.h
STD_INPUT_HANDLE = -10
STD_OUTPUT_HANDLE = -11
STD_ERROR_HANDLE = -12
stdout_handle = windll.kernel32.GetStdHandle(STD_OUTPUT_HANDLE)
SetConsoleTextAttribute = windll.kernel32.SetConsoleTextAttribute
GetConsoleScreenBufferInfo = windll.kernel32.GetConsoleScreenBufferInfo
def get_text_attr():
"""Returns the character attributes (colors) of the console screen
buffer."""
csbi = ConsoleScreenBufferInfo()
GetConsoleScreenBufferInfo(stdout_handle, byref(csbi))
return csbi.wAttributes
def set_text_attr(color):
"""Sets the character attributes (colors) of the console screen
buffer. Color is a combination of foreground and background color,
foreground and background intensity."""
SetConsoleTextAttribute(stdout_handle, color)

12
resources/kirmah.desktop Normal file
View File

@ -0,0 +1,12 @@
[Desktop Entry]
Name=Kirmah
Comment=Encryption with symmetric-key algorithm Kirmah
Version=0.34
Icon=kirmah
Exec=kirmah
Terminal=false
Type=Application
StartupNotify=false
MimeType=
Categories=System;

674
resources/kirmah/LICENSE Executable file
View File

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

View File

@ -0,0 +1,974 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
<object class="GtkAdjustment" id="adjustment1">
<property name="lower">512</property>
<property name="upper">4096</property>
<property name="value">1024</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustment2">
<property name="upper">100</property>
<property name="value">100</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustment3">
<property name="lower">2</property>
<property name="upper">8</property>
<property name="value">2</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkFileFilter" id="filefilter1">
<patterns>
<pattern>*.key</pattern>
</patterns>
</object>
<object class="GtkFileFilter" id="filefilter2">
<patterns>
<pattern>*.kmh</pattern>
<pattern>*</pattern>
</patterns>
</object>
<object class="GtkFileFilter" id="filefilter3">
<patterns>
<pattern>*.*</pattern>
</patterns>
</object>
<object class="GtkWindow" id="window1">
<property name="can_focus">False</property>
<property name="window_position">center</property>
<property name="default_width">1024</property>
<property name="icon">../../pixmaps/kirmah/kirmah.png</property>
<child>
<object class="GtkBox" id="box1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkMenuBar" id="menubar1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkMenuItem" id="menuitem1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">_Fichier</property>
<property name="use_underline">True</property>
<child type="submenu">
<object class="GtkMenu" id="menu1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkSeparatorMenuItem" id="separatormenuitem1">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="imagemenuitem5">
<property name="label">gtk-quit</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
<signal name="activate" handler="onDeleteWindow" swapped="no"/>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkMenuItem" id="menuitem4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Aid_e</property>
<property name="use_underline">True</property>
<child type="submenu">
<object class="GtkMenu" id="menu3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImageMenuItem" id="imagemenuitem10">
<property name="label">gtk-about</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
<signal name="activate" handler="on_about" swapped="no"/>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkFrame" id="frame1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">10</property>
<property name="margin_right">10</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property>
<property name="label_xalign">0</property>
<child>
<object class="GtkAlignment" id="alignment1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="top_padding">5</property>
<property name="bottom_padding">5</property>
<property name="left_padding">30</property>
<property name="right_padding">13</property>
<child>
<object class="GtkBox" id="box3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox" id="box4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">20</property>
<child>
<object class="GtkRadioButton" id="radiobutton1">
<property name="label" translatable="yes">Default</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
<signal name="pressed" handler="on_default_key" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="radiobutton2">
<property name="label" translatable="yes">Existing</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
<property name="group">radiobutton1</property>
<signal name="pressed" handler="on_existing_key" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="radiobutton3">
<property name="label" translatable="yes">New</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
<property name="group">radiobutton1</property>
<signal name="pressed" handler="on_new_key" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box5">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="xpad">5</property>
<property name="label" translatable="yes">length :</property>
<property name="width_chars">12</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="spinbutton1">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="max_length">5</property>
<property name="invisible_char">●</property>
<property name="width_chars">6</property>
<property name="progress_fraction">1</property>
<property name="progress_pulse_step">1</property>
<property name="placeholder_text">1024</property>
<property name="input_purpose">number</property>
<property name="adjustment">adjustment1</property>
<property name="climb_rate">10</property>
<property name="numeric">True</property>
<property name="update_policy">if-valid</property>
<signal name="value-changed" handler="on_keylen_changed" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">4</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkSeparator" id="separator1">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">10</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">path :</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkFileChooserButton" id="filechooserbutton1">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="do_overwrite_confirmation">True</property>
<property name="filter">filefilter1</property>
<property name="show_hidden">True</property>
<property name="width_chars">20</property>
<signal name="file-set" handler="on_new_file_key" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="padding">6</property>
<property name="position">4</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box10">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="label10">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="xpad">4</property>
<property name="label" translatable="yes">mark :</property>
<property name="width_chars">12</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="entry1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="invisible_char">●</property>
<property name="width_chars">62</property>
<property name="progress_fraction">0.039999999105930328</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="padding">6</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">4</property>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">&lt;b&gt;Key&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkFrame" id="frame2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">10</property>
<property name="margin_right">10</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property>
<property name="label_xalign">0</property>
<child>
<object class="GtkAlignment" id="alignment2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="top_padding">5</property>
<property name="bottom_padding">5</property>
<property name="left_padding">30</property>
<property name="right_padding">13</property>
<child>
<object class="GtkBox" id="box6">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">7</property>
<child>
<object class="GtkBox" id="box7">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkLabel" id="label5">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">mode :</property>
<property name="width_chars">20</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">10</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label8">
<property name="width_request">60</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">10</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">encrypt</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkSwitch" id="switch1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<signal name="notify" handler="on_switch_mode" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">5</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label9">
<property name="width_request">55</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">decrypt</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label15">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">50</property>
<property name="label" translatable="yes">format :</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label13">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">20</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">as text</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">5</property>
</packing>
</child>
<child>
<object class="GtkSwitch" id="switch2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<signal name="notify" handler="on_switch_format" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">5</property>
<property name="position">6</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label14">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">binary</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">7</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label16">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">40</property>
<property name="label" translatable="yes">logging level : </property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">8</property>
</packing>
</child>
<child>
<object class="GtkComboBoxText" id="comboboxtext2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="entry_text_column">0</property>
<property name="id_column">1</property>
<items>
<item translatable="yes">DISABLED</item>
<item translatable="yes">LOG_ALL</item>
<item translatable="yes">LOG_DEBUG</item>
<item translatable="yes">LOG_WARN</item>
<item translatable="yes">LOG_UI</item>
<item translatable="yes">LOG_DEFAULT</item>
</items>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">9</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box11">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkCheckButton" id="checkbutton1">
<property name="label" translatable="yes">multiprocessing : </property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="margin_left">29</property>
<property name="xalign">1</property>
<property name="draw_indicator">True</property>
<signal name="pressed" handler="on_multiproc_changed" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">10</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="spinbutton2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="margin_left">6</property>
<property name="invisible_char">●</property>
<property name="width_chars">2</property>
<property name="placeholder_text">2</property>
<property name="adjustment">adjustment3</property>
<property name="numeric">True</property>
<property name="wrap">True</property>
<signal name="value-changed" handler="on_nproc_changed" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="checkbutton2">
<property name="label" translatable="yes">mix mode</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="margin_left">30</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
<signal name="pressed" handler="on_mixdata_changed" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="checkbutton4">
<property name="label" translatable="yes">random mode</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="margin_left">30</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
<signal name="pressed" handler="on_randomdata_changed" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label12">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">30</property>
<property name="label" translatable="yes">compression : </property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">6</property>
</packing>
</child>
<child>
<object class="GtkComboBoxText" id="comboboxtext1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="active">0</property>
<property name="entry_text_column">0</property>
<property name="id_column">1</property>
<items>
<item translatable="yes">yes</item>
<item translatable="yes">no</item>
<item translatable="yes">fullcompress</item>
<item translatable="yes">auto</item>
</items>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">7</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box8">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkLabel" id="label6">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">source path :</property>
<property name="width_chars">20</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">10</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkFileChooserButton" id="filechooserbutton2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">10</property>
<property name="orientation">vertical</property>
<property name="filter">filefilter2</property>
<signal name="file-set" handler="on_new_file_source" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box9">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkLabel" id="label7">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">destination path :</property>
<property name="width_chars">20</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">10</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkFileChooserButton" id="filechooserbutton3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">10</property>
<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>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">&lt;b&gt;File&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkFrame" id="frame3">
<property name="can_focus">False</property>
<property name="no_show_all">True</property>
<property name="margin_left">10</property>
<property name="margin_right">10</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property>
<property name="label_xalign">0</property>
<child>
<object class="GtkAlignment" id="alignment4">
<property name="width_request">1000</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="top_padding">5</property>
<property name="bottom_padding">5</property>
<property name="left_padding">5</property>
<property name="right_padding">5</property>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="shadow_type">in</property>
<property name="min_content_height">100</property>
<child>
<object class="GtkTextView" id="textview1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscroll_policy">natural</property>
<property name="vadjustment">adjustment2</property>
<property name="editable">False</property>
<property name="left_margin">2</property>
<property name="right_margin">2</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="label11">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">&lt;b&gt;Log&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkFrame" id="frame4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkAlignment" id="alignment5">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="left_padding">12</property>
<child>
<placeholder/>
</child>
</object>
</child>
<child type="label_item">
<placeholder/>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box12">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">9</property>
<property name="margin_right">19</property>
<property name="border_width">1</property>
<child>
<object class="GtkButton" id="button3">
<property name="label" translatable="yes">show log</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="no_show_all">True</property>
<property name="margin_left">20</property>
<signal name="pressed" handler="show_log" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="button2">
<property name="label" translatable="yes">clear log</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="no_show_all">True</property>
<signal name="pressed" handler="clear_log" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="checkbutton3">
<property name="label" translatable="yes">autoscroll</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="no_show_all">True</property>
<property name="margin_right">15</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
<signal name="pressed" handler="on_autoscroll_changed" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">5</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">10</property>
<property name="margin_right">10</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property>
<property name="border_width">2</property>
<property name="orientation">vertical</property>
<property name="spacing">5</property>
<child>
<object class="GtkBox" id="box13">
<property name="height_request">20</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkProgressBar" id="progressbar1">
<property name="can_focus">False</property>
<property name="no_show_all">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkAlignment" id="alignment3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">10</property>
<property name="yalign">1</property>
<property name="xscale">0.05000000074505806</property>
<child>
<object class="GtkButton" id="button1">
<property name="label" translatable="yes">proceed</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="yalign">1</property>
<signal name="clicked" handler="on_proceed" swapped="no"/>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">6</property>
</packing>
</child>
</object>
</child>
</object>
</interface>

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

53
setup.py Normal file
View File

@ -0,0 +1,53 @@
# !/usr/bin/env python
# -*- coding: utf-8 -*-
# setup.py
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# software : Kirmah <http://kirmah.sourceforge.net/>
# version : 2.17
# date : 2013
# licence : GPLv3.0 <http://www.gnu.org/licenses/>
# author : a-Sansara <[a-sansara]at[clochardprod]dot[net]>
# copyright : pluie.org <http://www.pluie.org/>
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# This file is part of Kirmah.
#
# Kirmah is free software (free as in speech) : you can redistribute it
# and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of the License,
# or (at your option) any later version.
#
# Kirmah is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License
# along with Kirmah. If not, see <http://www.gnu.org/licenses/>.
#
from psr.kirmah import conf
from distutils.core import setup
import glob
import os
# I18N
I18NFILES = []
for filepath in glob.glob('resources/locale/*/LC_MESSAGES/*.mo'):
lang = filepath[len('resources/locale/'):]
targetpath = os.path.dirname(os.path.join('share/locale',lang))
I18NFILES.append((targetpath, [filepath]))
setup(name = conf.PRG_NAME,
version = conf.PRG_VERS,
packages = [conf.PRG_PACKAGE],
scripts = [conf.PRG_SCRIPT, conf.PRG_CLI_NAME],
data_files= [('/usr/share/pixmaps/'+conf.PRG_PACKAGE , glob.glob('resources/pixmaps/'+conf.PRG_PACKAGE+'/*.png')),
('/usr/share/applications' , ['resources/'+conf.PRG_PACKAGE+'.desktop']),
('/usr/share/'+conf.PRG_PACKAGE , glob.glob('resources/'+conf.PRG_PACKAGE+'/LICENSE')),
('/usr/share/'+conf.PRG_PACKAGE+'/glade' , glob.glob('resources/'+conf.PRG_PACKAGE+'/glade/*.glade'))]
+ I18NFILES
)