Permalink
Browse files

Made relevant Python3 changes.

  • Loading branch information...
1 parent 5d0664a commit 16e7fd3d4abbec9f5e6d976a2feca87176e79e29 @dolda2000 committed Jan 15, 2012
Showing with 15 additions and 15 deletions.
  1. +1 −1 pdm/cli.py
  2. +14 −14 pdm/sshsock.py
View
@@ -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)
View
@@ -9,7 +9,7 @@ def __init__(self, host, path, user = None, port = None):
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 @@ def __del__(self):
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()

0 comments on commit 16e7fd3

Please sign in to comment.