-
Notifications
You must be signed in to change notification settings - Fork 0
/
configuration.py
99 lines (88 loc) · 3.89 KB
/
configuration.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import elementtree.ElementTree as ET
from controllers import *
from requestprocessor import *
import pdb
class configuration(object):
def get_system_configuration(self):
systemConfiguration = {
"locations": self.config('locations'),
"blinds": ['Den','Kitchen','Theater'],
"options": self.config('options'),
"radiostations": self.config('radiostations')}
#print systemConfiguration
return systemConfiguration
def get_mce_configuration(self):
XMLtree = ET.parse("Configuration/config.xml")
doc = XMLtree.getroot()
for elem in doc.findall('config'):
if elem.get('name') == 'MCE':
mceConfig = {}
for item in elem.findall('item'):
mceConfig[item.get('name')] = { "Title": item.get('Title'),
"On": item.get('On'),
"Off": item.get('Off'),
"Up": item.get('Up'),
"Down": item.get('Down')
}
return mceConfig
return mceConfig
def get_system_status(self):
systemStatus = []
locations = self.config('locations')
#So request some dummy data.
#Now request the data that we want.
for location in locations:
zone,chassis = self.zone_location(location)
systemStatus.append('volume,' + location + ',' + str(requestprocessor().get_volume(zone,chassis)))
systemStatus.append('treble,' + location + ',' + str(requestprocessor().get_treble(zone,chassis)))
systemStatus.append('base,' + location + ',' + str(requestprocessor().get_base(zone,chassis)))
systemStatus.append('source,' + location + ',' + self.source_location(requestprocessor().get_source(zone, chassis)))
return systemStatus
def get_system_status_template(self):
systemStatus = {}
locations = self.config('locations')
#So request some dummy data.
#Now request the data that we want.
for location in locations:
zone = self.zone_location(location)
#print location + " " + zone
systemStatus[location] = { "Volume": '',
"Treble": '',
"Base": '',
"Input": 'Off' }
#print(systemStatus[location])
systemStatus['RadioStation'] = requestprocessor().get_radio_station()
systemStatus['PandoraStation'] = ""
return systemStatus
def config_exists(self,name):
XMLtree = ET.parse("Configuration/config.xml")
doc = XMLtree.getroot()
for elem in doc.findall('config'):
if elem.get('name') == name:
return True
return False
def config(self,setting):
XMLtree = ET.parse("Configuration/config.xml")
doc = XMLtree.getroot()
for elem in doc.findall('config'):
if elem.get('name') == setting:
items = []
for item in elem.findall('item'):
items.append(item.get('name'))
return items
def zone_location(self,location):
XMLtree = ET.parse("Configuration/config.xml")
doc = XMLtree.getroot()
for elem in doc.findall('config'):
if elem.get('name') == 'locations':
for item in elem.findall('item'):
if item.get('name') == location:
return item.get('zone'),item.get('chassis')
def source_location(self,option):
XMLtree = ET.parse("Configuration/config.xml")
doc = XMLtree.getroot()
for elem in doc.findall('config'):
if elem.get('name') == 'options':
for item in elem.findall('item'):
if item.get('source') == option:
return item.get('name')