forked from scottjacksonx/hu
-
Notifications
You must be signed in to change notification settings - Fork 1
/
hu.py
82 lines (60 loc) · 1.89 KB
/
hu.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
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
73
74
75
76
77
78
79
80
81
82
# Plugin declarations
plugin_modules = []
import hu_currentlyplaying.hu_currentlyplaying
plugin_modules.append(hu_currentlyplaying.hu_currentlyplaying)
import hu_lastfm.hu_lastfm
plugin_modules.append(hu_lastfm.hu_lastfm)
import hu_googleweather.hu_googleweather
plugin_modules.append(hu_googleweather.hu_googleweather)
import hu_ssidname.hu_ssidname
plugin_modules.append(hu_ssidname.hu_ssidname)
import hu_openbrowsertabs.hu_openbrowsertabs
plugin_modules.append(hu_openbrowsertabs.hu_openbrowsertabs)
import hu_openapps.hu_openapps
plugin_modules.append(hu_openapps.hu_openapps)
# End plugin declarations
import datetime
import time
class hu:
"""
i'm hu. i'm a big, important class. i watch you and i take notes.
i hope you like me.
"""
def takeSnapshot(self):
"""
this is the part where i look at all of the things you want me to record.
i look at the things, take a reading for each of them, and record them.
hopefully.
"""
snapshot = "<entry time=\""
snapshotTime = str(time.strftime("%a, %d %b %Y %H:%M:%S", time.localtime()))
snapshot += snapshotTime + "\">\n"
for plugin in plugin_modules:
entryData = plugin.getData()
if entryData != "":
snapshot += str(entryData + "\n")
snapshot += "</entry>"
print snapshot
return snapshot
def writeSnapshotToLogFile(self, anEntry):
"""
this is the bit where i write the things down in my big book.
if you want me to write down something secret, it's ok -- i won't tell.
promise.
"""
try:
logFile = open("hu-notes.txt", "r")
currentLog = logFile.readlines()
logFile.close()
except:
currentLog = []
logFile = open("hu-notes.txt", "w")
logFile.write("<hu>\n")
for i in range(1, len(currentLog) - 1):
logFile.write(currentLog[i])
logFile.write(anEntry)
logFile.write("\n</hu>")
logFile.close()
hu = hu()
snapshot = hu.takeSnapshot()
hu.writeSnapshotToLogFile(snapshot)