-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.py
35 lines (28 loc) · 976 Bytes
/
utils.py
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
32
33
34
35
import json
import logging
import platform
import re
import socket
import uuid
import psutil
def getSystemInfoDict():
try:
info = dict()
info['platform'] = platform.system()
info['platform-release'] = platform.release()
info['platform-version'] = platform.version()
info['architecture'] = platform.machine()
info['hostname'] = socket.gethostname()
info['ip-address'] = socket.gethostbyname(socket.gethostname())
info['mac-address'] = ':'.join(re.findall('..',
'%012x' % uuid.getnode()))
info['processor'] = platform.processor()
info['ram'] = str(
round(psutil.virtual_memory().total / (1024.0 ** 3)))+" GB"
return info
except Exception as e:
logging.exception(e)
def getSystemInfoString():
return json.dumps(getSystemInfoDict())
def getSystemInfoJson():
return json.loads(getSystemInfoString())