mirror of
https://github.com/BOSWatch/BW3-Core.git
synced 2026-04-06 14:53:53 +00:00
fixes for pyLint
This commit is contained in:
parent
3564680867
commit
3f1eac88be
14 changed files with 35 additions and 34 deletions
|
|
@ -45,16 +45,16 @@ class TCPClient:
|
|||
self._sock.setdefaulttimeout(self._timeout)
|
||||
self._sock = socket.create_connection((host, port))
|
||||
|
||||
logging.debug("connected to " + str(host) + ":" + str(port))
|
||||
logging.debug("connected to %s:%s", host, port)
|
||||
return True
|
||||
except ConnectionRefusedError:
|
||||
logging.error("cannot connect to %s:%s - connection refused", str(host), str(port))
|
||||
logging.error("cannot connect to %s:%s - connection refused", host, port)
|
||||
return False
|
||||
except socket.timeout: # pragma: no cover
|
||||
logging.warning("cannot connect to %s:%s - timeout after %s sec", str(host), str(port), self._timeout)
|
||||
logging.warning("cannot connect to %s:%s - timeout after %s sec", host, port, self._timeout)
|
||||
return False
|
||||
except: # pragma: no cover
|
||||
logging.exception("cannot connect to %s:%s", str(host), str(port))
|
||||
logging.exception("cannot connect to %s:%s", host, port)
|
||||
return False
|
||||
|
||||
def disconnect(self):
|
||||
|
|
@ -78,7 +78,7 @@ class TCPClient:
|
|||
@param data: data to send to the server
|
||||
@return True or False"""
|
||||
try:
|
||||
logging.debug("transmitting: " + data)
|
||||
logging.debug("transmitting: %s", data)
|
||||
self._sock.sendall(bytes(data + "\n", "utf-8"))
|
||||
logging.debug("transmitted...")
|
||||
return True
|
||||
|
|
@ -98,7 +98,7 @@ class TCPClient:
|
|||
@return received data"""
|
||||
try:
|
||||
received = str(self._sock.recv(1024), "utf-8")
|
||||
logging.debug("received: " + received)
|
||||
logging.debug("received: %d", received)
|
||||
return received
|
||||
except AttributeError:
|
||||
logging.error("cannot receive - no connection established")
|
||||
|
|
|
|||
|
|
@ -48,8 +48,8 @@ class TCPHandler(socketserver.BaseRequestHandler):
|
|||
try:
|
||||
while data:
|
||||
data = str(self.request.recv(1024).strip(), 'utf-8')
|
||||
if data is not "":
|
||||
logging.debug(req_name + " recv: " + data)
|
||||
if data != "":
|
||||
logging.debug("%s recv: %s", req_name, data)
|
||||
|
||||
# add a new entry at first position (index 0) with client IP
|
||||
# and the decoded data dict as an string in utf-8 and an timestamp
|
||||
|
|
@ -57,14 +57,14 @@ class TCPHandler(socketserver.BaseRequestHandler):
|
|||
_dataPackets.insert(0, (self.client_address[0], data, time.time())) # time() to calc time in queue
|
||||
logging.debug("Add data to queue")
|
||||
|
||||
logging.debug(req_name + " send: [ack]")
|
||||
logging.debug("%s send: [ack]", req_name)
|
||||
self.request.sendall(bytes("[ack]", "utf-8"))
|
||||
self.request.close()
|
||||
|
||||
except (ConnectionResetError, ConnectionAbortedError): # pragma: no cover
|
||||
logging.debug(req_name + " connection closed")
|
||||
logging.debug("%s connection closed", req_name)
|
||||
except: # pragma: no cover
|
||||
logging.exception(req_name + " error while receiving")
|
||||
logging.exception("%s error while receiving", req_name)
|
||||
finally:
|
||||
with _lockClients:
|
||||
del _clients[threading.current_thread().name]
|
||||
|
|
@ -100,7 +100,7 @@ class TCPServer(socketserver.ThreadingMixIn, socketserver.TCPServer):
|
|||
self._server_thread.name = "Thread-BWServer"
|
||||
self._server_thread.daemon = True
|
||||
self._server_thread.start()
|
||||
logging.debug("TCPServer started in Thread: " + self._server_thread.name)
|
||||
logging.debug("TCPServer started in Thread: %s", self._server_thread.name)
|
||||
return True
|
||||
except OSError:
|
||||
logging.exception("server always running?")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue