-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathradupdater.py
55 lines (45 loc) · 1.8 KB
/
radupdater.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
#!/usr/bin/env python
# $Id: radupdater.py 7 2009-09-22 14:20:21Z lkalif $
from google.appengine.ext import db
from django.utils import simplejson
from django.core import serializers
class Settings(db.Model):
value = db.StringProperty(required = True, multiline=True)
class Serializable:
def get_dict(self):
return dict((key, value) for key, value in self.__dict__.iteritems()
if not callable(value) and not key.startswith('__'))
def json(self):
return simplejson.dumps(self.get_dict(), sort_keys=True, indent=4)
class UpdateInfo(Serializable):
def __init__(self):
self.Error = False
self.ErrMessage = ''
self.CurrentVersion = ''
self.DownloadSite = ''
self.MOTD = ''
self.DisplayMOTD = False
setting = Settings.get_by_key_name("current_version")
if setting is None:
self.ErrMessage = "Failed fetching data"
self.Error = True;
else:
self.CurrentVersion = setting.value
setting = Settings.get_by_key_name("current_site")
if setting is None:
self.ErrMessage = "Failed fetching data"
self.Error = True;
else:
self.DownloadSite = setting.value
setting = Settings.get_by_key_name("current_motd")
if setting is None:
self.ErrMessage = "Failed fetching data"
self.Error = True;
else:
self.MOTD = setting.value
setting = Settings.get_by_key_name("current_display_motd")
if setting is None:
self.ErrMessage = "Failed fetching data"
self.Error = True;
else:
self.DisplayMOTD = setting.value == "true"