-
Notifications
You must be signed in to change notification settings - Fork 8
/
permanence.py
56 lines (47 loc) · 1.4 KB
/
permanence.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
import urllib, os,json
thisVersion = 1.0
#manually changing this bit for the Mac/Windows builds...I know it's ugly but shuttup.
thisPlatform = 'Mac'
def checkUpdate():
url = "http://www.vidiiUstreamer.com/updateManifest.json"
try:
updateManif = urllib.urlopen(url)
updateObject = json.loads(updateManif.read())
print updateObject["version"]
global thisVersion
global thisPlatform
link = str(updateObject["link"]).replace('%s',thisPlatform)
if thisVersion < updateObject["version"]:
updateString = "Changes include... %s"%(updateObject["changes"])
else:
print "latest"
raise Exception("This version is latest.")
return [updateString,link]
except:
#either not connected to the internet or what we got wasn't JSON. no biggy.
print "update failed"
return False
class localStorage():
datadict = {}
datafile = "config.txt"
def __init__(self):
self.datadict = {}
if not (os.path.exists(self.datafile)):
open("config.txt",'w+').write("{}")
self.datadict = {}
self.datadict = json.load(open("config.txt",'r'))
def store(self,newdict):
for key in newdict.keys():
self.datadict[key] = newdict[key]
self.write()
def read(self,key):
print key + ' being read'
try:
return self.datadict[key]
except:
return []
def clear(self):
self.datadict = {}
open("config.txt",'w+').write("{}")
def write(self):
open("config.txt",'w+').write(json.dumps(self.datadict))