Ejemplo n.º 1
0
    def execmd_impl(cmd,check=True, okcode= [0],loglevel= 2 ):
        # cmd_txt =  setting.tmp_file("sh")
        pid     = os.getpid()
        cmd_txt = "/tmp/rigger-ng_%s.cmd" %(pid)
        cmd     = re.sub(r'/bin/php ' ,'/bin/php  -d error_reporting="E_ALL&~E_NOTICE" ',cmd)
        if setting.debug and setting.debug_level >= loglevel:
            rgio.simple_out(cmd)

        if shexec.DO  :
            shexec.out2txt(cmd,cmd_txt)
            with end_keeper(lambda : os.system( " rm %s " %cmd_txt ) )   as keeper :
                os.system("chmod +x " +  cmd_txt)
                uid = os.getuid()
                if shexec.SUDO  and uid != 0 :
                    sudo_cmd    = "sudo " + cmd_txt
                    rcode       = os.system(sudo_cmd)
                    if setting.debug and setting.debug_level >= loglevel:
                        rgio.simple_out("sudo system code: %s" % rcode )
                    if check and rcode not in  okcode :
                        raise interface.rigger_exception("shell execute have error! code: %d  cmd:\n%s " %(rcode ,cmd))
                    return 0
                else:
                    rcode = os.system( cmd_txt)
                    if setting.debug and setting.debug_level >= loglevel:
                        rgio.simple_out("system code: %s" % rcode )
                    if check and rcode not in  okcode :
                        raise interface.rigger_exception("shell execute have error! code: %d  cmd:\n%s" %(rcode,cmd) )
                    return  0
        else :
            return 0
        return 1
Ejemplo n.º 2
0
    def runcmd(self,rargs,fun,extra=None) :
        import utls.rg_yaml,copy
        utls.check.must_exists(rargs.prj.conf)
        rg_logger.info("load prj conf: %s" %(rargs.prj.conf))
        loader = utls.rg_yaml.conf_loader(rargs.prj.conf)
        data   = loader.load_data("!R","res")
        prj_cmd_base.check_data(data)

        env_data    = data['_env']
        sys_data    = data['_sys']

        if data.has_key('_mod') :
            for m  in  data['_mod'] :
                res.node.regist_mod(m)


        main  = res.prj_main()
        if len(self.env) == 0 :
            return
        #import pdb
        #pdb.set_trace()
        

        for env_obj  in env_data  :
            res.node.env_regist(env_obj)
            if self.env == "@all" :
                main.append(env_obj)

        if self.env != "@all"  :
            for  need_env in self.env :
                obj = res.node.env_find(need_env)
                if obj is not None :
                    main.append(obj)
                else:
                    raise interface.rigger_exception("env [%s] not found" %(need_env))


        for sys_obj in   sys_data  :
            res.node.sys_regist(sys_obj)
            if self.sys == "@all":
                main.append(sys_obj)

        if len(self.sys) > 1 and extra is not None :
                raise interface.rigger_exception("extra obj will execute in muti sys" %(len(self.sys)))

        if self.sys != "@all"  :
            for need_sys in self.sys :
                obj = res.node.sys_find(need_sys)
                if obj is not None :
                    if extra is not None :
                        obj.append(extra)
                    main.append(obj)
                else :
                    raise interface.rigger_exception("sys [%s] not found" %(need_sys))

        context = interface.run_context()
        project = res.project()
        project.setup4start(context)
        interface.control_call(main,fun,context,"unknow")
Ejemplo n.º 3
0
def run_rigger(rargs, argv) :
    #TODO: muti cmd support
    if len(rargs.prj.cmds) == 0 :
        raise interface.rigger_exception("No Cmd!")
    cmds = rargs.prj.cmds[0]
    for  cmd in cmds.split(',') :
        obj = rg_ioc.ins_cmd(cmd)
        if obj is None :
            raise  interface.rigger_exception( "unfound '%s' cmd instance" %cmd)
        rg_logger.info("cmd: %s , cmd_ins : %s" %(cmd,obj.__class__.__name__))
        obj._config(argv,rargs)
        obj._execute(rargs)
Ejemplo n.º 4
0
def ins_cmd(name) :
    import  impl.rg_cmd
    for cmd,module in interface.registed_cmd.items() :
        if  cmd == name :
            code = "obj = impl.rg_cmd.%s_cmd()" %(name)
            rg_logger.debug("exec code : %s" %code)
            try :
                exec code
                return obj
            except  Exception as e :
                raise interface.rigger_exception("@ins_cmd() code error: %s \n %s" %(code,e) )
    # return None
    raise interface.rigger_exception(" '%s' cmd not support!" %(name) )
Ejemplo n.º 5
0
def run_rigger(rargs, argv):
    #TODO: muti cmd support
    if len(rargs.prj.cmds) == 0:
        raise interface.rigger_exception("No Cmd!")
    cmds = rargs.prj.cmds[0]
    for cmd in cmds.split(','):
        obj = rg_ioc.ins_cmd(cmd)
        if obj is None:
            raise interface.rigger_exception("unfound '%s' cmd instance" % cmd)
        rg_logger.info("cmd: %s , cmd_ins : %s" %
                       (cmd, obj.__class__.__name__))
        obj._config(argv, rargs)
        obj._execute(rargs)
Ejemplo n.º 6
0
def ins_cmd(name):
    import impl.rg_cmd
    for cmd, module in interface.registed_cmd.items():
        if cmd == name:
            code = "obj = impl.rg_cmd.%s_cmd()" % (name)
            rg_logger.debug("exec code : %s" % code)
            try:
                exec code
                return obj
            except Exception as e:
                raise interface.rigger_exception(
                    "@ins_cmd() code error: %s \n %s" % (code, e))
    # return None
    raise interface.rigger_exception(" '%s' cmd not support!" % (name))
Ejemplo n.º 7
0
 def _config(self,argv,rargs):
     dst = ""
     tpl = ""
     if argv.has_key('-t') :
         tpl  = argv['-t']
     if argv.has_key('-o') :
         dst  = argv['-o']
     if len(dst) == 0 :
         print("rg tpl -t <template> -o <dst>")
         raise interface.rigger_exception("dst: %s is empty" %dst)
     if os.path.exists(dst) :
         raise interface.rigger_exception("dst: %s have exists" %dst)
     if not os.path.exists(tpl) :
         raise interface.rigger_exception("tpl: %s not exists" %tpl)
     self.dst = dst
     self.tpl = tpl
Ejemplo n.º 8
0
    def _execute(self,rargs):
        dst = os.getcwd() + "/_rg"
        if os.path.exists(dst) :
            raise interface.rigger_exception("have _rg dir. maybe inited!")

        import utls.tpl
        utls.tpl.tplworker().execute(self.tpl,dst,"")
Ejemplo n.º 9
0
    def runcmd(self,rargs,fun,extra=None) :
        utls.check.must_exists(rargs.prj.conf)
        conf.run_conf.load(rargs.prj.conf)


        main  = res.prj_main()
        if len(self.env) == 0 :
            return
        #import pdb
        #pdb.set_trace()
        


        for  need_env in self.env :
            obj = res.node.env_find(need_env)
            if obj is None :
                obj = interface.res_proxy(res.node.env_find,need_env,"env")
            main.append(obj)

        if len(self.sys) > 1 and extra is not None :
                raise interface.rigger_exception("forbit! execute in muti sys(%s)" %(self.sys))

        for need_sys in self.sys :
            obj = res.node.sys_find(need_sys)
            if obj is None :
                obj = interface.res_proxy(res.node.sys_find,need_sys,"sys")
            main.append(obj)
            if extra is not None :
                obj.append(extra)

        context        = interface.run_context()
        context.passwd = self.passwd
        project        = res.project()
        project.setup4start(context)
        interface.control_call(main,fun,context,"unknow")
Ejemplo n.º 10
0
    def runcmd(self, rargs, fun, extra=None):
        utls.check.must_exists(rargs.prj.conf)
        conf.run_conf.load(rargs.prj.conf)

        main = res.prj_main()
        if len(self.env) == 0:
            return
        #import pdb
        #pdb.set_trace()

        for need_env in self.env:
            obj = res.node.env_find(need_env)
            if obj is None:
                obj = interface.res_proxy(res.node.env_find, need_env, "env")
            main.append(obj)

        if len(self.sys) > 1 and extra is not None:
            raise interface.rigger_exception(
                "forbit! execute in muti sys(%s)" % (self.sys))

        for need_sys in self.sys:
            obj = res.node.sys_find(need_sys)
            if obj is None:
                obj = interface.res_proxy(res.node.sys_find, need_sys, "sys")
            main.append(obj)
            if extra is not None:
                obj.append(extra)

        context = interface.run_context()
        context.passwd = self.passwd
        project = res.project()
        project.setup4start(context)
        interface.control_call(main, fun, context, "unknow")
Ejemplo n.º 11
0
    def _execute(self, rargs):
        dst = os.getcwd() + "/_rg"
        if os.path.exists(dst):
            raise interface.rigger_exception("have _rg dir. maybe inited!")

        import utls.tpl
        utls.tpl.tplworker().execute(self.tpl, dst, "")
Ejemplo n.º 12
0
    def get(self,name):
        name = name.upper()
        val  = icase_porp.get(self,name)
        if val is not None :
            return val

        fun  = self._default_fun
        if  self._var_funs.has_key(name) :
            fun = self._var_funs[name]

        if fun is None :
            raise interface.rigger_exception(" layzer_porp   %s no fun" %name)
        val = fun(name)
        if val is None :
            raise interface.rigger_exception(" layzer_porp   %s is None" %name)
        self.set(name,val)
        return val
Ejemplo n.º 13
0
 def _before(self,context):
     import conf.run_conf
     for path in self._path  :
         if os.path.isfile(path) :
             path = res_utls.value(path)
             conf.run_conf.load(path)
         else:
             raise interface.rigger_exception("%s path not found! in !R.include" %path)
Ejemplo n.º 14
0
    def get(self,name):
        name = name.upper()
        val  = icase_porp.get(self,name)
        if val is not None :
            return val

        fun  = self._default_fun
        if  self._var_funs.has_key(name) :
            fun = self._var_funs[name]

        if fun is None :
            raise interface.rigger_exception(" layzer_porp   %s no fun" %name)
        val = fun(name)
        if val is None :
            raise interface.rigger_exception(" layzer_porp   %s is None" %name)
        self.set(name,val)
        return val
Ejemplo n.º 15
0
 def doit(self, context, pos):
     if not os.path.exists(self.script):
         raise interface.rigger_exception("script is bad! %s " %
                                          (self.script))
     if pos in self.run.split(","):
         cmd = Template(self.script + "  $ARGS").substitute(ARGS=self.args)
         utls.rg_var.export_env()
         self.execmd(cmd)
Ejemplo n.º 16
0
 def _before(self,context):
     rg_logger.info("env:%s _before" %(self._name))
     if self._mix is not None :
         for key in  self._mix.split(",") :
             obj = res.node.env_find(key)
             if obj is None :
                 raise interface.rigger_exception("env [%s] : mix [%s] not found " %(self._name,key))
             self.append(obj)
Ejemplo n.º 17
0
 def _before(self, context):
     import conf.run_conf
     for path in self._path:
         if os.path.isfile(path):
             path = res_utls.value(path)
             conf.run_conf.load(path)
         else:
             raise interface.rigger_exception(
                 "%s path not found! in !R.include" % path)
Ejemplo n.º 18
0
 def require_do(self,context,is_raise = True):
     dst        = res_utls.value(self.file)
     sha        = res_utls.value(self.sha)
     dst_sha    = cacu_file_sha(dst)
     if sha != dst_sha:
         if is_raise :
             raise interface.rigger_exception("file MD5: %s , expect MD5 : %s " %(dst_sha,sha))
         return False
     return True
Ejemplo n.º 19
0
 def doit(self,context,pos) :
     if not os.path.exists(self.script) :
         raise interface.rigger_exception( "script is bad! %s " %(self.script))
     if  pos in self.run.split(","):
         cmd = Template( self.script + "  $ARGS").substitute(
                 ARGS = self.args
                 )
         utls.rg_var.export_env()
         self.execmd(cmd)
Ejemplo n.º 20
0
def load_file(jsonfile,xpath= None) :
    if len(xpath) == 0 :
        xpath = "/"
    utls.check.must_exists(jsonfile)
    doc = open(jsonfile,"r").read()
    try :
        data = json.loads(doc)
        arr = xpath.split("/")
        for key in arr :
            if len(key) == 0 :
                continue
            data = data[key]
            utls.check.not_none(data, "data[%s] not exists" %key)
        return data
    except KeyError as e:
        raise interface.rigger_exception("not xpath %s in %s" %(e,jsonfile) )
    except Exception as e:
        raise interface.rigger_exception("bad json file %s %s:%s" %(jsonfile,e.__class__.__name__,e) )
Ejemplo n.º 21
0
 def _config(self,context):
     # import pdb
     # pdb.set_trace()
     with open(self.dst, 'w+') as self.dstfile :
         srclist = self.src.split(":")
         for src in srclist:
             if not os.path.exists(src):
                 raise interface.rigger_exception("path not exists: %s" %src)
             os.path.walk(src,self.proc_file,None)
Ejemplo n.º 22
0
    def _before(self,context) :
        self.env_keep = None
        if self.script is not None :
            self.script = res_utls.value(self.script)
            if os.path.exists(self.script) :
                self.env_keep = copy.copy(os.environ)
                return


        raise interface.rigger_exception( "script is bad! %s " %(self.script))
Ejemplo n.º 23
0
def list_res() :
    import  res
    for name,module in interface.registed_resource.items() :
        code = "obj = res.%s()" %(name)
        rg_logger.debug("exec code : %s" %code)
        try :
            exec code
            utls.rg_io.export_objdoc(name,obj )
        except  Exception as e :
            raise interface.rigger_exception("@list_res() code error: %s \n %s" %(code,e) )
Ejemplo n.º 24
0
    def append_conf(self,context):
        if not os.path.exists(self.hosts):
            raise interface.rigger_exception("hosts file not exists : %s" %self.hosts)
        # import pdb
        # pdb.set_trace() ;

        self.execmd("cat /etc/hosts > %s " %(self.tmp_hosts) ,okcode=[0,256])
        conf    = sysconf(self.tmp_hosts,"#")
        newhosts = conf.replace_by_file(self.tag,self.hosts)
        self.execmd("cat %s > /etc/hosts" %(newhosts))
Ejemplo n.º 25
0
 def _config(self, context):
     # import pdb
     # pdb.set_trace()
     with open(self.dst, 'w+') as self.dstfile:
         srclist = self.src.split(":")
         for src in srclist:
             if not os.path.exists(src):
                 raise interface.rigger_exception("path not exists: %s" %
                                                  src)
             os.path.walk(src, self.proc_file, None)
Ejemplo n.º 26
0
    def _before(self,context) :
        self.env_keep = None
        if self.script is not None :
            self.script = res_utls.value(self.script)
            if os.path.exists(self.script) :
                self.env_keep = copy.copy(os.environ)
                return


        raise interface.rigger_exception( "script is bad! %s " %(self.script))
Ejemplo n.º 27
0
def load_file(jsonfile, xpath=None):
    if len(xpath) == 0:
        xpath = "/"
    utls.check.must_exists(jsonfile)
    doc = open(jsonfile, "r").read()
    try:
        data = json.loads(doc)
        arr = xpath.split("/")
        for key in arr:
            if len(key) == 0:
                continue
            data = data[key]
            utls.check.not_none(data, "data[%s] not exists" % key)
        return data
    except KeyError as e:
        raise interface.rigger_exception("not xpath %s in %s" % (e, jsonfile))
    except Exception as e:
        raise interface.rigger_exception("bad json file %s %s:%s" %
                                         (jsonfile, e.__class__.__name__, e))
Ejemplo n.º 28
0
    def append_conf(self,context):
        if not os.path.exists(self.cron):
            raise interface.rigger_exception("cron file not exists : %s" %self.cron)
        # import pdb
        # pdb.set_trace() ;

        self.execmd("/usr/bin/crontab -l > %s " %(self.tmp_cron) ,okcode=[0,256])
        conf    = sysconf(self.tmp_cron,"#")
        newcron = conf.replace_by_file(self.tag,self.cron)
        self.execmd("crontab  %s " %(newcron))
Ejemplo n.º 29
0
def list_cmd() :
    import  impl.rg_cmd
    for name in interface.cmds_index :
        code = "obj = impl.rg_cmd.%s_cmd()" %(name)
        rg_logger.debug("exec code : %s" %code)
        try :
            exec code
            utls.rg_io.export_objdoc(name,obj )
        except  Exception as e :
            raise interface.rigger_exception("@list_cmd() code error: %s \n %s" %(code,e) )
Ejemplo n.º 30
0
    def append_conf(self, context):
        if not os.path.exists(self.hosts):
            raise interface.rigger_exception("hosts file not exists : %s" %
                                             self.hosts)
        # import pdb
        # pdb.set_trace() ;

        self.execmd("cat /etc/hosts > %s " % (self.tmp_hosts), okcode=[0, 256])
        conf = sysconf(self.tmp_hosts, "#")
        newhosts = conf.replace_by_file(self.tag, self.hosts)
        self.execmd("cat %s > /etc/hosts" % (newhosts))
Ejemplo n.º 31
0
 def var_proc(string,tplvars):
     # tpl     = string.strip()
     tpl     = string
     var_exp = re.compile(r'\$\{(\w+)\}')
     ass     = assigner(tpl,tplvars)
     try :
         while var_exp.search(tpl):
             tpl = var_exp.sub(ass.assign_value,tpl)
     except TypeError as e :
         raise interface.rigger_exception(tpl + "tpl proc fail!")
     return tpl
Ejemplo n.º 32
0
def list_cmd():
    import impl.rg_cmd
    for name, module in interface.registed_cmd.items():
        code = "obj = impl.rg_cmd.%s_cmd()" % (name)
        rg_logger.debug("exec code : %s" % code)
        try:
            exec code
            utls.rg_io.export_objdoc(name, obj)
        except Exception as e:
            raise interface.rigger_exception(
                "@list_cmd() code error: %s \n %s" % (code, e))
Ejemplo n.º 33
0
 def _config(self,context):
     for v in self.paths :
         if os.path.exists(v)  and self._checkWrite(v) :
             continue
         else :
             if not self._checkWrite(v) :
                 if not self.sudo :
                     raise interface.rigger_exception( "%s 不可访问" %(v) )
         cmdtpl ="if test ! -e $DST; then   mkdir -p $DST ; fi ;   chmod $CHMOD  $DST; "
         cmd = Template(cmdtpl).substitute(DST=v,CHMOD=self.chmod)
         self.execmd(cmd)
Ejemplo n.º 34
0
    def _config(self, argv, rargs):
        dst = ""
        tpl = ""
        ignore = ""
        if argv.has_key('-t'):
            tpl = argv['-t']
        if argv.has_key('-o'):
            dst = argv['-o']

        if argv.has_key('-i'):
            ignore = argv['-i']
        if len(dst) == 0:
            print("rg tpl -t <template> -o <dst>")
            raise interface.rigger_exception("dst: %s is empty" % dst)
        if os.path.exists(dst):
            raise interface.rigger_exception("dst: %s have exists" % dst)
        if not os.path.exists(tpl):
            raise interface.rigger_exception("tpl: %s not exists" % tpl)
        self.dst = dst
        self.tpl = tpl
        self.ignore = ignore
Ejemplo n.º 35
0
def ins_res(name) :
    import  res
    for res_name,module in interface.registed_resource.items() :
        if  res_name == name :
            code = "obj = res.%s()" %(name)
            rg_logger.debug("exec code : %s" %code)
            try :
                exec code
                return obj
            except  Exception as e :
                raise interface.rigger_exception("@ins_res() code error: %s \n %s" %(code,e) )
    return None
Ejemplo n.º 36
0
def list_res():
    import res
    sorted_res = sorted(interface.registed_resource)
    for name in sorted_res:
        code = "obj = res.%s()" % (name)
        rg_logger.debug("exec code : %s" % code)
        try:
            exec code
            utls.rg_io.export_objdoc(name, obj)
        except Exception as e:
            raise interface.rigger_exception(
                "@list_res() code error: %s \n %s" % (code, e))
Ejemplo n.º 37
0
def ins_res(name):
    import res
    for res_name, module in interface.registed_resource.items():
        if res_name == name:
            code = "obj = res.%s()" % (name)
            rg_logger.debug("exec code : %s" % code)
            try:
                exec code
                return obj
            except Exception as e:
                raise interface.rigger_exception(
                    "@ins_res() code error: %s \n %s" % (code, e))
    return None
Ejemplo n.º 38
0
    def _execute(self,rargs):
        conf.version.file=os.path.join(rargs.rg.root ,"version.txt" )
        ver    = conf.version()
        rgio.simple_out("rigger-ng ver: " + ver.info())
        cmdlen = len(rargs.prj.cmds)
        print(rargs.prj.cmds)
        if cmdlen == 1 :
            rargs.help()
            impl.rg_ioc.list_cmd()
            return
        if cmdlen >= 2 :
            subcmd = rargs.prj.cmds[1]
            if subcmd == "res":
                if cmdlen == 3 :
                    resname = rargs.prj.cmds[2]
                    resobj  = impl.rg_ioc.ins_res(resname)
                    if resobj is None :
                        raise  interface.rigger_exception( "instance res fail! resname: %s" %(resname) )

                    # resobj.useage(output):
                    resobj.useage(rgio.simple_out)

                else:
                    impl.rg_ioc.list_res()
Ejemplo n.º 39
0
    def _execute(self,rargs):
        conf.version.file=os.path.join(rargs.rg.root ,"version.txt" )
        ver    = conf.version()
        rgio.simple_out("rigger-ng ver: " + ver.info())
        cmdlen = len(rargs.prj.cmds)
        print(rargs.prj.cmds)
        if cmdlen == 1 :
            rargs.help()
            impl.rg_ioc.list_cmd()
            return
        if cmdlen >= 2 :
            subcmd = rargs.prj.cmds[1]
            if subcmd == "res":
                if cmdlen == 3 :
                    resname = rargs.prj.cmds[2]
                    resobj  = impl.rg_ioc.ins_res(resname)
                    if resobj is None :
                        raise  interface.rigger_exception( "instance res fail! resname: %s" %(resname) )

                    # resobj.useage(output):
                    resobj.useage(rgio.simple_out)

                else:
                    impl.rg_ioc.list_res()
Ejemplo n.º 40
0
def ok(val, errmsg):
    if not val:
        raise interface.rigger_exception(errmsg)
    return val
Ejemplo n.º 41
0
def must_true(val, errmsg):
    if not val == True:
        raise interface.rigger_exception(errmsg)
    return val
Ejemplo n.º 42
0
 def assert_eq(self,context):
     value  = res_utls.value(self.value)
     expect = res_utls.value(self.expect)
     if value != expect :
         raise interface.rigger_exception("value: %s , expect : %s " %(value,expect))
Ejemplo n.º 43
0
 def ins():
     with   fail_exception(interface.rigger_exception("bad sonar conf "))  :
         return singleton.get_ins(sonar)
Ejemplo n.º 44
0
def not_none(val, errmsg):
    if val is None:
        raise interface.rigger_exception(errmsg)
    return val
Ejemplo n.º 45
0
def ok(val, errmsg):
    if not val:
        raise interface.rigger_exception(errmsg)
    return val
Ejemplo n.º 46
0
 def get(self,name) :
     raise interface.rigger_exception(" %s no impl get methond " %self.__class__.__name__)
Ejemplo n.º 47
0
import interface
import logging
from utls.rg_io import rg_logger

if len(interface.registed_resource.items()) == 0:
    raise interface.rigger_exception("@res.__init__ no regist res to module")

for res, module in interface.registed_resource.items():
    code = "from %s import %s" % (module, res)
    rg_logger.debug(" load module: %s" % code)
    try:
        exec code
    except Exception as e:
        raise interface.rigger_exception("@res.__init__ code error: %s \n %s" %
                                         (code, e))
Ejemplo n.º 48
0
def must_exists(path):
    if path is None or not os.path.exists(path):
        raise interface.rigger_exception("file not exists : %s" % path)
Ejemplo n.º 49
0
def must_exists(path):
    if path is None or not os.path.exists(path):
        raise interface.rigger_exception("file not exists : %s" % path)
Ejemplo n.º 50
0
 def res_help(resname):
     resobj  = impl.rg_ioc.ins_res(resname)
     if resobj is None :
         raise  interface.rigger_exception( "instance res fail! resname: %s" %(resname) )
     resobj.useage(rgio.simple_out)
Ejemplo n.º 51
0
import interface
import logging

from utls.rg_io import rg_logger

if len(interface.registed_cmd.items()) == 0:
    raise interface.rigger_exception("@cmd.__init__ no regist cmd to module")

for cmd, module in interface.registed_cmd.items():
    code = "from %s import %s_cmd" % (module, cmd)
    rg_logger.debug(" load module: %s" % code)
    try:
        exec code
    except Exception as e:
        raise interface.rigger_exception("@cmd.__init__ code error: %s \n %s" % (code, e))
Ejemplo n.º 52
0
 def res_help(resname):
     resobj = impl.rg_ioc.ins_res(resname)
     if resobj is None:
         raise interface.rigger_exception("instance res fail! resname: %s" %
                                          (resname))
     resobj.useage(rgio.simple_out)
Ejemplo n.º 53
0
def not_none(val, errmsg):
    if val is None:
        raise interface.rigger_exception(errmsg)
    return val
Ejemplo n.º 54
0
 def assert_eq(self, context):
     value = res_utls.value(self.value)
     expect = res_utls.value(self.expect)
     if value != expect:
         raise interface.rigger_exception("value: %s , expect : %s " %
                                          (value, expect))
Ejemplo n.º 55
0
 def get(self,name) :
     raise interface.rigger_exception(" %s no impl get methond " %self.__class__.__name__)
Ejemplo n.º 56
0
def require_value(value,expect,is_raise=True):
    if value.strip() != expect.strip() :
        if is_raise :
            raise interface.rigger_exception("value: %s , expect: %s " %(value,expect))
        return False ;
    return True