X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=lib%2Fpython%2Fdolcon%2F__init__.py;h=c1611ac590f1da39586bcb707fa927736458b2de;hb=9cbeb60c78389bde5a290e263335cffffbb5ced6;hp=0cb26baaf7c681b0473cf3a5bb4bb15c430fe14c;hpb=691f0a7044ab55e180db5620aa28ff6d8268273c;p=doldaconnect.git diff --git a/lib/python/dolcon/__init__.py b/lib/python/dolcon/__init__.py index 0cb26ba..c1611ac 100644 --- a/lib/python/dolcon/__init__.py +++ b/lib/python/dolcon/__init__.py @@ -25,7 +25,7 @@ def login(useauthless = True, **kw): select() return result[0] -def mustconnect(host, port = -1): +def mustconnect(host, revision = latest): """A convenience function for connect. This function will connect to the given host, perform a select @@ -33,17 +33,19 @@ def mustconnect(host, port = -1): any of these steps fail, an exception is raised. If successful, the file descriptor for the server connection is returned. """ - fd = connect(host, port) + fd = connect(host) while True: resp = getresp() if resp is not None and resp.getcmd() == u".connect": break select() - if resp.getcode() != 200: + if resp.getcode() != 201: raise RuntimeError, resp.intresp()[0][0] + if not checkproto(resp, revision): + raise RuntimeError, resp return fd -def cnl(host = None, port = -1, useauthless = True, **kw): +def cnl(host = None, useauthless = True, revision = latest, **kw): """A convenience function for connect and loginasync. This function will connect to the given server, or the server in @@ -55,7 +57,7 @@ def cnl(host = None, port = -1, useauthless = True, **kw): host = os.getenv("DCSERVER") if host is None: host = "localhost" - fd = mustconnect(host, port) + fd = mustconnect(host, revision) err, reason = login(useauthless, **kw) if err != "success": raise RuntimeError, (err, reason)