-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgpuz.py
More file actions
72 lines (61 loc) · 1.98 KB
/
gpuz.py
File metadata and controls
72 lines (61 loc) · 1.98 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import re
import datetime
import time
def open_gpuz(path = "GPU-Z Sensor Log2.txt"):
fh = open(path)
result = dict()
index = fh.readline().split(',')
for i in range(len(index)):
index[i] = index[i].strip().decode('cp1251')
index.remove(u'')
result["index"] = index
sensors = {item: [] for item in index}
for line in fh:
row = line.split(',')
if line.strip() == "":
continue
elif "Date" in line: # made pause visible
for s in index[1:]:
sensors[s][-1] = 0
continue
for i in range(len(index)):
if row[i].strip() == "-":
row[i] = 0
if u'Date' in index[i]:
r = row[i]
#sensors[index[i]].append( gpu_datetime(row[i]) ) # row[i].decode("cp1251")
sensors[index[i]].append( gpu_unixtime(row[i]) )
elif u"RPM" in index[i]:
sensors[index[i]].append( int(row[i]) )
elif u"MB" in index[i]:
sensors[index[i]].append( int(row[i]) )
else:
sensors[index[i]].append( float(row[i]) )
result["sensors"] = sensors
dimension = {}
for item in index:
d = re.findall("\[(.+)\]", item)
if len(d) != 0:
dimension[d[0]] = None
result["dimension"] = dimension.keys()
fh.close()
return result
def gpu_datetime(s):
"""s= '2016-02-27 08:27:24'"""
# date_object = datetime.strptime('Jun 1 2005 1:33PM', '%b %d %Y %I:%M%p')
s = s.strip().split(' ')
d = []
for x in s[0].split('-'):
d.append(int(x))
t = []
for x in s[-1].split(':'):
t.append(int(x))
return datetime.datetime(d[0], d[1], d[2], t[0], t[1], t[2])
def gpu_unixtime(s):
return time.mktime( time.strptime(s.strip(), "%Y-%m-%d %H:%M:%S") )
if __name__ == '__main__':
r = open_gpuz()
for item in r["index"]:
print item, r["sensors"][item]
print
print r["dimension"]