From c30be9c90be2bec50dff04ef96af1dbea43d7015 Mon Sep 17 00:00:00 2001 From: Fredrik Tolf Date: Sun, 15 Jan 2012 07:49:33 +0100 Subject: [PATCH] Added a client resolve syntax for connecting to remote Unix sockets. --- pdm/cli.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pdm/cli.py b/pdm/cli.py index effe3c9..1d83920 100644 --- a/pdm/cli.py +++ b/pdm/cli.py @@ -19,16 +19,21 @@ def resolve(spec): return spec sk = None try: - if "/" in spec: + if ":" in spec: + p = spec.rindex(":") + first, second = spec[:p], spec[p + 1:] + if "/" in second: + import sshsock + sk = sshsock.sshsocket(first, second) + else: + sk = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sk.connect((first, second)) + elif "/" in spec: sk = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) sk.connect(spec) elif spec.isdigit(): sk = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sk.connect(("localhost", int(spec))) - elif ":" in spec: - sk = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - p = spec.rindex(":") - sk.connect((spec[:p], int(spec[p + 1:]))) else: raise Exception("Unknown target specification %r" % spec) rv = sk -- 2.11.0