Browse Source

Fix python3 encoding issues for remote commands

Change-Id: Idb377eae4a2b52760cb810b590a75b5aea522968
James E. Blair 1 month ago
parent
commit
2f9eebc211
1 changed files with 4 additions and 4 deletions
  1. 4
    4
      gertty/app.py

+ 4
- 4
gertty/app.py View File

@@ -374,12 +374,12 @@ class App(object):
374 374
             try:
375 375
                 s, addr = self.socket.accept()
376 376
                 self.log.debug("Accepted socket connection %s" % (s,))
377
-                buf = ''
377
+                buf = b''
378 378
                 while True:
379 379
                     buf += s.recv(1)
380
-                    if buf[-1] == '\n':
380
+                    if buf[-1] == 10:
381 381
                         break
382
-                buf = buf.strip()
382
+                buf = buf.decode('utf8').strip()
383 383
                 self.log.debug("Received %s from socket" % (buf,))
384 384
                 s.close()
385 385
                 parts = buf.split()
@@ -874,7 +874,7 @@ class OpenChangeAction(argparse.Action):
874 874
 
875 875
         s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
876 876
         s.connect(cf.socket_path)
877
-        s.sendall('open %s\n' % url)
877
+        s.sendall(('open %s\n' % url).encode('utf8'))
878 878
         sys.exit(0)
879 879
 
880 880
 def main():

Loading…
Cancel
Save