Use socket connection end instead of \n, handle empty commands better
This commit is contained in:
parent
7d64688464
commit
5eac07bfe9
|
@ -44,19 +44,19 @@ class uriThread(threading.Thread):
|
|||
while True:
|
||||
c,addr = s.accept()
|
||||
data = c.recv(1)
|
||||
if data.decode("utf-8",errors="ignore") == "\n": # Empty URI, could be a command
|
||||
if data == b"": # Empty URI, could be a command
|
||||
try:
|
||||
cmd = q.get(False)
|
||||
except queue.Empty:
|
||||
pass
|
||||
data = b""
|
||||
else:
|
||||
if cmd == "exit": return
|
||||
continue
|
||||
|
||||
while True:
|
||||
addData = c.recv(1)
|
||||
if addData.decode("utf-8",errors="ignore") == "\n": break
|
||||
data += addData
|
||||
else:
|
||||
while True:
|
||||
addData = c.recv(1)
|
||||
if addData == b"": break
|
||||
data += addData
|
||||
uri = data.decode("utf-8",errors="ignore")
|
||||
GLib.idle_add(makeWindow,uri)
|
||||
|
||||
|
@ -70,7 +70,7 @@ def onClose(*args,**kwargs):
|
|||
try:
|
||||
with socket.socket(socket.AF_UNIX,socket.SOCK_STREAM) as s:
|
||||
s.connect(socketFile)
|
||||
s.send("\n".encode("utf-8"))
|
||||
s.close()
|
||||
except Exception:
|
||||
pass
|
||||
return rtn
|
||||
|
|
Loading…
Reference in New Issue