Files
old-tfm/controller/state/__init__.py
2016-01-24 09:40:39 +01:00

28 lines
649 B
Python

import config
from state.server import Server
from state.changer import Changer
from state.file import File
def sync():
server = Server(config.API_BASE_URL, config.CONTROLLER_ID)
local = File(config.STATE_FILE)
server_state = server.get_state()
if local.present():
local.load()
print "local present: " + repr(local.data)
else:
local.data = server_state
print "local not present, server: " + repr(local.data)
local.save()
local_state = local.data
changer = Changer(local_state, server_state)
current_state = changer.process_change()
server.post_state(current_state)