-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathexample.py
More file actions
31 lines (25 loc) · 880 Bytes
/
example.py
File metadata and controls
31 lines (25 loc) · 880 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"""Get grade of multiple servers."""
import asyncio
import logging
from typing import List
from ssllabs import Ssllabs
from ssllabs.data.host import HostData
HOSTS = [
"devolo.com",
"www.devolo.com",
]
async def analyze(hosts: List[str]) -> List[HostData]:
"""Analyze servers."""
ssllabs = Ssllabs()
if not await ssllabs.availability():
raise
return await asyncio.gather(*[ssllabs.analyze(host=host) for host in hosts])
if __name__ == "__main__":
logging.basicConfig(level=logging.INFO, format="%(asctime)s: %(message)s")
results = asyncio.run(analyze(HOSTS))
for result in results:
for endpoint in result.endpoints:
if endpoint.grade:
logging.info("Grade of %s (%s): %s", result.host, endpoint.ipAddress, endpoint.grade)
else:
logging.error(endpoint.statusMessage)