From a8e59bdfbb2d7c65ece9e36f6358ef4a7f701290 Mon Sep 17 00:00:00 2001 From: Devendra Gera Date: Sun, 14 Mar 2010 03:08:46 +0530 Subject: [PATCH] Add script to generate per-user cookie file The script is called gitzilla-gencookie --- setup.py | 1 + utilscripts.py | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 utilscripts.py diff --git a/setup.py b/setup.py index a3de3c3..0937275 100644 --- a/setup.py +++ b/setup.py @@ -21,6 +21,7 @@ args = dict( 'console_scripts': [ 'gitzilla-post-receive = gitzilla.hookscripts:post_receive', 'gitzilla-update = gitzilla.hookscripts:update', + 'gitzilla-gencookie = gitzilla.utilscripts:generate_cookiefile', ], } ) diff --git a/utilscripts.py b/utilscripts.py new file mode 100644 index 0000000..a76f42a --- /dev/null +++ b/utilscripts.py @@ -0,0 +1,34 @@ + +""" +utilscripts - utility scripts for gitzilla. + +""" + +import os +import sys +import bugz.bugzilla +import getpass + +def generate_cookiefile(): + """ + asks the user for Bugzilla credentials and generates a cookiefile. + """ + if len(sys.argv) < 2: + print """Usage: + %s +""" % sys.argv[0] + sys.exit(1) + + sBZUrl = sys.argv[1] + sLogin = os.getlogin() + sUsername = raw_input("username [%s]: " % (sLogin,)) + sPassword = getpass.getpass("password: ") + + if sUsername == "": + sUsername = sLogin + + oBZ = bugz.bugzilla.Bugz(sBZUrl, user=sUsername, password=sPassword) + oBZ.auth() + + +