Best Python code snippet using autotest_python
test-1.py
Source:test-1.py
...76 # otr_filter_func = None77 source.make_fingerprints(with_filter=src_filter_func)78 other.make_fingerprints(with_filter=otr_filter_func)79 # def tr_hostname(val):80 # return normalize_hostname(val).replace('/', '-')81 source.make_keys("hostname", with_translate=normalize_hostname)82 other.make_keys("hostname", with_translate=normalize_hostname)83 source.make_keys("sn")84 other.make_keys("sn")85 def sn_cmp(val):86 return val if not val.endswith("_1") else val.partition("_1")[0]87 comparitors = {88 "sn": sn_cmp,89 # "model": str.upper,90 # "os_name": lambda f: f.replace("-", ""),91 }92 missing, changes = diff.diff(source, other, fields_cmp=comparitors)93 missing_sn = [94 (fp, change) for fp, change in changes if "sn" in change and fp["sn"] == ""...
domain-limit-list.py
Source:domain-limit-list.py
1# -*- coding: utf-8 -*-2import datetime3import time4from datetime import timezone5import pytz6import whois7import yaml8from jinja2 import Environment, FileSystemLoader9from publicsuffix import PublicSuffixList10# whoisåç
§11def get_whois(host):12 time.sleep(2)13 return whois.whois(host)14# YamlãOpen15f = open("./chk_hosts.yml",encoding='utf-8')16chk_hosts = yaml.load(f)17chk_hosts = chk_hosts['chk_host_list']18#print (chk_hosts)19domain_list = []20# ãµããã¡ã¤ã³ãæ¥æ¬èªãã¡ã¤ã³ãæ£è¦åãã21for chk in chk_hosts:22 hostname = chk['uri']23 if hostname is None:24 next25 normalize_hostname = hostname.encode('idna').decode('utf-8')26 psl = PublicSuffixList()27 domain_list.append(psl.get_public_suffix(normalize_hostname))28#print (domain_list)29uniq_domain_list = list(set(domain_list))30list = []31# éè¤ãé¤å»ããWhoisãå¼ã32for domain in uniq_domain_list:33 registrar = "ã"34 update_date = "ã"35 expires_date = "ã"36 limit_day = "ã"37 try:38 whois_ans = get_whois(domain)39 registrar = whois_ans.registrar40 # print(domain)41 # print(whois_ans)42 # print(type(whois_ans.updated_date))43 if isinstance(whois_ans.updated_date, type(list)):44 whois_update_date = whois_ans.updated_date[0]45 else:46 whois_update_date = whois_ans.updated_date47 if isinstance(whois_ans.expiration_date, type(list)):48 whois_expiration_date = whois_ans.expiration_date[0]49 else:50 whois_expiration_date = whois_ans.expiration_date51 except whois.parser.PywhoisError as e:52 print("Whoisã«è¦ã¤ãããªã")53 continue54 print(domain)55 # print(whois_ans)56 if whois_update_date is None:57 print("Whoisæ
å ±åå¾ã«å¤±æ")58 continue59 # ãã®ã¾ã¾å¦çããã¨JSTã¨èªèããã¦æå»ããããã®ã§ãä¸ç´°å·¥ã ãã©æéãããã60 update_date = whois_update_date - datetime.timedelta(hours=9)61 expires_date = whois_expiration_date - datetime.timedelta(hours=9)62 jp = pytz.timezone('Asia/Tokyo')63 # print(update_date.astimezone(jp))64 diff = (expires_date.astimezone(jp) - datetime.datetime.now(jp)65 ) // datetime.timedelta(days=1)66 # print(update_date)67 # print(expires_date)68 # print(diff)69 whois_propaty = {"domain": domain, "registrar": registrar,70 "update_date": update_date, "expires_date": expires_date, "limit_day": diff}71 list.append(whois_propaty)72# æ®ãæ¥æ°ã¨ãã¹ãåã§ã½ã¼ã73list = sorted(list, key=lambda x: (x["limit_day"], x["domain"]))74# HTMLä½æ75env = Environment(loader=FileSystemLoader('./', encoding='utf8'))76templete = env.get_template('./domain_limit.html.j2')77data = {"list": list}78output = templete.render(data)79# Windowsç°å¢ã ã¨ã¨ã³ã³ã¼ãæå®ããªãã¨åºåãSJISã«ãªãã80with open('domain_limit.html', 'w', encoding='utf-8') as f:81 f.write(output)...
normalize_hostname.py
Source:normalize_hostname.py
...37 any_domain = "|".join(38 map(re.escape, map(partial(concat, "."), cfg_obj.domain_names))39 )40 return partial(re.compile(any_domain).sub, repl="")41def normalize_hostname(hostname):...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!