Skip to content

Commit

Permalink
revert lights update
Browse files Browse the repository at this point in the history
  • Loading branch information
juanvallejo committed Feb 28, 2016
1 parent efae4da commit 0a485fa
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 31 deletions.
6 changes: 1 addition & 5 deletions client.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ def __init__(self, server):
self.gamecontroller = None
self.current_state = None

try:
self.lights = visuals.Lights()
except Exception:
print "self lights equals None"
self.lights = None
self.lights = visuals.Lights()

def signal_handler(self, signal, frame):
self.lights.set_lights_off()
Expand Down
50 changes: 24 additions & 26 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ def __init__(self, host, port, gamecontroller):

self.gamecontroller = gamecontroller

try:
self.lights = visuals.Lights()
except Exception:
self.lights = None
self.lights = visuals.Lights()

self.subsection = None

Expand Down Expand Up @@ -76,28 +73,29 @@ def update_lights(self):
# if p not active replace with own, if active, keep trying
#self.lights.update(self.gamecontroller.get_partial_grid())

if self.lights == None:
return

try:
pid_valid = False
f = open("/tmp/fallback.pid", "w+")
pid = f.readline()

if pid != "" and pid != str(os.getpid()) and self.process_exists(pid):
pid_valid = True

if pid_valid:
f.close()
return
else:
f.seek(0)
f.write(str(os.getpid()))
f.close()
self.lights.update(self.gamecontroller.get_partial_grid())

except IOError as err:
print ("err")
#if self.lights == None:
# return

self.lights.update(self.gamecontroller.get_partial_grid())
#try:
# pid_valid = False
# f = open("/tmp/fallback.pid", "w+")
# pid = f.readline()

# if pid != "" and pid != str(os.getpid()) and self.process_exists(pid):
# pid_valid = True

# if pid_valid:
# f.close()
# return
# else:
# f.seek(0)
# f.write(str(os.getpid()))
# f.close()
# self.lights.update(self.gamecontroller.get_partial_grid())

#except IOError as err:
# print ("err")

def main():
server = Server('', 8000)
Expand Down

0 comments on commit 0a485fa

Please sign in to comment.