Generalise cli_auth_utils 79/76779/3
authorJames Harrison <00jamesh@gmail.com>
Thu, 13 Apr 2017 15:19:33 +0000 (16:19 +0100)
committerDave Rigby <daver@couchbase.com>
Wed, 19 Apr 2017 08:10:58 +0000 (08:10 +0000)
Some minor modifications to allow arbitrary kwargs to be passed through
the cmd decorator - permits use in cbcompact

Change-Id: Ib506b29d1aa8b8cabc28ddad91024294632c0a63
Reviewed-on: http://review.couchbase.org/76779
Reviewed-by: Manu Dhundi <manu@couchbase.com>
Tested-by: Build Bot <build@couchbase.com>
management/cbstats
management/cli_auth_utils.py

index fb40cb6..acf1541 100755 (executable)
@@ -31,7 +31,7 @@ def cmd(f):
     f = cli_auth_utils.cmd_decorator(f)
     def g(*args, **kwargs):
         global output_json
-        output_json = kwargs.get('json', None)
+        output_json = kwargs.pop('json', None)
         f(*args, **kwargs)
     return g
 
index 4548004..46ad1b7 100644 (file)
@@ -33,9 +33,9 @@ def cmd_decorator(f):
                                       % (max - 1, len(args) - 1, list(args[1:])))
                 sys.exit(2)
 
-        bucket = kwargs.get('bucketName', None) or 'default'
-        username = kwargs.get('username', None) or bucket
-        password = kwargs.get('password', None) or ''
+        bucket = kwargs.pop('bucketName', None) or 'default'
+        username = kwargs.pop('username', None) or bucket
+        password = kwargs.pop('password', None) or ''
 
         if username:
             try:
@@ -49,19 +49,19 @@ def cmd_decorator(f):
                                 os.getenv("EP_ENGINE_VERSION",
                                           "unknown version")))
         try:
-            if kwargs.get('allBuckets', None):
+            if kwargs.pop('allBuckets', None):
                 buckets = mc.list_buckets()
                 for bucket in buckets:
                     print '*' * 78
                     print bucket
                     print
                     mc.bucket_select(bucket)
-                    f(*args)
+                    f(*args, **kwargs)
             elif bucket is not None:
                 mc.bucket_select(bucket)
-                f(*args)
+                f(*args, **kwargs)
             else:
-                f(*args)
+                f(*args, **kwargs)
         except mc_bin_client.ErrorEaccess:
             print ("No access to bucket:{} - permission denied "
                    "or bucket does not exist.".format(bucket))