示例#1
0
 def onCommandInfo(self):
     """"""
     key = self.getMatchKey()
     if key is not None:
         Sys.clear()
         self.pheader()
         self.impst.getInfo(int(self.a[1]))
示例#2
0
 def needConfig(self):
     Sys.clear()
     self.pheader()
     Sys.echo(" " * 4 + "ImpraStorage has no configuration file !!", Sys.Clz.fgB1)
     Sys.dprint()
     Sys.echo(
         " " * 8 + "# to create the config file you must use this command with appropriate values :", Sys.Clz.fgn7
     )
     Sys.echo(" " * 8 + "# type command help for details", Sys.Clz.fgn7)
     Sys.echo(" " * 8 + conf.PRG_CLI_NAME + " ", Sys.Clz.fgB7, False)
     Sys.echo("conf ", Sys.Clz.fgB3, False)
     Sys.echo("-S ", Sys.Clz.fgB3, False)
     Sys.echo("profileName ", Sys.Clz.fgB1, False)
     Sys.echo("-N ", Sys.Clz.fgB3, False)
     Sys.echo("yourName ", Sys.Clz.fgB1, False)
     Sys.echo("-K -H ", Sys.Clz.fgB3, False)
     Sys.echo("accountHost ", Sys.Clz.fgB1, False)
     Sys.echo("-P ", Sys.Clz.fgB3, False)
     Sys.echo("993 ", Sys.Clz.fgB1, False)
     Sys.echo("-U ", Sys.Clz.fgB3, False)
     Sys.echo("accountName ", Sys.Clz.fgB1, False)
     Sys.echo("-X ", Sys.Clz.fgB3, False)
     Sys.echo("accountPassword ", Sys.Clz.fgB1)
     Sys.dprint()
     Sys.exit(1)
示例#3
0
 def onCommandGet(self):
     """"""
     if not len(self.a) > 1:
         self.parser.error_cmd((self.a[0] + " command need an id",), True)
     else:
         vid = self.a[1]
         ids = []
         for sid in vid.split(","):
             seq = sid.split("-")
             if len(seq) == 2:
                 ids.extend(range(int(seq[0]), int(seq[1]) + 1))
             else:
                 ids.append(sid)
         for sid in ids:
             Sys.clear()
             self.pheader()
             if self.impst.getFile(sid):
                 self.Cli.printLineSep(Const.LINE_SEP_CHAR, Const.LINE_SEP_LEN)
                 Sys.dprint(" ", end="")
                 Sys.echo(" == OK == ", Sys.Clz.bg2 + Sys.Clz.fgb7)
                 Sys.dprint()
             else:
                 self.Cli.printLineSep(Const.LINE_SEP_CHAR, Const.LINE_SEP_LEN)
                 Sys.dprint(" ", end="")
                 Sys.echo(" == `", Sys.Clz.bg1 + Sys.Clz.fgB7, False)
                 Sys.echo(str(sid), Sys.Clz.bg1 + Sys.Clz.fgB3, False)
                 Sys.echo("` KO == ", Sys.Clz.bg1 + Sys.Clz.fgB7)
                 Sys.dprint()
示例#4
0
    def onCommandSearch(self):
        """"""
        if not len(self.a) > 1:
            self.parser.error_cmd((" search command need one argument",), True)
        else:
            vsearch = self.a[1]

            matchIds = self.impst.idxu.index.getByPattern(vsearch)
            Sys.clear()
            self.pheader()
            if matchIds is not None:
                Sys.echo(" searching --", Sys.Clz.fgB3, False)
                Sys.echo(" `" + vsearch + "`", Sys.Clz.fgB7, False)
                Sys.echo(" -- found ", Sys.Clz.fgB3, False)
                Sys.echo(str(len(matchIds)), Sys.Clz.fgB1, False)
                Sys.echo(" results --", Sys.Clz.fgB3)
                self.Cli.printLineSep(Const.LINE_SEP_CHAR, Const.LINE_SEP_LEN)

                matchIdsCatg = None
                matchIdsUser = None
                matchIdsCrit = None
                if self.o.category is not None:
                    Sys.dprint(self.o.category)
                    matchIdsCatg = self.impst.idxu.index.getByCategory(self.o.category)
                if self.o.user is not None:
                    matchIdsUser = impst.idxu.index.getByUser(o.user)

                if self.o.category is not None:
                    if self.o.user is not None:
                        matchIdsCrit = self.impst.idxu.index.getIntersection(matchIdsCatg, matchIdsUser)
                    else:
                        matchIdsCrit = matchIdsCatg

                elif self.o.user is not None:
                    matchIdsCrit = matchIdsUser

                if matchIdsCrit is not None:
                    matchIds = self.impst.idxu.index.getIntersection(matchIds, matchIdsCrit)

                order = self.o.order
                if self.o.order_inv is not None:
                    order = "-" + self.o.order_inv

                self.impst.idxu.index.print(self.o.order, matchIds)
            else:
                self.Cli.printLineSep(Const.LINE_SEP_CHAR, Const.LINE_SEP_LEN)
                Sys.dprint(" ", end="")
                Sys.echo(" == no match found for pattern `", Sys.Clz.bg3 + Sys.Clz.fgB4, False)
                Sys.echo(vsearch, Sys.Clz.bg3 + Sys.Clz.fgB1, False)
                Sys.echo("` == ", Sys.Clz.bg3 + Sys.Clz.fgB4)
                Sys.dprint()
示例#5
0
 def onCommandRemove(self):
     """"""
     key = self.getMatchKey()
     if key is not None:
         Sys.clear()
         self.pheader()
         if self.impst.removeFile(self.a[1]):
             self.Cli.printLineSep(Const.LINE_SEP_CHAR, Const.LINE_SEP_LEN)
             Sys.dprint(" ", end="")
             Sys.echo(" == OK == ", Sys.Clz.bg2 + Sys.Clz.fgb7)
         else:
             self.Cli.printLineSep(Const.LINE_SEP_CHAR, Const.LINE_SEP_LEN)
             Sys.dprint(" ", end="")
             Sys.echo(" == can't remove file == ", Sys.Clz.bg3 + Sys.Clz.fgB4)
         Sys.dprint()
示例#6
0
    def onCommandList(self):
        """"""
        matchIdsCatg = None
        matchIdsUser = None
        matchIdsAcc = None
        matchIds = None

        if self.o.account is not None:
            matchIdsAcc = []
            # print(self.impst.idxu.index.acclist)
            # print(self.impst.idxu.index.acclist.keys())
            if self.impst.idxu.conf.ini.has("user", self.o.account + ".imap"):
                usr = self.impst.idxu.conf.ini.get("user", self.o.account + ".imap")
                if usr in self.impst.idxu.index.acclist.keys():
                    print(usr)
                for k in self.impst.idxu.index.acclist.keys():
                    if self.impst.idxu.index.acclist[k] == usr:
                        print("matched")
                        matchIdsAcc = self.impst.idxu.index.getByAccount(k)
                        print(matchIdsAcc)
                        break
            else:
                matchIdsAcc = []

        if self.o.category is not None:
            matchIdsCatg = self.impst.idxu.index.getByCategory(self.o.category)
        if self.o.user is not None:
            matchIdsUser = self.impst.idxu.index.getByUser(self.o.user)

        if self.o.category is not None:
            if self.o.user is not None:
                matchIds = self.impst.idxu.index.getIntersection(matchIdsCatg, matchIdsUser)
            else:
                matchIds = matchIdsCatg

        elif self.o.user is not None:
            matchIds = matchIdsUser

        if matchIdsAcc is not None:
            matchIds = matchIdsAcc if matchIds is None else self.impst.idxu.index.getIntersection(matchIdsAcc, matchIds)

        order = self.o.order
        if self.o.order_inv is not None:
            order = "-" + self.o.order_inv
        Sys.clear()
        self.pheader()
        self.impst.idxu.index.print(order, matchIds)
示例#7
0
    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()
        tree_iter = cbt.get_model().get_iter_from_string('4')
        cbt.set_active_iter(tree_iter)
        Sys.clear()
        Sys.dprint('INIT UI')
        self.start = True
        self.thkmh = None
示例#8
0
    def on_start(self):
        """"""
        self.app.createDefaultKeyIfNone()
        key, size, mark = self.app.getKeyInfos()

        self.curKey = self.DEFAULT_KEY
        print('-'*15)
        v = self.app.getDefaultKeyPath()
        print(v)
        self.get('filechooserbutton1').set_filename(self.app.getDefaultKeyPath())
        print(conf.DEFVAL_USER_PATH)
        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()
        tree_iter = cbt.get_model().get_iter_from_string('4')
        cbt.set_active_iter(tree_iter)
        Sys.clear()
        Sys.dprint('INIT UI')
        self.start = True
        self.thkmh = None
示例#9
0
 def onCommandEdit(self):
     """"""
     key = self.getMatchKey()
     if key is not None:
         if self.o.label is not None or self.o.category is not None:
             if self.impst.editFile(key, self.o.label, self.o.category):
                 Sys.clear()
                 self.pheader()
                 self.impst.idxu.index.print("ID", [int(self.a[1])])
                 Sys.dprint("\n ", end="")
                 Sys.echo(" == OK == ", Sys.Clz.bg2 + Sys.Clz.fgb7)
                 Sys.dprint()
             else:
                 self.parser.error_cmd(
                     (("id ", (self.a[1], Sys.CLZ_ERROR_PARAM), " has not been modified "),), False
                 )
         else:
             self.parser.error_cmd(((" command edit need a label or a category "),), True)
示例#10
0
    def onCommandExport(self):
        """"""
        Sys.clear()
        self.pheader()
        from time import strftime

        name = strftime("%Y%m%d%H%M%S") + "_" + self.impst.idxu.conf.profile
        Sys.echo(" saving ", Sys.Clz.fgn7, False)
        Sys.echo(name + ".index" + Kirmah.EXT, Sys.Clz.fgB2)
        Io.copy(self.impst.idxu.pathIdx, name + ".index" + Kirmah.EXT)
        Sys.echo(" saving ", Sys.Clz.fgn7, False)
        Sys.echo(name + ".ini" + Kirmah.EXT, Sys.Clz.fgB2)
        self.impst.idxu.conf.ini.save(name + ".ini", True)
        Sys.echo(" saving ", Sys.Clz.fgn7, False)
        Sys.echo(name + ".key", Sys.Clz.fgB2)
        Io.set_data(name + ".key", self.impst.idxu.conf.get("key", "keys"))
        Sys.dprint("\n ", end="")
        Sys.echo(" == OK == ", Sys.Clz.bg2 + Sys.Clz.fgb7)
        Sys.dprint()
示例#11
0
 def onCommandAdd(self):
     """"""
     if not len(self.a) > 1:
         self.parser.error_cmd((self.a[0] + " command need one argument",), True)
     else:
         vfile = self.a[1]
         if not Io.file_exists(vfile):
             if Sys.isdir(vfile):
                 for f in Sys.listdir(vfile):
                     if not Sys.isdir(f):
                         label, ext = Sys.getFileExt(Sys.basename(f))
                         if self.o.category is None:
                             self.o.category = ""
                         done = self.impst.addFile(vfile + Sys.sep + f, label, self.o.category)
                         if done:
                             self.Cli.printLineSep(Const.LINE_SEP_CHAR, Const.LINE_SEP_LEN)
                             Sys.dprint(" ", end="")
                             Sys.echo(" == OK == ", Sys.Clz.bg2 + Sys.Clz.fgb7)
                             Sys.dprint()
             else:
                 self.parser.error_cmd((self.a[0] + " is not a file or a directory",), True)
         else:
             if not len(self.a) > 2:
                 label = Sys.basename(vfile)
             else:
                 label = self.a[2]
             if self.o.category is None:
                 self.o.category = ""
             Sys.clear()
             self.pheader()
             done = self.impst.addFile(vfile, label, self.o.category)
             if done:
                 self.Cli.printLineSep(Const.LINE_SEP_CHAR, Const.LINE_SEP_LEN)
                 Sys.dprint(" ", end="")
                 Sys.echo(" == OK == ", Sys.Clz.bg2 + Sys.Clz.fgb7)
                 Sys.dprint()
             else:
                 self.Cli.printLineSep(Const.LINE_SEP_CHAR, Const.LINE_SEP_LEN)
                 Sys.dprint(" ", end="")
                 Sys.echo(" == KO == ", Sys.Clz.bg1 + Sys.Clz.fgb7)
                 Sys.dprint()
示例#12
0
    def __init__(self, path, remote=False, rwargs=None, thread=None, loglvl=Const.LOG_ALL):
        """"""
        AbstractCli.__init__(self, conf, self)

        Cli.HOME   = conf.DEFVAL_USER_PATH
        Cli.DIRKEY = Cli.HOME+'.'+conf.PRG_NAME.lower()+Sys.sep
        if not Sys.isUnix() :
            Cli.CHQ    = '"'
            Cli.HOME   = 'C:'+Sys.sep+conf.PRG_NAME.lower()+Sys.sep
            Cli.DIRKEY = self.HOME+'keys'+Sys.sep
        Sys.mkdir_p(Cli.DIRKEY)

        gpData = OptionGroup(self.parser, '')
        gpData = OptionGroup(self.parser, '')
        gpConf = OptionGroup(self.parser, '')
        
        gpData.add_option('-c', '--category'      , action='store',       metavar='CATG            ')
        gpData.add_option('-u', '--user'          , action='store',       metavar='OWNER           ')
        gpData.add_option('-l', '--label'         , action='store',       metavar='LABEL           ')
        gpData.add_option('-o', '--order'         , action='store',       metavar='ORDER           '  , default='ID')
        gpData.add_option('-O', '--order-inv'     , action='store',       metavar='ORDER_INVERSE   ')
        gpData.add_option('-a', '--account'       , action='store',       metavar='ACCOUNT         ')
        self.parser.add_option_group(gpData)        

        gpConf.add_option('-V', '--view'          , action='store'                                  )
        gpConf.add_option('-L', '--load'          , action='store'                                  )
        gpConf.add_option('-S', '--save'          , action='store'                                  )
        gpConf.add_option('-C', '--check'         , action='store'                                  )
        gpConf.add_option('-H', '--set-host'      , action='store',       metavar='HOST            ')
        gpConf.add_option('-U', '--set-user'      , action='store',       metavar='USER            ')
        gpConf.add_option('-X', '--set-pass'      , action='store',       metavar='PASS            ')
        gpConf.add_option('-P', '--set-port'      , action='store',       metavar='PORT            ')
        gpConf.add_option('-N', '--set-name'      , action='store',       metavar='NAME            ')
        gpConf.add_option('-M', '--set-multi'     , action='store',       metavar='PROFILE         ')
        gpConf.add_option('-R', '--remove-multi'  , action='store',       metavar='PROFILE         ')
        gpConf.add_option('-B', '--set-boxname'   , action='store',       metavar='BOXNAME         ')
        gpConf.add_option('-K', '--gen-key'       , action='store_true',  default=False)
        self.parser.add_option_group(gpConf)

        # rewrite argv sended by remote
        if rwargs is not None :
            import sys
            sys.argv = rwargs

        (o, a) = self.parser.parse_args()

        Sys.g.QUIET      = o.quiet
        Sys.g.THREAD_CLI = thread
        Sys.g.GUI        = thread is not None

        init(conf.PRG_NAME, o.debug, remote, not o.no_color, loglvl)
        Const.LINE_SEP_LEN = 120

        if not a:
            try :
                if not o.help or not o.version:
                    self.parser.error_cmd(('no command specified',), True)
                else :
                    Sys.clear()
                    Cli.print_help()
            except :
                if not o.version :
                    self.parser.error_cmd(('no command specified',), True)
                else :
                    Cli.print_header()

        else:
            if a[0] == 'help':
                Sys.clear()
                Cli.print_help()

            elif a[0] in ['add','conf','import','info', 'edit','export','get','list','remove','search'] :
                app = CliApp(self.HOME, path, self.parser, Cli, a, o)

                if a[0]=='add':
                    app.onCommandAdd()
                elif a[0]=='conf':
                    app.onCommandConf()
                elif a[0]=='info':
                    app.onCommandInfo()
                elif a[0]=='import':
                    app.onCommandImport()
                elif a[0]=='edit':
                    app.onCommandEdit()
                elif a[0]=='export':
                    app.onCommandExport()
                elif a[0]=='get':
                    app.onCommandGet()
                elif a[0]=='list':
                    app.onCommandList()
                elif a[0]=='remove':
                    app.onCommandRemove()
                elif a[0]=='search':
                    app.onCommandSearch()
                    
                Sys.dprint('PUT END SIGNAL')
                if Sys.g.LOG_QUEUE is not None :
                    Sys.g.LOG_QUEUE.put(Sys.g.SIGNAL_STOP)

            else :
                self.parser.error_cmd((('unknow command ',(a[0],Sys.Clz.fgb3)),), True)

        if not o.quiet : Sys.dprint()
示例#13
0
    def __init__(self, path, remote=False, rwargs=None, thread=None, loglvl=Const.LOG_DEFAULT):
        """"""
        AbstractCli.__init__(self, conf, self)

        Cli.HOME = conf.DEFVAL_USER_PATH
        Cli.DIRKEY = Cli.HOME + "." + conf.PRG_NAME.lower() + Sys.sep
        if not Sys.isUnix():
            CHQ = '"'
            self.HOME = "C:" + Sys.sep + conf.PRG_NAME.lower() + Sys.sep
            self.DIRKEY = self.HOME + "keys" + Sys.sep
        Sys.mkdir_p(Cli.DIRKEY)

        gpData = OptionGroup(self.parser, "")
        gpData.add_option("-a", "--fullcompress", action="store_true")
        gpData.add_option("-z", "--compress", action="store_true")
        gpData.add_option("-Z", "--nocompress", action="store_true")
        gpData.add_option("-r", "--random", action="store_true")
        gpData.add_option("-R", "--norandom", action="store_true")
        gpData.add_option("-m", "--mix", action="store_true")
        gpData.add_option("-M", "--nomix", action="store_true")
        gpData.add_option("-j", "--multiprocess", action="store")
        gpData.add_option("-k", "--keyfile", action="store")
        gpData.add_option("-l", "--length", action="store", default=1024)
        gpData.add_option("-p", "--parts", action="store", default=22)
        gpData.add_option("-o", "--outputfile", action="store")
        self.parser.add_option_group(gpData)

        # rewrite argv sended by remote
        if rwargs is not None:
            import sys

            sys.argv = rwargs

        (o, a) = self.parser.parse_args()

        Sys.g.QUIET = o.quiet
        Sys.g.THREAD_CLI = thread
        Sys.g.GUI = thread is not None

        init(conf.PRG_NAME, o.debug, remote, not o.no_color, loglvl)

        if not a:
            try:
                if not o.help or not o.version:
                    self.parser.error_cmd(("no command specified",), True)
                else:
                    Sys.clear()
                    Cli.print_help()
            except:
                if not o.version:
                    self.parser.error_cmd(("no command specified",), True)
                else:
                    Cli.print_header()

        else:
            if a[0] == "help":
                Sys.clear()
                Cli.print_help()

            elif a[0] in ["key", "enc", "dec", "split", "merge"]:

                app = CliApp(self.HOME, path, self, a, o)

                if a[0] == "key":
                    app.onCommandKey()
                else:
                    if not len(a) > 1:
                        self.parser.error_cmd((("an ", ("inputFile", Sys.Clz.fgb3), " is required !"),), True)
                    elif not Io.file_exists(a[1]):
                        self.parser.error_cmd((("the file ", (a[1], Sys.Clz.fgb3), " doesn't exists !"),), True)

                    elif a[0] == "enc":
                        app.onCommandEnc()
                    elif a[0] == "dec":
                        app.onCommandDec()
                    elif a[0] == "split":
                        app.onCommandSplit()
                    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:
                self.parser.error_cmd((("unknow command ", (a[0], Sys.Clz.fgb3)),), True)

        if not o.quiet:
            Sys.dprint()
示例#14
0
    def __init__(self,
                 path,
                 remote=False,
                 rwargs=None,
                 thread=None,
                 loglvl=Const.LOG_DEFAULT):
        """"""
        AbstractCli.__init__(self, conf, self)

        Cli.HOME = conf.DEFVAL_USER_PATH
        Cli.DIRKEY = Cli.HOME + '.' + conf.PRG_NAME.lower() + Sys.sep
        if not Sys.isUnix():
            CHQ = '"'
            self.HOME = 'C:' + Sys.sep + conf.PRG_NAME.lower() + Sys.sep
            self.DIRKEY = self.HOME + 'keys' + Sys.sep
        Sys.mkdir_p(Cli.DIRKEY)

        gpData = OptionGroup(self.parser, '')
        gpData.add_option('-a', '--fullcompress', action='store_true')
        gpData.add_option('-z', '--compress', action='store_true')
        gpData.add_option('-Z', '--nocompress', action='store_true')
        gpData.add_option('-r', '--random', action='store_true')
        gpData.add_option('-R', '--norandom', action='store_true')
        gpData.add_option('-m', '--mix', action='store_true')
        gpData.add_option('-M', '--nomix', action='store_true')
        gpData.add_option('-j', '--multiprocess', action='store')
        gpData.add_option('-k', '--keyfile', action='store')
        gpData.add_option('-l', '--length', action='store', default=1024)
        gpData.add_option('-p', '--parts', action='store', default=22)
        gpData.add_option('-o', '--outputfile', action='store')
        self.parser.add_option_group(gpData)

        # rewrite argv sended by remote
        if rwargs is not None:
            import sys
            sys.argv = rwargs

        (o, a) = self.parser.parse_args()

        Sys.g.QUIET = o.quiet
        Sys.g.THREAD_CLI = thread
        Sys.g.GUI = thread is not None

        init(conf.PRG_NAME, o.debug, remote, not o.no_color, loglvl)

        if not a:
            try:
                if not o.help or not o.version:
                    self.parser.error_cmd(('no command specified', ), True)
                else:
                    Sys.clear()
                    Cli.print_help()
            except:
                if not o.version:
                    self.parser.error_cmd(('no command specified', ), True)
                else:
                    Cli.print_header()

        else:
            if a[0] == 'help':
                Sys.clear()
                Cli.print_help()

            elif a[0] in ['key', 'enc', 'dec', 'split', 'merge']:

                app = CliApp(self.HOME, path, self, a, o)

                if a[0] == 'key':
                    app.onCommandKey()
                else:
                    if not len(a) > 1:
                        self.parser.error_cmd(
                            (('an ', ('inputFile', Sys.Clz.fgb3),
                              ' is required !'), ), True)
                    elif not Io.file_exists(a[1]):
                        self.parser.error_cmd(
                            (('the file ',
                              (a[1], Sys.Clz.fgb3), ' doesn\'t exists !'), ),
                            True)

                    elif a[0] == 'enc':
                        app.onCommandEnc()
                    elif a[0] == 'dec':
                        app.onCommandDec()
                    elif a[0] == 'split':
                        app.onCommandSplit()
                    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:
                self.parser.error_cmd(
                    (('unknow command ', (a[0], Sys.Clz.fgb3)), ))

        if not o.quiet: Sys.dprint()