X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=pdm%2Fcli.py;h=272be862e061e8313be53959ca443044fceff166;hb=5d0664aa6dde860573fe4bcf8d1b312b7c6c4271;hp=32580bba5722cedde7a05e83fed91266195cc6b7;hpb=28203f3fefeaa864b8f14390b7a72d5081a94ce8;p=pdm.git diff --git a/pdm/cli.py b/pdm/cli.py index 32580bb..272be86 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 @@ -51,12 +56,12 @@ class client(object): """Create a client object connected to the specified server. `sk' can either be a socket object, which is used as it is, or a string specification very similar to the - specification for pdm.srv.listen, so see its documentation for - details. The differences are only that this function does not - take arguments specific to socket creation, like the mode and - group arguments for Unix sockets. If `proto' is given, that - subprotocol will negotiated with the server (by calling the - select() method). + specification for L{pdm.srv.listen}, so see its documentation + for details. The differences are only that this function does + not take arguments specific to socket creation, like the mode + and group arguments for Unix sockets. If `proto' is given, + that subprotocol will negotiated with the server (by calling + the select() method). """ self.sk = resolve(sk) self.buf = b"" @@ -108,8 +113,8 @@ class client(object): class replclient(client): """REPL protocol client - Implements the client side of the REPL protocol; see pdm.srv.repl - for details on the protocol and its functionality. + Implements the client side of the REPL protocol; see + L{pdm.srv.repl} for details on the protocol and its functionality. """ def __init__(self, sk): """Create a connected client as documented in the `client' class.""" @@ -117,8 +122,8 @@ class replclient(client): def run(self, code): """Run a single block of Python code on the server. Returns - the output of the command (as documented in pdm.srv.repl) as a - string. + the output of the command (as documented in L{pdm.srv.repl}) + as a string. """ while True: ncode = code.replace("\n\n", "\n") @@ -209,8 +214,8 @@ class perfproxy(object): class perfclient(client): """PERF protocol client - Implements the client side of the PERF protocol; see pdm.srv.perf - for details on the protocol and its functionality. + Implements the client side of the PERF protocol; see + L{pdm.srv.perf} for details on the protocol and its functionality. This client class implements functions for finding PERF objects on the server, and returns, for each server-side object looked up, a @@ -220,8 +225,8 @@ class perfclient(client): they implement a close() method for that purpose, and can also be used in `with' statements. - See pdm.srv.perf for details on the various PERF interfaces that - the proxy objects might implement. + See L{pdm.srv.perf} for details on the various PERF interfaces + that the proxy objects might implement. """ def __init__(self, sk): """Create a connected client as documented in the `client' class."""