aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Sokolovsky <paul.sokolovsky@linaro.org>2014-01-21 18:28:38 +0200
committerPaul Sokolovsky <paul.sokolovsky@linaro.org>2014-01-21 18:28:38 +0200
commitc24dbb660240e8aca4506e98c360f5fd82111b8a (patch)
treeb65e477812e68ce67991e047b9e8e8cbea7518c2
parent3ee5beb8d46b1f7ef42daf40b37489e5d82f8b11 (diff)
downloadcrowd-tool-c24dbb660240e8aca4506e98c360f5fd82111b8a.tar.gz
Add debug logging support.
-rwxr-xr-xcrowd-tool9
1 files changed, 6 insertions, 3 deletions
diff --git a/crowd-tool b/crowd-tool
index bc4fe7e..6e9f7cf 100755
--- a/crowd-tool
+++ b/crowd-tool
@@ -35,8 +35,9 @@ def rest(uri, params):
auth = base64.encodestring('%s:%s' % AUTH)
headers = {"Authorization": "Basic " + auth}
- url = uri + "?" + urllib.urlencode(params)
- c.request("GET", "/crowd/rest/usermanagement/1" + url, headers=headers)
+ url = "/crowd/rest/usermanagement/1" + uri + "?" + urllib.urlencode(params)
+ log.debug("REST request: %s", url)
+ c.request("GET", url, headers=headers)
resp = c.getresponse()
if resp.status != 200:
data = resp.read()
@@ -47,17 +48,19 @@ def rest(uri, params):
if __name__ == "__main__":
- logging.basicConfig()
optparser = optparse.OptionParser(usage="%prog users|groups|user|alises|group|usergroups|ismember|groupusers|groupgroups|members")
optparser.add_option("-u", "--user", default="rest-test", help="Crowd username")
optparser.add_option("-p", "--passwd", help="Crowd password")
optparser.add_option("-P", "--ask-passwd", action="store_true", help="Ask Crowd password")
optparser.add_option("-n", "--nested", action="store_true", help="Process nested groups")
optparser.add_option("-r", "--raw", action="store_true", help="Show raw JSON response")
+ optparser.add_option("-d", "--debug", action="store_true", help="Debug logging")
options, args = optparser.parse_args(sys.argv[1:])
if len(args) < 1:
optparser.error("Wrong number of arguments")
+ logging.basicConfig(level=(logging.DEBUG if options.debug else logging.INFO))
+
if options.ask_passwd:
options.passwd = getpass.getpass("Crowd password: ")