Commit cebc9e8d authored by Tammo Jan Dijkema's avatar Tammo Jan Dijkema
Browse files

Catch some socket errors

parent c900f24f
......@@ -57,11 +57,17 @@ class telescope():
'''
Poll the socket with the j2000 info, store its values in class members
'''
self.j2000socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.j2000socket.connect((consolehost, j2000_read_port))
try:
self.j2000socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.j2000socket.connect((consolehost, j2000_read_port))
except socket.error:
raise Exception("Cannot connect to j2000 status server")
while True:
readable, writable, exceptional = select.select(
[self.j2000socket], [], [])
if len(exceptional)>0:
raise Exception("Error with j2000 read socket")
msg = readable[0].recv(4096)
vals = msg.strip().split()
ra = vals[2]
......@@ -72,11 +78,17 @@ class telescope():
'''
Poll the socket with the traces, store their values in class members
'''
self.tracesocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.tracesocket.connect((tracehost, traceport))
try:
self.tracesocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.tracesocket.connect((tracehost, traceport))
except socket.error:
raise Exception("Cannot connect to trace2port server")
while True:
readable, writable, exceptional = select.select(
[self.tracesocket], [], [])
if len(exceptional)>0:
raise Exception("Error with trace read socket")
msg = readable[0].recv(4096)
vals = msg.strip().split()
self.az = (float(vals[0])*u.rad).to(u.deg)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment