cleanup
This commit is contained in:
parent
52ad431877
commit
14f7819a79
|
@ -80,7 +80,6 @@ class socket_util(object):
|
|||
self.write(integer_buf)
|
||||
|
||||
def write(self, data: bytes):
|
||||
#socket.bind(address)
|
||||
data_len = len(data)
|
||||
offset = 0
|
||||
while offset != data_len:
|
||||
|
@ -88,7 +87,7 @@ class socket_util(object):
|
|||
|
||||
def receive(self):
|
||||
r,s,e = select.select([self.soc], [], [], 1)
|
||||
#LOG.info("r" + str(r))
|
||||
LOG.debug("r: {!r}".format(r))
|
||||
if r == []:
|
||||
return ""
|
||||
message_size = self.read_int()
|
||||
|
@ -96,10 +95,11 @@ class socket_util(object):
|
|||
self.close_socket()
|
||||
return None
|
||||
data = self.read(message_size)
|
||||
LOG.debug("data: {!r}".format(data))
|
||||
if data == None:
|
||||
LOG.debug("data_none")
|
||||
LOG.debug("data was none")
|
||||
return None
|
||||
message = json.loads(data)
|
||||
message = json.loads(data.decode("utf-8"))
|
||||
|
||||
return message
|
||||
|
||||
|
@ -111,7 +111,7 @@ class socket_util(object):
|
|||
return struct.unpack('>i', intbuf)[0]
|
||||
|
||||
def read(self, size):
|
||||
data = ""
|
||||
data = b""
|
||||
while len(data) != size:
|
||||
newdata = self.soc.recv(size - len(data))
|
||||
if len(newdata) == 0:
|
||||
|
@ -148,7 +148,7 @@ class MinecraftWrapper(socket_util):
|
|||
raise subprocess.CalledProcessError(return_code, self.command)
|
||||
|
||||
def msg_process(self):
|
||||
while(not self.exit):
|
||||
while not self.exit:
|
||||
try:
|
||||
self.proc_monitor()
|
||||
status = 1
|
||||
|
@ -239,7 +239,6 @@ class MinecraftServerBridge(socket_util):
|
|||
self.soc.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
LOG.info("Server accepted connection: " + str(self.addr))
|
||||
|
||||
|
||||
def msg_process(self):
|
||||
while(True):
|
||||
try:
|
||||
|
@ -250,10 +249,9 @@ class MinecraftServerBridge(socket_util):
|
|||
if rcv != "" and rcv != None:
|
||||
self.msg_handle(rcv)
|
||||
except Exception as e:
|
||||
LOG.info(e)
|
||||
LOG.exception(e)
|
||||
self.socket_reset()
|
||||
|
||||
|
||||
def msg_handle(self, msg):
|
||||
#for msg, create user and post as user
|
||||
#add minecraft user to minecraft channel, if this fails, no big deal
|
||||
|
@ -284,7 +282,7 @@ class MinecraftServerBridge(socket_util):
|
|||
self.avatar_update_log[msg['user']] = time.time()
|
||||
avatar_url = self.get_mc_skin(msg['user'], user_id)
|
||||
if avatar_url:
|
||||
LOG.info("avatar_url is " + avatar_url)
|
||||
LOG.debug("avatar_url is " + avatar_url)
|
||||
self.api._send("PUT", '/profile/'+user_id+'/avatar_url/', content={"avatar_url":avatar_url}, query_params={"user_id": user_id}, headers={"Content-Type":"application/json"})
|
||||
|
||||
#attempt to post in room
|
||||
|
@ -422,3 +420,5 @@ def main():
|
|||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
# vi: set expandtab sw=4 ts=4 softtabstop=4
|
||||
|
|
Loading…
Reference in New Issue