Mercurial > hg > mood-conductor
changeset 32:cb57e554ae80
some bug fixes while testing connection
author | gyorgyf |
---|---|
date | Tue, 09 Jul 2013 16:20:08 +0100 |
parents | 1233c13c17d9 |
children | fe04ff3547c7 |
files | mcserver/mcserver.py visualclient/visclient.py |
diffstat | 2 files changed, 18 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/mcserver/mcserver.py Mon Apr 29 16:02:54 2013 +0100 +++ b/mcserver/mcserver.py Tue Jul 09 16:20:08 2013 +0100 @@ -68,7 +68,7 @@ @cp.expose def mood(self,x,y): - # print "Received coordinates", x,y, "\n" + print "Received coordinates", x,y, "\n" i = Input(x,y,self.age,self.dist) if i in self.inputs : self.inputs[self.inputs.index(i)].inc() @@ -93,6 +93,7 @@ if kwargs.has_key('ninp') : self.ninp = int(kwargs['ninp']) # cp.log.error("Config changed...") + print "New configuration received from visual client." return str() @cp.expose @@ -156,6 +157,7 @@ print 'Processes killed:',pids_killed,' Waiting 10 secods...' import time time.sleep(10) + print "Starting..." return True return False
--- a/visualclient/visclient.py Mon Apr 29 16:02:54 2013 +0100 +++ b/visualclient/visclient.py Tue Jul 09 16:20:08 2013 +0100 @@ -49,9 +49,9 @@ FRAMERATE = 60 # Connection: -# IP = "127.0.0.1:8030" +IP = "127.0.0.1:8030" # IP = "192.168.2.158:8030" -IP = "138.37.95.215" +# IP = "138.37.95.215" HTTP_TIMEOUT = 3 SERVER_UPDATE_INTERVAL = 0.8 @@ -265,10 +265,11 @@ def start_update_thread(self): '''Start the thread that reads data from the server.''' - self.running = True self.thread = Thread(target = self.update_thread) self.thread.daemon = True self.thread.start() + self.running = True + print "OK. Update thread started." def stop_update_thread(self): '''Stop the thread and allow some time fot the connections to close.''' @@ -281,6 +282,7 @@ def update_thread(self): '''The server update thread''' while self.running : + # self.update() try : self.update() # self.indicators["update"].visible = True @@ -494,10 +496,12 @@ def update_server_config(self,age,dist,ninp,retry = 3): '''Send the server some configuration data.''' try : + print "Sending configuration data." self.conn.putrequest("GET","/moodconductor/config?age=%(age)s&dist=%(dist)s&ninp=%(ninp)s" %locals(), skip_host=True) self.conn.putheader("Host", "www.isophonics.net") self.conn.endheaders() res = self.conn.getresponse() + res.read() if not res.status == 200 : print "Server response:", res.status, res.reason self.indicators["conn"].off() @@ -508,9 +512,10 @@ res = self.conn.getresponse() if not res.status == 200 : print "Server response:", res.status, res.reason - self.indicators["conn"].off() + self.indicators["conn"].off() print "Server configuration:", res.read() except: + print "Failed to send configuration data." time.sleep(2) retry -= 1 self.update_server_config(age,dist,ninp,retry) @@ -525,18 +530,21 @@ if retry < 5 : time.sleep(3) try : + print "connecting to server..." self.conn = ht.HTTPConnection(IP,timeout=HTTP_TIMEOUT) - # self.start_update_thread() self.indicators["conn"].on() except : self.indicators["conn"].off() self.connect(retry = retry-1) + print "connection failed." try: + print "Testing connection." self.conn.putrequest("GET","/moodconductor/index.html", skip_host=True) self.conn.putheader("Host", "www.isophonics.net") self.conn.endheaders() res = self.conn.getresponse() + res.read() if res.status == 200 : self.indicators["conn"].on() else : @@ -545,6 +553,7 @@ if not hasattr(self,"noretry") and raw_input("Go offline? ") in ['y',''] : return False else : + print "Failed. retrying." self.noretry = None self.connect(retry = retry-1) except : @@ -557,6 +566,7 @@ self.noretry = None self.connect(retry = retry-1) self.configure_server() + print "OK. Starting update thread..." self.start_update_thread() return True