How to use list_domains method in localstack

Best Python code snippet using localstack_python

a_task.py

Source:a_task.py Github

copy

Full Screen

...58 :param domain_na_tes: test domain names59 """60 raise NotImplementedError61 @abstractmethod62 def get_list_domains(self):63 """64 1. get list of domain names65 2. better use method than property so new domains can be added66 """67 raise NotImplementedError68 @abstractproperty69 def list_str_y(self):70 raise NotImplementedError71 @abstractproperty72 def isize(self):73 """image channel, height, width"""74 raise NotImplementedError75 ###########################################################################76 @property77 def dim_y(self):78 """classification dimension"""79 return len(self.list_str_y)80 @property81 def list_domain_tr(self):82 if self._list_domain_tr is None:83 raise RuntimeError("task not intialized!")84 return self._list_domain_tr85 @property86 def loader_tr(self):87 """loader of mixed train domains"""88 return self._loader_tr89 @property90 def loader_val(self):91 """loader of validation dataset on the training domains"""92 return self._loader_val93 @property94 def loader_te(self):95 """loader of mixed test domains"""96 return self._loader_te97 @property98 def task_name(self):99 """100 The basic name of the task, without configurations101 """102 return type(self).__name__[8:].lower()103 def get_na(self, na_tr, na_te):104 """105 task name appended with configurations106 :param na_tr: training domain names107 :param na_te: test domain names108 """109 list_tr, list_te = self.get_list_domains_tr_te(na_tr, na_te)110 str_tr = "_".join(list_tr)111 str_te = "_".join(list_te)112 return "_".join([self.task_name, "te", str_te]) # train domain names are too long113 def is_myjob(self, request):114 """115 :param request: string116 """117 return request == self.task_name118 def get_list_domains_tr_te(self, tr_id, te_id):119 """120 For static DG task, get train and test domains list.121 :param tr_id: training domain ids;122 int or str, or a list of int or str, or None;123 if None, then assumed to be the complement of te_id.124 :param te_id: test domain ids;125 int or str, or a list of int or str; required.126 :return: list of training domain names, list of test domain names.127 """128 list_domains = self.get_list_domains()129 list_domain_te = parse_domain_id(te_id, list_domains)130 assert set(list_domain_te).issubset(set(list_domains))131 if tr_id is None:132 list_domain_tr = [did for did in list_domains if133 did not in list_domain_te]134 else:135 list_domain_tr = parse_domain_id(tr_id, list_domains)136 if not set(list_domain_tr).issubset(set(list_domains)):137 raise RuntimeError(138 "training domain %s is not subset of available domains %s"139 % (list_domain_tr, list_domains))140 if set(list_domain_tr) & set(list_domain_te):141 warnings.warn(142 "The sets of training and test domains overlap -- beware of data leakage or training to the test!",143 RuntimeWarning144 )145 self.dim_d_tr = len(list_domain_tr)146 self._list_domain_tr = list_domain_tr147 return list_domain_tr, list_domain_te148 def sample_sav(self, root, batches=5, subfolder_na="task_sample"):149 """150 sample data from task and save to disk151 """152 folder_na = os.path.join(root, self.task_name, subfolder_na)153 img_loader2dir(self.loader_te,154 list_domain_na=self.get_list_domains(),155 list_class_na=self.list_str_y,156 folder=folder_na,157 batches=batches)158 img_loader2dir(self.loader_tr,159 list_domain_na=self.get_list_domains(),160 list_class_na=self.list_str_y,161 folder=folder_na,...

Full Screen

Full Screen

main.py

Source:main.py Github

copy

Full Screen

...64 database_dict_update = {}65 for key, value in checked_dict_current.items():66 id = dict_domains.pop(key)67 database_dict_update.update({id:value})68 await write_mx_list_domains(database_dict_update, db_connection)69 checked_dict.update(checked_dict_current)70 log = f"Work Time: {round(time() - start_time, 1)}s | "71 log += f"Checked: {len(checked_dict)}. Residue: {len(list_domains)} | "72 log += f"DNS: {dns_server} | "73 log += f"[{len(result.get('checked'))}:{len(result.get('unchecked'))}]"74 list_domains.extend(result.get('unchecked'))75 if result.get('ban') or \76 len(result.get('checked')) < current_size_chunk / 100:77 list_dns_servers.append(dns_server)78 dns_server = list_dns_servers.pop(0)79 log += " | DNS UPDATE"80 print(log)81 print(f'Checker end! Length checked dict: {len(checked_dict)}')82 return checked_dict...

Full Screen

Full Screen

Insert.py

Source:Insert.py Github

copy

Full Screen

1from models import Intents2class Insert:3 def __init__(self, intent):4 self.intent = intent5 def insert_intent(self):6 post=Intents(IntentType=self.intent.IntentType,Intent_State=self.intent.Intent_State,Intent_Target=self.intent.Intent_Target)7 cond=self.intent.Conditions8 Name=''9 Gw=''10 for i in range(0,len(cond)):11 post.Conditions.append(Policy=cond[i].Policy)12 constr=cond[i].Constraints13 for j in range(0,len(constr)):14 list_constraints=[]15 try:16 list_constraints.append(constr[j].Level)17 except:18 list_constraints.append(None)19 try:20 list_constraints.append(constr[j].Bool)21 except:22 list_constraints.append(None)23 post.Conditions[i].Constraints.append(Level=list_constraints[0],Bool=list_constraints[1])24 try:25 domains=constr[j].Domains26 for l in range(0,len(domains)):27 list_domains=[]28 try:29 list_domains.append(domains[l].Action)30 Name=domains[l].Action31 except:32 list_domains.append(None)33 try:34 list_domains.append(domains[l].Traffic_Type)35 except:36 list_domains.append(None)37 try:38 list_domains.append(domains[l].Period)39 except:40 list_domains.append(None)41 try:42 list_domains.append(domains[l].Domain)43 Gw=domains[l].Domain44 except:45 list_domains.append(None)46 try:47 list_domains.append(domains[l].Limit)48 except:49 list_domains.append(None)50 try:51 list_domains.append(domains[l].Source)52 except:53 list_domains.append(None)54 try:55 list_domains.append(domains[l].Destination)56 except:57 list_domains.append(None)58 try:59 list_domains.append(domains[l].Level)60 except:61 list_domains.append(None)62 try:63 list_domains.append(domains[l].Bool)64 except:65 list_domains.append(None)66 try:67 list_domains.append(domains[l].Name)68 except:69 list_domains.append(None)70 try:71 list_domains.append(domains[l].Acess)72 except:73 list_domains.append(None)74 try:75 list_domains.append(domains[l].Performance)76 except:77 list_domains.append(None)78 print(list_domains)79 post.Conditions[i].Constraints[j].Domains.append(Action=list_domains[0],Traffic_Type=list_domains[1],Period=list_domains[2],Domain=list_domains[3],Limit=list_domains[4],Source=list_domains[5],Destination=list_domains[6],Level=list_domains[7],Bool=list_domains[8],Name=list_domains[9],Acess=list_domains[10],Performance=list_domains[11])80 except:81 print("No Domains")82 post.store()...

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 localstack 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