From 16e7fd3d4abbec9f5e6d976a2feca87176e79e29 Mon Sep 17 00:00:00 2001 From: Fredrik Tolf Date: Sun, 15 Jan 2012 08:14:53 +0100 Subject: [PATCH] Made relevant Python3 changes. --- pdm/cli.py | 2 +- pdm/sshsock.py | 28 ++++++++++++++-------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/pdm/cli.py b/pdm/cli.py index 272be86..667e2ed 100644 --- a/pdm/cli.py +++ b/pdm/cli.py @@ -23,7 +23,7 @@ def resolve(spec): p = spec.rindex(":") first, second = spec[:p], spec[p + 1:] if "/" in second: - import sshsock + from . import sshsock sk = sshsock.sshsocket(first, second) else: sk = socket.socket(socket.AF_INET, socket.SOCK_STREAM) diff --git a/pdm/sshsock.py b/pdm/sshsock.py index feb2f9f..3a64122 100644 --- a/pdm/sshsock.py +++ b/pdm/sshsock.py @@ -9,7 +9,7 @@ class sshsocket(object): if port is not None: args += ["-p", str(int(port))] args += [host] - args += ["python", "-m", "pdm.sshsock", path] + args += ["python3", "-m", "pdm.sshsock", path] self.proc = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, close_fds=True) fcntl.fcntl(self.proc.stdout, fcntl.F_SETFL, fcntl.fcntl(self.proc.stdout, fcntl.F_GETFL) | os.O_NONBLOCK) @@ -36,36 +36,36 @@ class sshsocket(object): self.close() def cli(): - fcntl.fcntl(sys.stdin, fcntl.F_SETFL, fcntl.fcntl(sys.stdin, fcntl.F_GETFL) | os.O_NONBLOCK) + fcntl.fcntl(sys.stdin.buffer, fcntl.F_SETFL, fcntl.fcntl(sys.stdin.buffer, fcntl.F_GETFL) | os.O_NONBLOCK) sk = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) try: sk.connect(sys.argv[1]) - buf1 = "" - buf2 = "" + buf1 = b"" + buf2 = b"" while True: wfd = [] if buf1: wfd.append(sk) - if buf2: wfd.append(sys.stdout) - rfd, wfd, efd = select.select([sk, sys.stdin], wfd, []) + if buf2: wfd.append(sys.stdout.buffer) + rfd, wfd, efd = select.select([sk, sys.stdin.buffer], wfd, []) if sk in rfd: ret = sk.recv(65536) - if ret == "": + if ret == b"": break else: buf2 += ret - if sys.stdin in rfd: - ret = sys.stdin.read() - if ret == "": + if sys.stdin.buffer in rfd: + ret = sys.stdin.buffer.read() + if ret == b"": break else: buf1 = ret if sk in wfd: ret = sk.send(buf1) buf1 = buf1[ret:] - if sys.stdout in wfd: - sys.stdout.write(buf2) - sys.stdout.flush() - buf2 = "" + if sys.stdout.buffer in wfd: + sys.stdout.buffer.write(buf2) + sys.stdout.buffer.flush() + buf2 = b"" finally: sk.close() -- 2.11.0