How to use normalize_hostname method in autotest

Best Python code snippet using autotest_python

test-1.py

Source: test-1.py Github

copy

Full Screen

...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"] == ""...

Full Screen

Full Screen

domain-limit-list.py

Source: domain-limit-list.py Github

copy

Full Screen

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)...

Full Screen

Full Screen

normalize_hostname.py

Source: normalize_hostname.py Github

copy

Full Screen

...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):...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Scala Testing: A Comprehensive Guide

Before we discuss Scala testing, let us understand the fundamentals of Scala and how this programming language is a preferred choice for your development requirements.The popularity and usage of Scala are rapidly rising, evident by the ever-increasing open positions for Scala developers.

What Agile Testing (Actually) Is

So, now that the first installment of this two fold article has been published (hence you might have an idea of what Agile Testing is not in my opinion), I’ve started feeling the pressure to explain what Agile Testing actually means to me.

How To Choose The Right Mobile App Testing Tools

Did you know that according to Statista, the number of smartphone users will reach 18.22 billion by 2025? Let’s face it, digital transformation is skyrocketing and will continue to do so. This swamps the mobile app development market with various options and gives rise to the need for the best mobile app testing tools

A Complete Guide To CSS Houdini

As a developer, checking the cross browser compatibility of your CSS properties is of utmost importance when building your website. I have often found myself excited to use a CSS feature only to discover that it’s still not supported on all browsers. Even if it is supported, the feature might be experimental and not work consistently across all browsers. Ask any front-end developer about using a CSS feature whose support is still in the experimental phase in most prominent web browsers. ????

Appium Testing Tutorial For Mobile Applications

The count of mobile users is on a steep rise. According to the research, by 2025, it is expected to reach 7.49 billion users worldwide. 70% of all US digital media time comes from mobile apps, and to your surprise, the average smartphone owner uses ten apps per day and 30 apps each month.

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