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")
def test_vars_echo(self): """ test this ------------------------ !R.vars: X : "a" Y : "b" !R.echo: value : "${X}/${Y}" """ testbox = res.modul() v1 = res.vars() v1.X = "a" v1.Y = "b" e1 = res.echo() e1.value = "${X}/${Y}" testbox.append(v1) testbox.append(e1) context = interface.run_context() interface.control_call(testbox, interface.controlable._config, context, '_config')
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")
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")
def test_muti_module(self): u = res.using() u._name = "using" u.path = self.conf u.modul = "m2" context = interface.run_context() u._before(context) u._config(context)
def test_context(self): context = interface.run_context() context.x = 1 context.keep() context.x = 2 self.assertEqual(context.x, 2) context.rollback() self.assertEqual(context.x, 1)
def test_context(self) : context = interface.run_context() context.x = 1 context.keep() context.x = 2 self.assertEqual(context.x,2) context.rollback() self.assertEqual(context.x,1)
def test_exp(self): context = interface.run_context() context.need_admin = "TRUE" context.mode = "rest" utls.rg_var.clean() utls.rg_var.import_context(context) v = utls.rg_var.value_of("${MODE}") self.assertEqual(v,'rest') utls.rg_var.clean()
def test_box_res(self): reslist = [] resbox = res_box() resbox.append(tc_data.simple_res("A")) resbox.append(tc_data.simple_res("B")) resbox.append(tc_data.simple_res("C")) context = interface.run_context() run = res_runner(resbox) run.config(context) #检查调用数据 for res in resbox.res: self.asst_res(res, "_config")
def test_box_res(self): reslist = [] resbox = res_box() resbox.append( tc_data.simple_res("A") ) resbox.append( tc_data.simple_res("B") ) resbox.append( tc_data.simple_res("C") ) context = interface.run_context() run = res_runner(resbox) run.config(context) #检查调用数据 for res in resbox.res : self.asst_res(res,"_config")
def runcmd(self,rargs,fun) : import utls.rg_yaml,copy utls.dbc.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 in self.env : for env_obj in env_data : res.node.env_regist(env_obj) if env_obj._name == env : main.append(env_obj) context = interface.run_context() # interface.control_call(main,fun,context) if len(self.sys) > 0 : for sys in self.sys : for sysobj in sys_data : res.node.sys_regist(sysobj) if sysobj._name == sys : main.append(sysobj) # interface.control_call(sysobj,fun,context) interface.control_call(main,fun,context,"unknow")
def runcmd(self, rargs, fun): import utls.rg_yaml, copy utls.dbc.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 in self.env: for env_obj in env_data: res.node.env_regist(env_obj) if env_obj._name == env: main.append(env_obj) context = interface.run_context() # interface.control_call(main,fun,context) if len(self.sys) > 0: for sys in self.sys: for sysobj in sys_data: res.node.sys_regist(sysobj) if sysobj._name == sys: main.append(sysobj) # interface.control_call(sysobj,fun,context) interface.control_call(main, fun, context, "unknow")
def test_vars_echo(self): """ test this ------------------------ !R.vars: X : "a" Y : "b" !R.echo: value : "${X}/${Y}" """ testbox = res.modul() v1 = res.vars() v1.X = "a" v1.Y = "b" e1 = res.echo() e1.value = "${X}/${Y}" testbox.append(v1) testbox.append(e1) context = interface.run_context() interface.control_call( testbox,interface.controlable._config,context,'_config')
def test_simple_res(self): res = tc_data.simple_res() context = interface.run_context() self.asst_call(res, context, res_runner.config, '_config') self.asst_call(res, context, res_runner.start, '_start') self.asst_call(res, context, res_runner.stop, '_stop')
def test_simple_res(self): res = tc_data.simple_res() context = interface.run_context() self.asst_call(res, context,res_runner.config,'_config' ) self.asst_call(res, context,res_runner.start,'_start' ) self.asst_call(res, context,res_runner.stop,'_stop' )