-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinfo.py
More file actions
22 lines (19 loc) · 697 Bytes
/
Copy pathinfo.py
File metadata and controls
22 lines (19 loc) · 697 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import cpuinfo, requests, socket, getpass
# import GPUtil
from platform import uname
def get_host_info() -> dict:
ipinfo = requests.get('http://ipinfo.io/json').json()
# gpus = GPUtil.getGPUs()
hostname = socket.gethostname().lower()
username = getpass.getuser().lower()
return {
'username': username,
'hostname': hostname,
'public_ip': ipinfo['ip'],
'local_ip': socket.gethostbyname(hostname),
'country': ipinfo['country'],
'city': ipinfo['city'],
'os': f'{uname().system} {uname().release} {uname().version}',
'cpu': cpuinfo.get_cpu_info()['brand_raw'],
# 'gpu': gpus[0].name if gpus else None
}