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)
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()