(self)
Prepare configuration, parse and execute the command line
Prepare configuration, parse and execute the command line
Prepare configuration parse and execute the command line
def _prepare_exec(self):
        """Prepare configuration, parse and execute the command line"""
        self.cmdp = CmdParser()
        self.cmdp.parse(self.argv)
        allow_root = self.cmdp.get("--allow-root", "GEN_OPT")
        if not (os.geteuid() or allow_root):
            Msg().err("Error: do not run as root !")
            sys.exit(self.STATUS_ERROR)

        if self.cmdp.get("--config=", "GEN_OPT"):
            conf_file = self.cmdp.get("--config=", "GEN_OPT")
            Config().getconf(conf_file)
        else:
            Config().getconf()

        if (self.cmdp.get("--debug", "GEN_OPT") or
                self.cmdp.get("-D", "GEN_OPT")):
            Config.conf['verbose_level'] = Msg.DBG
        elif (self.cmdp.get("--quiet", "GEN_OPT") or
              self.cmdp.get("-q", "GEN_OPT")):
            Config.conf['verbose_level'] = Msg.MSG
        Msg().setlevel(Config.conf['verbose_level'])

        if self.cmdp.get("--insecure", "GEN_OPT"):
            Config.conf['http_insecure'] = True

        topdir = self.cmdp.get("--repo=", "GEN_OPT")
        if topdir:  # override repo root tree
            Config.conf['topdir'] = topdir
        self.local = LocalRepository()
        if not self.local.is_repo():
            if topdir:
                Msg().err("Error: invalid udocker repository:", topdir)
                sys.exit(self.STATUS_ERROR)
            else:
                Msg().out("Info: creating repo: " + Config.conf['topdir'],
                          l=Msg.INF)
                self.local.create_repo()

        self.cli = UdockerCLI(self.local)
def _prepare_exec ( self ) : self . cmdp = CmdParser ( ) self . cmdp . parse ( self . argv ) allow_root = self . cmdp . get ( "--allow-root" , "GEN_OPT" ) if not ( os . geteuid ( ) or allow_root ) : Msg ( ) . err ( "Error: do not run as root !" ) sys . exit ( self . STATUS_ERROR ) if self . cmdp . get ( "--config=" , "GEN_OPT" ) : conf_file = self . cmdp . get ( "--config=" , "GEN_OPT" ) Config ( ) . getconf ( conf_file ) else : Config ( ) . getconf ( ) if ( self . cmdp . get ( "--debug" , "GEN_OPT" ) or self . cmdp . get ( "-D" , "GEN_OPT" ) ) : Config . conf [ 'verbose_level' ] = Msg . DBG elif ( self . cmdp . get ( "--quiet" , "GEN_OPT" ) or self . cmdp . get ( "-q" , "GEN_OPT" ) ) : Config . conf [ 'verbose_level' ] = Msg . MSG Msg ( ) . setlevel ( Config . conf [ 'verbose_level' ] ) if self . cmdp . get ( "--insecure" , "GEN_OPT" ) : Config . conf [ 'http_insecure' ] = True topdir = self . cmdp . get ( "--repo=" , "GEN_OPT" ) if topdir : # override repo root tree Config . conf [ 'topdir' ] = topdir self . local = LocalRepository ( ) if not self . local . is_repo ( ) : if topdir : Msg ( ) . err ( "Error: invalid udocker repository:" , topdir ) sys . exit ( self . STATUS_ERROR ) else : Msg ( ) . out ( "Info: creating repo: " + Config . conf [ 'topdir' ] , l = Msg . INF ) self . local . create_repo ( ) self . cli = UdockerCLI ( self . local )