Changeset 52135 in webkit


Ignore:
Timestamp:
Dec 14, 2009 10:00:55 PM (14 years ago)
Author:
eric@webkit.org
Message:

2009-12-14 Eric Seidel <eric@webkit.org>

Reviewed by Adam Barth.

Move Credential handling out into a separate module
https://bugs.webkit.org/show_bug.cgi?id=32531

  • Scripts/modules/bugzilla.py:
  • Scripts/modules/credentials.py: Added.
  • Scripts/modules/credentials_unittest.py: Added.
  • Scripts/run-webkit-unittests:
Location:
trunk/WebKitTools
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r52134 r52135  
     12009-12-14  Eric Seidel  <eric@webkit.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        Move Credential handling out into a separate module
     6        https://bugs.webkit.org/show_bug.cgi?id=32531
     7
     8        * Scripts/modules/bugzilla.py:
     9        * Scripts/modules/credentials.py: Added.
     10        * Scripts/modules/credentials_unittest.py: Added.
     11        * Scripts/run-webkit-unittests:
     12
    1132009-12-14  Adam Barth  <abarth@webkit.org>
    214
  • trunk/WebKitTools/Scripts/modules/bugzilla.py

    r51959 r52135  
    3030# WebKit's Python module for interacting with Bugzilla
    3131
    32 import getpass
    33 import platform
    3432import re
    3533import subprocess
     
    4139from modules.logging import error, log
    4240from modules.committers import CommitterList
     41from modules.credentials import Credentials
    4342
    4443# WebKit includes a built copy of BeautifulSoup in Scripts/modules
     
    5958"""
    6059    exit(1)
    61 
    62 def credentials_from_git():
    63     return [read_config("username"), read_config("password")]
    64 
    65 def credentials_from_keychain(username=None):
    66     if not is_mac_os_x():
    67         return [username, None]
    68 
    69     command = "/usr/bin/security %s -g -s %s" % ("find-internet-password", Bugzilla.bug_server_host)
    70     if username:
    71         command += " -a %s" % username
    72 
    73     log('Reading Keychain for %s account and password.  Click "Allow" to continue...' % Bugzilla.bug_server_host)
    74     keychain_process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
    75     value = keychain_process.communicate()[0]
    76     exit_code = keychain_process.wait()
    77 
    78     if exit_code:
    79         return [username, None]
    80 
    81     match = re.search('^\s*"acct"<blob>="(?P<username>.+)"', value, re.MULTILINE)
    82     if match:
    83         username = match.group('username')
    84 
    85     password = None
    86     match = re.search('^password: "(?P<password>.+)"', value, re.MULTILINE)
    87     if match:
    88         password = match.group('password')
    89 
    90     return [username, password]
    91 
    92 def is_mac_os_x():
    93     return platform.mac_ver()[0]
    9460
    9561def parse_bug_id(message):
     
    10268    return None
    10369
    104 # FIXME: This should not depend on git for config storage
    105 def read_config(key):
    106     # Need a way to read from svn too
    107     config_process = subprocess.Popen("git config --get bugzilla.%s" % key, stdout=subprocess.PIPE, shell=True)
    108     value = config_process.communicate()[0]
    109     return_code = config_process.wait()
    110 
    111     if return_code:
    112         return None
    113     return value.rstrip('\n')
    114 
    115 def read_credentials():
    116     (username, password) = credentials_from_git()
    117 
    118     if not username or not password:
    119         (username, password) = credentials_from_keychain(username)
    120 
    121     if not username:
    122         username = raw_input("Bugzilla login: ")
    123     if not password:
    124         password = getpass.getpass("Bugzilla password for %s: " % username)
    125 
    126     return [username, password]
    12770
    12871def timestamp():
     
    13477
    13578
    136 class Bugzilla:
     79class Bugzilla(object):
    13780    def __init__(self, dryrun=False, committers=CommitterList()):
    13881        self.dryrun = dryrun
     
    371314            return
    372315
    373         (username, password) = read_credentials()
     316        (username, password) = Credentials(self.bug_server_host, git_prefix="bugzilla").read_credentials()
    374317
    375318        log("Logging in as %s..." % username)
  • trunk/WebKitTools/Scripts/run-webkit-unittests

    r51895 r52135  
    3838from modules.commands.queues_unittest import *
    3939from modules.committers_unittest import *
     40from modules.credentials_unittest import *
    4041from modules.cpp_style_unittest import *
    4142from modules.diff_parser_unittest import *
Note: See TracChangeset for help on using the changeset viewer.