How to use set_local_config method in lisa

Best Python code snippet using lisa_python

main.py

Source:main.py Github

copy

Full Screen

...58 if(pars_args.contest): args['c_name'] = pars_args.contest59 if(pars_args.type): args['c_type'] = pars_args.type60 if(pars_args.prob): args['p_name'] = pars_args.prob61 if(pars_args.site): args['c_site'] = pars_args.site62 Args.set_local_config(args)63 elif(first_arg == "run"):64 '''65 runs the given problem.66 if no prob given it will check in cache.67 if no prob in cache then it will stop68 sets up cache for next time69 '''70 if(not Args.check_init()):71 Colour.print('coolkit repo not found',Colour.YELLOW)72 Args.init_repo()73 args['inp'] = pars_args.inp # can be none74 args['test'] = pars_args.test # 0 means all75 args['p_name'] = pars_args.prob # can be None76 config_data = Args.fetch_data_from_local_config()77 args['c_type'] = config_data['c_type'] # contest/gym78 args['c_name'] = config_data['c_name'] # can be None79 args['c_site'] = config_data['c_site'] # can be None80 if(not args['c_name']):81 Colour.print('contest not set, please set it : `coolkit set -c <contest_num>`',Colour.RED)82 if(debug): Colour.print('repo at : '+ Args.check_init(),Colour.CYAN)83 sys.exit(1)84 if(not args['inp']):85 Colour.print('no input file provided or found in cache',Colour.RED)86 sys.exit(1)87 if(not args['p_name']):88 Colour.print("Prob name not provided, trying to detect from filename",Colour.YELLOW)89 p = get_problem_name(args['inp'].split('/')[-1])90 if(p == None):91 Colour.print("Unable to detect prob name from file name",Colour.YELLOW)92 p = config_data['p_name']93 if(p == None):94 Colour.print('No cached problem name found',Colour.YELLOW)95 Colour.print('Please provide the problem name using -p option',Colour.RED)96 Args.set_local_config({'inp':args['inp']}) #cache up the input file for next turn97 sys.exit(1)98 args['p_name'] = p99 Args.set_local_config(args) #cache up the args for next turn100 Args.run(args)101 elif(first_arg == "submit"):102 if(not Args.check_init()):103 Args.init_repo()104 args['inp'] = pars_args.inp # can be None105 args['p_name'] = pars_args.prob # can be None106 config_data = Args.fetch_data_from_local_config()107 args['c_name'] = config_data['c_name'] # can be None108 args['c_type'] = config_data['c_type']109 args['c_site'] = config_data['c_site']110 if(not args['c_name']):111 Colour.print('contest not set, please set it : `coolkit set -c <contest_num>`',Colour.RED)112 if(debug): Colour.print('repo at : '+ Args.check_init(),Colour.CYAN)113 sys.exit(1)114 if(not args['inp']):115 Colour.print('no input file provided or found in cache',Colour.RED)116 sys.exit(1)117 if(not args['p_name']):118 Colour.print("Prob name not provided, trying to detect from filename",Colour.YELLOW)119 p = get_problem_name(args['inp'].split('/')[-1])120 if(p == None):121 Colour.print("Unable to detect prob name from file name",Colour.YELLOW)122 Colour.print('Please provide the problem name using -p option',Colour.RED)123 sys.exit(1)124 args['p_name'] = p125 config_data = Args.fetch_global_config()126 if(not config_data['user']):127 Colour.print('Please configure your username using "coolkit config -u <username>"',Colour.YELLOW)128 config_data['user'] = input('Enter your username : ') # it will also store it129 if(not config_data['pswd']):130 Colour.print('Please configure your password using "coolkit config -p <password>"',Colour.YELLOW)131 config_data['pswd'] = getpass.getpass('Enter your password : ') # it will also store it132 args['user'] = config_data['user']133 args['pswd'] = config_data['pswd']134 args['test'] = -1135 args['force'] = pars_args.force136 args['force_stdout'] = pars_args.force_stdout137 if(pars_args.secondary): # special case for others138 if config_data.get('secondary_user') and config_data.get('secondary_pswd'):139 args['user'] = config_data['secondary_user']140 args['pswd'] = config_data['secondary_pswd']141 if(debug): Colour.print('Using secondary user, '+args['user'],Colour.GREEN)142 else:143 Colour.print('Please configure your secondary user in config file manually',Colour.YELLOW)144 sys.exit(0)145 Args.submit_it(args)146 elif(first_arg == "fetch"):147 # Args.check_init() # fetching can be done even without this if contest name given148 args['c_name'] = pars_args.contest # can be None149 args['c_type'] = pars_args.type150 args['c_site'] = pars_args.site151 args['force'] = pars_args.force152 if(not args['c_name']):153 if(not Args.check_init()):154 Colour.print('no contest provided, either provide contest using -c or run command from a coolkit repo',Colour.RED)155 sys.exit(1)156 config_data = Args.fetch_data_from_local_config()157 args['c_name'] = config_data['c_name'] # can be none158 if(not args['c_name']):159 Colour.print('contest not set, use `coolkit set -c <contest num>`, or provide contest name using -c parameter',Colour.RED)160 if(debug): Colour.print('repo at : '+ Args.check_init(),Colour.CYAN)161 sys.exit(1)162 Args.fetch_contest(args)163 elif(first_arg == "config"):164 config_data = Args.fetch_global_config()165 if(pars_args.user):166 config_data['user'] = pars_args.user167 else:168 user = input('Enter your user name (default: '+ str(config_data.get('user')) +'): ') # str for None169 if user != '': config_data['user'] = user170 if(pars_args.pswd):171 config_data['pswd'] = pars_args.pswd172 else:173 pswd = getpass.getpass('Enter your password (press enter to not to change): ')174 if pswd != '': config_data['pswd'] = pswd175 elif(first_arg == "view"):176 second_arg = pars_args.second_arg177 config_data = Args.fetch_global_config().data178 if(second_arg == "user"):179 u_name = pars_args.u_name180 if(not u_name):181 if not config_data.get('user'):182 Colour.print('Please provide username using flag -u/--user or configure your username',Colour.YELLOW)183 sys.exit(0)184 u_name = input('Enter username (default: '+ config_data.get('user') +'): ')185 if u_name == '': u_name = config_data.get('user')186 dummy_user = Dummy_user(u_name,verbose=False)187 dummy_user.print_data()188 print(Tabular(dummy_user.contest_table))189 elif(second_arg == "contest"):190 c_name = pars_args.c_name191 if(not c_name):192 if(Args.check_init()):193 Colour.print('contest not set, use `coolkit set -c <contest num>`',Colour.YELLOW)194 c_name = input('Enter contest name : ')195 temp_contest = Contest(c_name)196 temp_contest.pull_contest()197 temp_contest.display_contest()198 elif(second_arg == "standings"):199 c_name = pars_args.c_name200 if(not c_name):201 if(Args.check_init()):202 Colour.print('contest not set, use `coolkit set -c <contest num>`',Colour.YELLOW)203 c_name = input('Enter contest name : ')204 if(not config_data['user']):205 Colour.print('Please configure your username using "coolkit config -u <username>"',Colour.RED)206 config_data['user'] = input('Enter your username : ')207 if(not config_data['pswd']):208 Colour.print('Please configure your password using "coolkit config -p <password>"',Colour.RED)209 config_data['pswd'] = getpass.getpass('Enter your password : ')210 temp_Standing = Standing(c_name,config_data['user'],config_data['pswd'])211 temp_Standing.show()212 elif(second_arg == "friends"):213 config_data = Args.fetch_global_config()214 if(not config_data['user']):215 Colour.print('Please configure your username using "coolkit config -u <username>"',Colour.RED)216 config_data['user'] = input('Enter your username : ') # it will save it too217 if(not config_data['pswd']):218 Colour.print('Please configure your password using "coolkit config -p <password>"',Colour.RED)219 config_data['pswd'] = getpass.getpass('Enter your password : ')220 temp_friends = Friends(config_data['user'],config_data['pswd'])221 temp_friends.show()222 elif(second_arg == "prob"):223 if(not Args.check_init()):224 Colour.print('please run this command from a coolkit repo',Colour.RED)225 sys.exit(1)226 p_name = pars_args.p_name227 c_name = Args.fetch_data_from_local_config()['c_name']228 if(not c_name):229 Colour.print('contest not set, use `coolkit set -c <contest num>`',Colour.YELLOW)230 c_name = input('Enter contest name : ')231 Args.set_local_config({'c_name',c_name})232 if(not p_name):233 Colour.print('problem not set, use `coolkit set -p <problem name>`',Colour.YELLOW)234 p_name = input('Enter problem name : ')235 Args.set_local_config({'p_name',p_name})236 prob = Problem(p_name,c_name)237 prob.pull_problem(force=False)238 prob.display_problem()239 Colour.print(prob.link,Colour.CYAN)240 elif(second_arg == "upcoming"):241 Contest.upcoming_contest(display=True)242def main():243 try:244 safe_main()245 except KeyboardInterrupt:246 Colour.print('Exiting safely ... ')247 sys.exit(1)248if __name__ == '__main__':249 main()

Full Screen

Full Screen

datasrc_clients_mgr_test.py

Source:datasrc_clients_mgr_test.py Github

copy

Full Screen

...51 self.assertIsNotNone(clist)52 self.assertTrue(clist.find(Name('bind'), True, False)[2])53 # Reconfigure it with a simple new config: the list for CH will be54 # gone, and and an empty list for IN will be installed.55 self.__datasrc_cfg.set_local_config({"classes": {"IN": []}})56 self.__mgr.reconfigure({}, self.__datasrc_cfg)57 self.assertIsNone(self.__mgr.get_client_list(RRClass.CH))58 self.assertIsNotNone(self.__mgr.get_client_list(RRClass.IN))59 def test_reconfigure_error(self):60 """Check reconfigure failure preserves the old config."""61 # Configure it with the default62 self.__mgr.reconfigure({}, self.__datasrc_cfg)63 self.assertIsNotNone(self.__mgr.get_client_list(RRClass.CH))64 # Then try invalid configuration65 self.assertRaises(ConfigError, self.__mgr.reconfigure, {}, 42)66 self.assertIsNotNone(self.__mgr.get_client_list(RRClass.CH))67 # Another type of invalid configuration: exception would come from68 # the C++ wrapper.69 self.__datasrc_cfg.set_local_config({"classes": {"IN": 42}})70 self.assertRaises(ConfigError,71 self.__mgr.reconfigure, {}, self.__datasrc_cfg)72 self.assertIsNotNone(self.__mgr.get_client_list(RRClass.CH))73 def check_client_list_content(self, clist):74 """Some set of checks on given data source client list.75 Used by a couple of tests below.76 """77 datasrc_client, finder, exact = clist.find(Name('bind'))78 self.assertTrue(exact)79 # Reset the client list80 clist = None81 # Both finder and datasrc client should still work without causing82 # disruption. We shouldn't have to inspect too much details of the83 # returned values.84 result, rrset, _ = finder.find(Name('bind'), RRType.SOA)85 self.assertEqual(Name('bind'), rrset.get_name())86 self.assertEqual(RRType.SOA, rrset.get_type())87 self.assertEqual(RRClass.CH, rrset.get_class())88 self.assertEqual(RRTTL(0), rrset.get_ttl())89 # iterator should produce some non empty set of RRsets90 rrsets = datasrc_client.get_iterator(Name('bind'))91 self.assertNotEqual(0, len(list(rrsets)))92 def test_reconfig_while_using_old(self):93 """Check datasrc client and finder can work even after list is gone."""94 self.__mgr.reconfigure({}, self.__datasrc_cfg)95 clist = self.__mgr.get_client_list(RRClass.CH)96 self.__datasrc_cfg.set_local_config({"classes": {"IN": []}})97 self.__mgr.reconfigure({}, self.__datasrc_cfg)98 self.check_client_list_content(clist)99 def test_get_clients_map(self):100 # This is basically a trivial getter, so it should be sufficient101 # to check we can call it as we expect.102 # Initially map is empty, the generation ID is None.103 self.assertEqual((None, {}), self.__mgr.get_clients_map())104 # gen Id is not in spec, so we need to set it by hand105 self.__datasrc_cfg.data['_generation_id'] = 1106 self.__mgr.reconfigure({}, self.__datasrc_cfg)107 genid, clients_map = self.__mgr.get_clients_map()108 self.assertEqual(1, genid)109 self.assertEqual(2, len(clients_map)) # should contain 'IN' and 'CH'110 # Check the retrieved map is usable even after further reconfig().111 self.__datasrc_cfg.set_local_config({"classes": {"IN": []},112 "_generation_id": 2})113 self.__mgr.reconfigure({}, self.__datasrc_cfg)114 self.check_client_list_content(clients_map[RRClass.CH])115 # confirm generation ID is updated116 self.assertEqual(2, self.__mgr.get_clients_map()[0])117if __name__ == "__main__":118 bundy.log.init("bundy")119 bundy.log.resetUnitTestRootLogger()...

Full Screen

Full Screen

config.py

Source:config.py Github

copy

Full Screen

...73 config[field] = value74 if args.config_type == "shared":75 set_shared_config(config)76 elif args.config_type == "local":77 set_local_config(config)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run lisa automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful