Add script to generate per-user cookie file

The script is called gitzilla-gencookie
master
Devendra Gera 2010-03-14 03:08:46 +05:30
parent e6c1bc0b7f
commit a8e59bdfbb
2 changed files with 35 additions and 0 deletions

View File

@ -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',
],
}
)

34
utilscripts.py Normal file
View File

@ -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 <bugzilla_base_url>
""" % 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()