From: fredrik Date: Wed, 22 Nov 2006 17:58:25 +0000 (+0000) Subject: Add ecmds. X-Git-Tag: 0.3~160 X-Git-Url: http://dolda2000.com/gitweb/?p=doldaconnect.git;a=commitdiff_plain;h=194d48ea4710829c7c890c43381857fe07f77050 Add ecmds. git-svn-id: svn+ssh://svn.dolda2000.com/srv/svn/repos/src/doldaconnect@763 959494ce-11ee-0310-bf91-de5d638817bd --- diff --git a/lib/python/dolcon/__init__.py b/lib/python/dolcon/__init__.py index 11cb6d4..86ce624 100644 --- a/lib/python/dolcon/__init__.py +++ b/lib/python/dolcon/__init__.py @@ -88,3 +88,14 @@ def ecmda(code, *args): if resp.getcode() != code: raise ValueError, resp.getcode() return resp + +def ecmds(*args): + """Another convenience function for ecmd. + + Like ecmda, but will fail on all 5xx codes, and succeed on all + others. + """ + resp = ecmd(*args) + if resp.getcode() >= 500 and resp.getcode() < 600: + raise ValueError, resp.extract()[0] + return resp