def test_002(self): HEADING("set default variable") name = "myvar" value = "myvalue" Var.set(name, value) print(Var.list()) self._check(value)
def test_002(self): HEADING("set default variable") name = "myvar" value = "myvalue" Var.set(name, value) print(Var.list()) self._check(value)
def test_003(self): HEADING("delete default variable") Var.clear() name = "deleteme" value = "myvalue" Var.set(name, value) print(Var.list()) Var.delete(name) print(Var.list()) self._check("None")
def test_003(self): HEADING("delete default variable") Var.clear() name = "deleteme" value = "myvalue" Var.set(name, value) print(Var.list()) Var.delete(name) print(Var.list()) self._check("None")
def do_var(self, arg, arguments): """ Usage: var list var delete NAMES var NAME=VALUE var NAME Arguments: NAME Name of the variable NAMES Names of the variable separated by spaces VALUE VALUE to be assigned special vars date and time are defined """ if arguments['list'] or arg == '' or arg is None: # self._list_variables() print(Var.list()) return "" elif arguments['NAME=VALUE'] and "=" in arguments["NAME=VALUE"]: (variable, value) = arg.split('=', 1) if value == "time" or value == "now": value = datetime.datetime.now().strftime("%H:%M:%S") elif value == "date": value = datetime.datetime.now().strftime("%Y-%m-%d") elif value.startswith("default."): name = value.replace("default.", "") value = Default.get(name=name, category="general") elif "." in value: try: config = ConfigDict("cloudmesh.yaml") value = config[value] except Exception as e: Console.error( "can not find variable {} in cloudmesh.yaml".format( value)) value = None # self._add_variable(variable, value) Var.set(variable, value) return "" elif arguments['NAME=VALUE'] and "=" not in arguments["NAME=VALUE"]: try: v = arguments['NAME=VALUE'] # Console.ok(str(self.variables[v])) Console.ok(str(Var.get(v))) except: Console.error('variable {:} not defined'.format( arguments['NAME=VALUE'])) elif arg.startswith('delete'): variable = arg.split(' ')[1] Var.delete(variable) # self._delete_variable(variable) return ""
def test_002(self): """ set default variable :return: """ HEADING() name = "myvar" value = "myvalue" Var.set(name, value) print (Var.list()) assert Var.get(name) == value self._check(value)
def test_002(self): """ set default variable :return: """ HEADING() name = "myvar" value = "myvalue" Var.set(name, value) print(Var.list()) assert Var.get(name) == value self._check(value)
def do_var(self, arg, arguments): """ Usage: var list var delete NAMES var NAME=VALUE var NAME Arguments: NAME Name of the variable NAMES Names of the variable separated by spaces VALUE VALUE to be assigned special vars date and time are defined """ if arguments['list'] or arg == '' or arg is None: # self._list_variables() print(Var.list()) return "" elif arguments['NAME=VALUE'] and "=" in arguments["NAME=VALUE"]: (variable, value) = arg.split('=', 1) if value == "time" or value == "now": value = datetime.datetime.now().strftime("%H:%M:%S") elif value == "date": value = datetime.datetime.now().strftime("%Y-%m-%d") elif value.startswith("default."): name = value.replace("default.", "") value = Default.get(name=name, category="general") elif "." in value: try: config = ConfigDict("cloudmesh.yaml") value = config[value] except Exception as e: Console.error("can not find variable {} in cloudmesh.yaml".format(value)) value = None # self._add_variable(variable, value) Var.set(variable, value) return "" elif arguments['NAME=VALUE'] and "=" not in arguments["NAME=VALUE"]: try: v = arguments['NAME=VALUE'] # Console.ok(str(self.variables[v])) Console.ok(str(Var.get(v))) except: Console.error('variable {:} not defined'.format(arguments['NAME=VALUE'])) elif arg.startswith('delete'): variable = arg.split(' ')[1] Var.delete(variable) # self._delete_variable(variable) return ""