-
Notifications
You must be signed in to change notification settings - Fork 156
/
update
47 lines (42 loc) · 1.26 KB
/
update
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
#!/usr/bin/env python
import urllib2,os,pynotify
with open("CONFIG",'r') as data:
for l in data.read().split("\n"):
print l
if l.startswith("UPDATEID="):
updateID = l.replace("\n",'').replace("UPDATEID=",'')
f = urllib2.urlopen("http://palaver.bmandesigns.com/functions.php?f=coreUpdate&id="+updateID)
data = f.read()
print data
id,files = data.split("|$|")
files = files.split("|#|")
if id > updateID:
f = urllib2.urlopen("http://github.com/JamezQ/Palaver/archive/master.zip")
with open('update.zip', "wb") as local_file:
local_file.write(f.read())
os.system("unzip -q update.zip -d Updates")
for f in files:
if f != '':
print f
os.system("mkdir "+os.path.dirname(f))
os.system("cp Updates/Palaver-master/"+f+" "+f)
os.system("rm Updates -r -f")
os.system("rm update.zip")
print "Done"
lines = []
with open("CONFIG",'r') as data:
for l in data.read().split("\n"):
lines.append(l)
with open("CONFIG",'w') as data:
for l in lines:
if l.startswith("UPDATEID="):
data.write("UPDATEID="+str(id)+"\n")
else:
if l != '\n':
data.write(l+"\n")
pynotify.init("Speech Recognition")
n = pynotify.Notification("Palaver Update","Palaver just successfully updated")
n.show()
os.system("./restart")
else:
print "System Up To Date"