X-Git-Url: http://git.dolda2000.com/gitweb/?a=blobdiff_plain;f=lib%2Fpython%2Fdolcon%2F__init__.py;h=0cb26baaf7c681b0473cf3a5bb4bb15c430fe14c;hb=54b4a8611d7b4dd760e4207f4a64932b580a431a;hp=86ce62456344a253319928b078310d2d4b232635;hpb=194d48ea4710829c7c890c43381857fe07f77050;p=doldaconnect.git diff --git a/lib/python/dolcon/__init__.py b/lib/python/dolcon/__init__.py index 86ce624..0cb26ba 100644 --- a/lib/python/dolcon/__init__.py +++ b/lib/python/dolcon/__init__.py @@ -47,14 +47,14 @@ def cnl(host = None, port = -1, useauthless = True, **kw): """A convenience function for connect and loginasync. This function will connect to the given server, or the server in - the environment variable $DCSERVER if none is given, and - authenticate to the server. If any of the steps fail, an exception - is raised. + the environment variable $DCSERVER if none is given, or, if that + fails, localhost, and authenticate to the server. If any of the + steps fail, an exception is raised. """ if host is None: host = os.getenv("DCSERVER") if host is None: - raise ValueError, "No DC host to connect to" + host = "localhost" fd = mustconnect(host, port) err, reason = login(useauthless, **kw) if err != "success": @@ -97,5 +97,16 @@ def ecmds(*args): """ resp = ecmd(*args) if resp.getcode() >= 500 and resp.getcode() < 600: - raise ValueError, resp.extract()[0] + raise ValueError, tuple(resp.extract()[0]) return resp + +def getresps(): + """A generator function which will iterate over all responses from + getresp. + """ + while True: + resp = getresp() + if resp is None: + break + else: + yield resp