|
|
|
@ -15,9 +15,7 @@ class Manager():
|
|
|
|
def __init__(self):
|
|
|
|
def __init__(self):
|
|
|
|
self.manager_id = gen_id()
|
|
|
|
self.manager_id = gen_id()
|
|
|
|
self.devices = []
|
|
|
|
self.devices = []
|
|
|
|
self.config = {}
|
|
|
|
self.config = self.import_config_file()
|
|
|
|
|
|
|
|
|
|
|
|
self.import_config_file()
|
|
|
|
|
|
|
|
self.construct_from_config()
|
|
|
|
self.construct_from_config()
|
|
|
|
|
|
|
|
|
|
|
|
def add_device(self, name, resolution): #add parameters for Device class constructor
|
|
|
|
def add_device(self, name, resolution): #add parameters for Device class constructor
|
|
|
|
@ -36,8 +34,7 @@ class Manager():
|
|
|
|
config = toml.load(os.path.join(mydir, 'config.toml'))
|
|
|
|
config = toml.load(os.path.join(mydir, 'config.toml'))
|
|
|
|
#config = convert(uni_config)
|
|
|
|
#config = convert(uni_config)
|
|
|
|
restored_data = restore(config)
|
|
|
|
restored_data = restore(config)
|
|
|
|
self.config = restored_data
|
|
|
|
return restored_data
|
|
|
|
self.devices = self.config['devices']
|
|
|
|
|
|
|
|
except:
|
|
|
|
except:
|
|
|
|
return None
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
@ -48,6 +45,12 @@ class Manager():
|
|
|
|
with open(path, "w+") as config_file:
|
|
|
|
with open(path, "w+") as config_file:
|
|
|
|
config_file.write(toml.dumps({'devices': preserved_data}))
|
|
|
|
config_file.write(toml.dumps({'devices': preserved_data}))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def construct_from_config(self):
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
self.devices = self.config['devices']
|
|
|
|
|
|
|
|
except:
|
|
|
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
#def update_config(self, new_config_tuple):
|
|
|
|
#def update_config(self, new_config_tuple):
|
|
|
|
# new_device_list = []
|
|
|
|
# new_device_list = []
|
|
|
|
# for dev in devices:
|
|
|
|
# for dev in devices:
|
|
|
|
@ -64,14 +67,7 @@ class Manager():
|
|
|
|
def clear_layout(self, device):
|
|
|
|
def clear_layout(self, device):
|
|
|
|
device.layout = {}
|
|
|
|
device.layout = {}
|
|
|
|
|
|
|
|
|
|
|
|
def construct_from_config(self):
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
for confdev in self.config.devices:
|
|
|
|
|
|
|
|
dev = Device(confdev.name, confdev.resolution, confdev.device_id)
|
|
|
|
|
|
|
|
#for cwidg in dev.widgets: ###add code to construct widgets as well
|
|
|
|
|
|
|
|
self.devices.append(dev)
|
|
|
|
|
|
|
|
except:
|
|
|
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@preservable
|
|
|
|
@preservable
|
|
|
|
class Device():
|
|
|
|
class Device():
|
|
|
|
@ -91,10 +87,9 @@ class Device():
|
|
|
|
#generated
|
|
|
|
#generated
|
|
|
|
self.device_image = None
|
|
|
|
self.device_image = None
|
|
|
|
|
|
|
|
|
|
|
|
class Layout():
|
|
|
|
#@preservable
|
|
|
|
# Layout class to contain a layout and functions to manipulate that layout.
|
|
|
|
#class Widget():
|
|
|
|
def __init__(self):
|
|
|
|
|
|
|
|
self.layout = {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Global Functions
|
|
|
|
# Global Functions
|
|
|
|
|