예제 #1
0
def discover_bugzilla_endpoint(bugzilla_url, api_key=None):
    """
    Attempts to discover if a given URL contains an exposed Bugzilla API

    Parameters:
        bugzilla_url - URL of potential Bugzilla
        api_key - API key to use when attempting to connect to Bugzilla API

    Returns:
        bugzilla_instance - Returns bugzilla Bugzilla object
    """
    # Try to connect to bugzilla XMLRPC API endpoint
    try:
        bzaf_logger.debug('Bugzilla API URL: {}'.format(bugzilla_url))
        if api_key:
            bugzilla_instance = bugzilla.Bugzilla(bugzilla_url,
                                                  api_key=api_key)
        else:
            bugzilla_instance = bugzilla.Bugzilla(bugzilla_url)
    except requests.exceptions.ConnectionError as e:
        bzaf_logger.debug("{}".format(e))
        raise exceptions.bzafConnectivityException(bugzilla_url)
    except requests.exceptions.HTTPError as e:
        bzaf_logger.debug("{}".format(e))
        raise exceptions.bzafConnectivityException(bugzilla_url)
    except bugzilla.BugzillaError as e:
        bzaf_logger.debug("{}".format(e))
        raise exceptions.bzafBugzillaAPIError()
    return bugzilla_instance
예제 #2
0
파일: bugs.py 프로젝트: jlebon/bodhi
 def _connect(self):
     user = config.get('bodhi_email')
     password = config.get('bodhi_password')
     url = config.get("bz_server")
     log.info("Using BZ URL %s" % url)
     if user and password:
         self._bz = bugzilla.Bugzilla(url=url,
                                      user=user, password=password,
                                      cookiefile=None, tokenfile=None)
     else:
         self._bz = bugzilla.Bugzilla(url=url,
                                      cookiefile=None, tokenfile=None)
예제 #3
0
파일: bugs.py 프로젝트: sshyran/bodhi
 def _connect(self):
     """Create a Bugzilla client instance and store it on self._bz."""
     user = config.get('bodhi_email')
     password = config.get('bodhi_password')
     url = config.get("bz_server")
     log.info("Using BZ URL %s" % url)
     if user and password:
         self._bz = bugzilla.Bugzilla(url=url,
                                      user=user, password=password,
                                      cookiefile=None, tokenfile=None)
     else:
         self._bz = bugzilla.Bugzilla(url=url,
                                      cookiefile=None, tokenfile=None)
예제 #4
0
    def client(self):
        """
        Only connect to Bugzilla when the client property is first used. This
        will make the unit tests less complicated and shorten the connections
        to the Bugzilla server.
        """
        if not self._client:
            # use_creds is only available in python-bugzilla 2.0+
            try:
                self._client = bugzilla.Bugzilla(self.api_url, use_creds=False)
            except TypeError:
                self._client = bugzilla.Bugzilla(self.api_url)

        return self._client
예제 #5
0
def test_api_login():
    with pytest.raises(TypeError):
        # Missing explicit URL
        bugzilla.Bugzilla()

    with pytest.raises(Exception):
        # Calling connect() with passed in URL
        bugzilla.Bugzilla(url="https:///FAKEURL")

    bz = tests.mockbackend.make_bz()

    with pytest.raises(ValueError):
        # Errors on missing user
        bz.login()

    bz.user = "******"
    with pytest.raises(ValueError):
        # Errors on missing pass
        bz.login()

    bz.password = "******"
    bz.api_key = "WIBBLE"
    with pytest.raises(ValueError):
        # Errors on api_key + login()
        bz.login()

    # Hit default api_key code path
    bz = tests.mockbackend.make_bz(
        bz_kwargs={"api_key": "FAKE_KEY"},
        user_login_args="data/mockargs/test_api_login.txt",
        user_login_return={})
    # Try reconnect, with RHBZ testing
    bz.connect("https:///fake/bugzilla.redhat.com")
    bz.connect()

    # Test auto login if user/password is set
    bz = tests.mockbackend.make_bz(
        bz_kwargs={
            "user": "******",
            "password": "******"
        },
        user_login_args="data/mockargs/test_api_login2.txt",
        user_login_return={},
        user_logout_args=None,
        user_logout_return={})

    # Test logout
    bz.logout()
예제 #6
0
 def test_get_tracker_bugs_empty(self):
     bugs = [None]
     bz = bugzilla.Bugzilla(None)
     bzapi = flexmock(bz)
     bzapi.should_receive('getbugs').once().and_return(bugs)
     self.assertRaises(exceptions.BugzillaFatalError,
                       bzutil.get_tracker_bugs, bzapi, [1])
예제 #7
0
    def __init__(self, consumer, config):
        self.consumer = consumer
        self.config = config
        self.log = logging.getLogger('fedmsg')
        default = 'https://partner-bugzilla.redhat.com'
        url = self.config.get('url', default)
        self.username = self.config['user']
        password = self.config['password']
        self.bugzilla = bugzilla.Bugzilla(url=url,
                                          cookiefile=None,
                                          tokenfile=None)
        self.log.info("Logging in to %s" % url)
        self.bugzilla.login(self.username, password)

        self.base_query['product'] = self.config['product']
        self.base_query['email1'] = self.config['user']

        self.new_bug['product'] = self.config['product']
        if "keywords" in self.config:
            self.new_bug['keywords'] = self.config['keywords']
        self.new_bug['version'] = self.config['version']
        self.new_bug['status'] = self.config['bug_status']

        self.short_desc_template = self.config['short_desc_template']
        self.description_template = self.config['description_template']
예제 #8
0
    def authenticate_to_bz(self):
        """
        Function for generating time worked on bugs a report that
        is generally found at /summarize_time.cgi.
        """

        if self.begin_date == "" or self.end_date == "":
            print("Error in setting dates")
            sys.exit(1)

        self.print_v("Begin Date:", self.begin_date)
        self.print_v("End Date:", self.end_date)
        #base_url = "https://bugzilla.example.com"
        #NOTE: Must NOT have a / at the end of the base_url

        #Look in a .bugzillarc file
        try:
            base_url = bugzilla.Bugzilla.get_rcfile_default_url()
        except AttributeError:
            print("Error in getting URL. Is your .bugzillarc file setup? ")
            sys.exit(2)

        self.print_v("Connecting to: ", base_url)

        if base_url is None or base_url == "":
            print("Error in getting URL. Is your .bugzillarc file setup? ")
            print("Do you have something in that file like")
            print("[DEFAULT]")
            print("url=https://www.example.com")
            print("api_key=your_api_key_here")
            sys.exit(2)

        #If you don't have a ~/.bugzillarc file then you'll have to have an API key
        #api_key = input("Enter Bugzilla API Key: ")

        try:
            #bzapi = bugzilla.Bugzilla(url=base_url, api_key=api_key)
            bzapi = bugzilla.Bugzilla(url=base_url)
        except TimeoutError:
            print("Timeout in creating connection to", base_url)
        except TypeError:
            print("Error in type connection to", base_url)

        if not bzapi.logged_in:
            print(
                "Error: Not Logged in. Lookup API/cached credentials for %s" %
                base_url)
            print(
                "  Try creating a .bugzillarc file with the following information in it"
            )
            print("    [%s]" % base_url)
            print("    url=%s" % base_url)
            print("    user=<your username>")
            print(
                "    api_key=<the api key you get at %s/userprefs.cgi?tab=apikey>"
                % base_url)
            sys.exit(0)
        #assert bzapi.logged_in

        return bzapi, base_url
예제 #9
0
def main(ref_repo_path):
    GITHUB_DEV_MAPPING = os.environ['GITHUB_DEV_MAPPING']
    GITHUB_PROJ_MAPPING = os.environ['GITHUB_PROJ_MAPPING']
    GITHUB_USERNAME = os.environ['GITHUB_USERNAME']
    GITHUB_TOKEN_FILE = os.environ['GITHUB_TOKEN_FILE']
    GITHUB_REPO = os.environ['GITHUB_REPO']

    with open(GITHUB_TOKEN_FILE) as f:
        token = f.read().strip()

    BUGZILLA_URL = os.environ['BUGZILLA_URL']
    BUGZILLA_APIKEY_FILE = os.environ['BUGZILLA_APIKEY_FILE']

    with open(BUGZILLA_APIKEY_FILE) as f:
        bugz_apikey = f.read().strip()

    g = github.Github(GITHUB_USERNAME, token, per_page=50)
    r = g.get_repo(GITHUB_REPO)
    bz = bugzilla.Bugzilla(BUGZILLA_URL, api_key=bugz_apikey)

    with open(GITHUB_DEV_MAPPING) as f:
        dev_mapping = json.load(f)
    with open(GITHUB_PROJ_MAPPING) as f:
        proj_mapping = json.load(f)
    with open(os.path.join(ref_repo_path, 'profiles/categories')) as f:
        categories = [l.strip() for l in f.read().splitlines()]

    for issue in r.get_issues(state='open'):
        # note: we need github.Issue due to labels missing in PR
        pr_getter = lambda: r.get_pull(issue.number)
        assign_one(pr_getter, issue, dev_mapping, proj_mapping, categories,
                   GITHUB_USERNAME, ref_repo_path, bz, BUGZILLA_URL)

    return 0
예제 #10
0
 def login(self):
     client = bugzilla.Bugzilla(self._server)
     if not client.logged_in:
         raise ValueError(
             f"elliott requires cached login credentials for {self._server}. Login using 'bugzilla "
             "login --api-key")
     return client
예제 #11
0
파일: get_bugs.py 프로젝트: bonnettang/ml
 def __init__(self, bugzilla_url=None,mongodb_host=None):
     super(GetBug, self).__init__()
     if bugzilla_url is None:
         self.bugzilla_url='bugzilla.arubanetworks.com'
     else:
         self.bugzilla_url = bugzilla_url
     if mongodb_host is None:
         self.mongodb_host='10.65.9.99'
     else:
         self.mongodb_host=mongodb_host
     self.mongo_conn=MongoClient(self.mongodb_host,27017)
     self.db=self.mongo_conn.bugzilla
     self.bug_table=self.db.bug_table3
     self.bzapi = bugzilla.Bugzilla(self.bugzilla_url)
     self.user_table=self.db.user_table
     self.logger = logging.getLogger("simple_example")
     self.logger.setLevel(logging.INFO)
     current=datetime.now().strftime("%d%m%y-%H%M%S")
     fh = logging.FileHandler('get_bug'+current+'.log')
     fh.setLevel(logging.INFO)
     ch = logging.StreamHandler()
     ch.setLevel(logging.INFO)
     formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
     ch.setFormatter(formatter)
     fh.setFormatter(formatter)
     self.logger.addHandler(ch)
     self.logger.addHandler(fh)
예제 #12
0
    def __init__(self, consumer, config):
        self.consumer = consumer
        self.config = config
        default = "https://partner-bugzilla.redhat.com"
        url = self.config.get("url", default)
        self.username = self.config["user"]
        password = self.config["password"]
        self.bugzilla = bugzilla.Bugzilla(url=url,
                                          cookiefile=None,
                                          tokenfile=None)
        self.bugzilla.bug_autorefresh = True
        _log.info("Logging in to %s" % url)
        self.bugzilla.login(self.username, password)

        self.base_query["product"] = self.config["product"]
        self.base_query["email1"] = self.config["user"]

        self.new_bug["product"] = self.config["product"]
        if "keywords" in self.config:
            self.new_bug["keywords"] = self.config["keywords"]
        self.new_bug["version"] = self.config["version"]
        self.new_bug["status"] = self.config["bug_status"]

        self.short_desc_template = self.config["short_desc_template"]
        self.description_template = self.config["description_template"]
def add_missing_descriptions(in_reports, out_reports, api_key, url):
    with open(in_reports) as bug_report_file:
        bug_reports = json.load(bug_report_file)

    empty_descriptions_keys = []
    for key in bug_reports:
        if bug_reports[key]['bug_report']['description'] is None:
            empty_descriptions_keys.append(key)
    print("Missing bug report keys size", len(empty_descriptions_keys))

    new_bug_reports = {}
    b = bugzilla.Bugzilla(url=url, api_key=api_key)
    for key in tqdm(empty_descriptions_keys):
        current_bug_id = bug_reports[key]['bug_report']['bug_id']
        try:
            time.sleep(1)
            comments = b.get_comments(current_bug_id)
            description = find_description(
                comments['bugs'][current_bug_id]['comments'])
            bug_reports[key]['bug_report']['description'] = description
            new_bug_reports[key] = bug_reports[key]
        except json.decoder.JSONDecodeError:
            print(current_bug_id)
            break

    with open(out_reports, 'w') as bug_report_out_file:
        json.dump(new_bug_reports, bug_report_out_file)
예제 #14
0
    def __init__(self, bugzilla_url, github_access_token, github_repo):
        """
        Prepares the API to bugzilla and github and sets up logging.
        """
        self._setup_logging()

        if self.with_graceful_exithandler:
            self._original_sigint = signal.getsignal(signal.SIGINT)
            signal.signal(signal.SIGINT, self._exit_gracefully)

        self.logger.info("Setting up bugzilla API %s", bugzilla_url)
        self.bugzilla_url = bugzilla_url
        self.bzapi = bugzilla.Bugzilla(bugzilla_url)

        self.logger.info("Setting up github API")
        self.github_access_token = github_access_token
        self.gh = github.Github(self.github_access_token)

        self.logger.info("Setting up github repo")
        self.github_repo = github_repo
        self.repo = self.gh.get_repo(self.github_repo)

        # Get remaining github API requests
        self.remaining_requests = 0
        self.remaining_requests = self.gh.get_rate_limit().core.remaining
        self.remaining_requests_last_refreshed = time.time()
        self.logger.debug("Remaining github API requests: %d",
                          self.remaining_requests)
예제 #15
0
def get_api_client(conf):
    """
    Returns a new Bugzilla API client with the provided configuration.

    :returns: a Bugzilla API client object
    """
    return bugzilla.Bugzilla(conf.bugzilla.url, api_key=conf.bugzilla.api_key)
예제 #16
0
    def __init__(self, *args, **kw):
        super(BugzillaService, self).__init__(*args, **kw)
        self.base_uri = self.config_get('base_uri')
        self.username = self.config_get('username')
        self.password = self.config_get('password')
        self.ignore_cc = self.config_get_default('ignore_cc',
                                                 default=False,
                                                 to_type=lambda x: x == "True")
        # So more modern bugzilla's require that we specify
        # query_format=advanced along with the xmlrpc request.
        # https://bugzilla.redhat.com/show_bug.cgi?id=825370
        # ...but older bugzilla's don't know anything about that argument.
        # Here we make it possible for the user to specify whether they want
        # to pass that argument or not.
        self.advanced = asbool(self.config_get_default('advanced', 'no'))

        if not self.password or self.password.startswith("@oracle:"):
            self.password = get_service_password(
                self.get_keyring_service(self.config, self.target),
                self.username,
                oracle=self.password,
                interactive=self.config.interactive)

        url = 'https://%s/xmlrpc.cgi' % self.base_uri
        self.bz = bugzilla.Bugzilla(url=url)
        self.bz.login(self.username, self.password)
예제 #17
0
def run_main(options):
    if not options.bz_url : return
    print_log("Starting bugz script %s" % options.bz_url)
    BUGZILLA = bugzilla.Bugzilla(url=options.bz_url)
    if not BUGZILLA.logged_in:
        print_log("Unable to log into %s" % options.bz_url)
        BUGZILLA.interactive_login()
    t1 = time.time()
    if not options.bugid:
       print_log("Initiating Query %s" % options.q_url)
       query = BUGZILLA.url_to_query(options.q_url)
       query["include_fields"] = ["id", "summary", "status"]
       buglist = BUGZILLA.query(query)
       print_log ("The query returned %d Bugs" % len(buglist))
       create_folder(LOCAL_BZ_FOLDER) 
       os.chdir(LOCAL_BZ_FOLDER)
       count = len(buglist) - 1 
       for b in buglist:
         if count :
           print_log("Creating %d & downloading attachments..." % b.id)
           create_folder(str(b.id))
           os.chdir(str(b.id))
           get_bug_all_attachments(BUGZILLA,b)
           count = count - 1
           os.chdir(LOCAL_BZ_FOLDER)
    else:
       print_log ("Bug id = %d" % options.bugid)
       bug = BUGZILLA.getbug(options.bugid)
       get_bug_all_attachments(BUGZILLA,bug)
    t2 = time.time()
    print_log ("Processing Time : %s" % (t2 - t1))
    return 0
예제 #18
0
    def __init__(self):
        self.master = Master()
        self.slave = Slave()
        self.bz = bugzilla.Bugzilla(url="https://bugzilla.redhat.com/xmlrpc.cgi",
                                    cookiefile=None)

        self.bz.login(config.BZ_USER, config.BZ_PASSWORD)
예제 #19
0
파일: fetch_bz.py 프로젝트: zulcss/infrared
def main():

    result = {}

    module_args = dict(
        id=dict(type='int', required=True),
        url=dict(type='str', required=False, default=URL),
        user=dict(type='str', rebuild=False, default=None),
        password=dict(type='str', rebuild=False, default=None, no_log=True),
        sslverify=dict(type='bool', required=False, default=True),)

    module = AnsibleModule(
        argument_spec=module_args,
        supports_check_mode=False,)

    bz_id = module.params.pop('id')

    try:
        bzapi = bugzilla.Bugzilla(**module.params)
        bug = bzapi.getbug(objid=bz_id)

        result.update(
            {key: val for key, val in vars(bug).items()
             if is_serializable(val)})

    # Raised when the user is not authorized or not logged in
    except xmlrpclib.Fault as ex:
        result['msg'] = ' '.join((str(ex.faultCode), ex.faultString))
        module.fail_json(**result)
    except Exception as ex:
        result['msg'] = ex.message
        module.fail_json(**result)

    module.exit_json(**result)
예제 #20
0
파일: main.py 프로젝트: gouthampacha/jeeves
def get_bugs_dict(bug_ids):
    ''' takes in set of bug_ids and returns dictionary with
		bug_ids as keys and API data as values
	'''

    # initialize bug dictionary
    bugs = {}

    # iterate through bug ids from set
    for bug_id in bug_ids:

        # 0 should be default in YAML file (i.e. no bugs recorded)
        # if present reference should be made in bug dict
        if bug_id == 0:
            bugs[0] = {'bug_name': 'No bug on file', 'bug_url': None}
            continue

        # get bug info from bugzilla API
        try:

            # hotfix: API call does not work if '/' present at end of URL string
            parsed_bz_url = config['bz_url'].rstrip('/')

            bz_api = bugzilla.Bugzilla(parsed_bz_url)
            bug = bz_api.getbug(bug_id)
            bug_name = bug.summary
        except Exception as e:
            print("Bugzilla API Call Error: ", e)
            bug_name = "BZ#" + str(bug_id)
        finally:
            bug_url = config['bz_url'] + "/show_bug.cgi?id=" + str(bug_id)
            bugs[bug_id] = {'bug_name': bug_name, 'bug_url': bug_url}

    return bugs
예제 #21
0
    def __init__(self, email, *args, **kwargs):
        super(BugzillaPlugin, self).__init__(*args, **kwargs)
        self.email = email

        url = "{0}/xmlrpc.cgi".format(self.url.geturl())
        self._bz = bugzilla.Bugzilla(url=url)
        self._bz.login(user=self.login, password=self.password)
예제 #22
0
    def __init__(
        self,
        server_url: str,
        api_key: str,
    ) -> None:
        """
        Class constructor.

        It initializes bugzilla session using the provided credentials.
        If the `api_key` is not provided it raises an `PatcherException`.

        Params:
            server_url: URL of the bugzilla server
            api_key: API key to use for authentication

        Raises:
            PatcherException: When the bugzilla session can't be established
        """
        super(Bugzilla, self).__init__()
        if api_key:
            self.bugzilla = bugzilla.Bugzilla(url=server_url,
                                              api_key=api_key,
                                              cookiefile=None,
                                              tokenfile=None)
        else:
            raise PatcherException(
                "Authentication info not provided! Provide API key.")
        self.bugzilla.bug_autorefresh = True
예제 #23
0
def pytest_configure(config):
    """
    If bugzilla is neabled, setup a session
    with bugzilla_url.

    :param config: configuration object
    """

    config.addinivalue_line(
        "markers",
        "bugzilla(*bug_ids, **guards): Bugzilla integration",
    )
    if config.getvalue("bugzilla") and config.getvalue('bugzilla_url'):
        url = config.getvalue('bugzilla_url')
        user = config.getvalue('bugzilla_username')
        password = config.getvalue('bugzilla_password')
        version = config.getvalue('bugzilla_version')
        loose = [
            x.strip()
            for x in config.getvalue('bugzilla_loose').strip().split(",", 1)
        ]
        if len(loose) == 1 and not loose[0]:
            loose = []

        bz = bugzilla.Bugzilla(url=url, user=user, password=password)

        my = BugzillaHooks(config, bz, loose, version)
        assert config.pluginmanager.register(my, "bugzilla_helper")
예제 #24
0
def get_bzapi(bz_data, interactive_login=False):
    bzapi = bugzilla.Bugzilla(bz_data['server'])
    if not bzapi.logged_in:
        print("elliott requires cached login credentials for {}".format(bz_data['server']))
        if interactive_login:
            bzapi.interactive_login()
    return bzapi
예제 #25
0
파일: zilla.py 프로젝트: hesaul/MozDef
    def __init__(self, *args, **kwargs):
        super(Zilla, self).__init__(*args, **kwargs)
        self._stop = False
        self.thread = threading.Thread(target=self.loop, name='zilla')
        self.thread.daemon = True

        config = self.controller.config
        try:
            self.url = config.get("zilla", "url")
            self.api_key = config.get("zilla", "api_key")
            self.interval = config.getint("zilla", "interval")
            self.channel = config.get('zilla', 'channel')
        except AttributeError:
            _log.warning(
                "Couldn't load the Zilla module, check your configuration.")
            self.url = "https://example.com"
            self.api_key = "DEADBEEF"
            self.interval = 9999999
            self.channel = '#test'

        self._bugzilla = bugzilla.Bugzilla(url=self.url + 'rest/',
                                           api_key=self.api_key)

        _log.info("zilla module initialized for {}, pooling every {} seconds.".
                  format(self.url, self.interval))
예제 #26
0
def bugtracker(arch, bug):
    """The function handles all the web requests using requests library"""

    config = yml_parser()

    bz = bugzilla.Bugzilla(config["url"])
    bz.login(config["login"], config["password"])

    if arch[0] is "~":
        arch = arch[1:]

        update = bz.build_update(cc_remove="{}@gentoo.org".format(arch),
                                 comment="~{} keyworded".format(arch))

        bz.update_bugs(bug, update)

    else:

        update = bz.build_update(cc_remove="{}@gentoo.org".format(arch),
                                 comment="{} stable".format(arch))

        bz.update_bugs(bug, update)

    print(
        colored("Posted comment to {}/{}".format(config["url"], bug), "green"))
예제 #27
0
    def __init__(self, hub):
        super(BugzillaConsumer, self).__init__(hub)

        self.config = config = hub.config

        # Backwards compat.  We used to have a self.debug...
        self.debug = self.log.info

        products = config.get('bugzilla.products', 'Fedora, Fedora EPEL')
        self.products = [product.strip() for product in products.split(',')]

        # First, initialize fedmsg and bugzilla in this thread's context.
        hostname = socket.gethostname().split('.', 1)[0]
        fedmsg.init(name='bugzilla.%s' % hostname)

        url = self.config.get('bugzilla.url', 'https://bugzilla.redhat.com')
        username = self.config.get('bugzilla.username', None)
        password = self.config.get('bugzilla.password', None)

        self.bugzilla = bugzilla.Bugzilla(url=url)
        if username and password:
            self.debug("Logging in to %s" % url)
            self.bugzilla.login(username, password)
        else:
            self.debug("No credentials found.  Not logging in to %s" % url)

        self.debug("Initialized bz2fm STOMP consumer.")
예제 #28
0
    def __init__(self, *args, **kw):
        super(BugzillaService, self).__init__(*args, **kw)
        base_uri = self.config.get(self.target, 'bugzilla.base_uri')
        username = self.config.get(self.target, 'bugzilla.username')
        password = self.config.get(self.target, 'bugzilla.password')

        # So more modern bugzilla's require that we specify
        # query_format=advanced along with the xmlrpc request.
        # https://bugzilla.redhat.com/show_bug.cgi?id=825370
        # ...but older bugzilla's don't know anything about that argument.
        # Here we make it possible for the user to specify whether they want
        # to pass that argument or not.
        self.advanced = True  # Default to True.
        if self.config.has_option(self.target, 'bugzilla.advanced'):
            self.advanced = asbool(
                self.config.get(self.target, 'bugzilla.advanced'))

        if not password or password.startswith("@oracle:"):
            service = "bugzilla://%s@%s" % (username, base_uri)
            password = get_service_password(
                service,
                username,
                oracle=password,
                interactive=self.config.interactive)

        url = 'https://%s/xmlrpc.cgi' % base_uri
        self.bz = bugzilla.Bugzilla(url=url)
        self.bz.login(username, password)
예제 #29
0
    def _connect(self):
        if self.connected:
            return

        if not self.api_url:
            raise FafConfigError(
                "No api_url specified for '{0}' bugzilla instance"
                .format(self.name))

        self.log_debug("Opening bugzilla connection for '{0}'"
                       .format(self.name))

        self.bz = bugzilla.Bugzilla(url=str(self.api_url), cookiefile=None,
                                    tokenfile=None)

        if self.user and self.password:
            self.log_debug("Logging into bugzilla '{0}' as '{1}'"
                           .format(self.name, self.user))

            self.bz.login(self.user, self.password)
        else:
            self.log_warn("No user and password specified for '{0}' bugzilla"
                          "instance, using anonymously")

        self.connected = True
예제 #30
0
파일: bz.py 프로젝트: wfranzini/bugwarrior
    def __init__(self, *args, **kw):
        super(BugzillaService, self).__init__(*args, **kw)
        self.base_uri = self.config_get('base_uri')
        self.username = self.config_get('username')
        self.ignore_cc = self.config_get_default('ignore_cc',
                                                 default=False,
                                                 to_type=lambda x: x == "True")
        self.query_url = self.config_get_default('query_url', default=None)
        self.include_needinfos = self.config_get_default(
            'include_needinfos', False, to_type=lambda x: x == "True")
        self.open_statuses = self.config_get_default(
            'open_statuses', _open_statuses, to_type=lambda x: x.split(','))
        log.name(self.target).debug(" filtering on statuses: {0}",
                                    self.open_statuses)

        # So more modern bugzilla's require that we specify
        # query_format=advanced along with the xmlrpc request.
        # https://bugzilla.redhat.com/show_bug.cgi?id=825370
        # ...but older bugzilla's don't know anything about that argument.
        # Here we make it possible for the user to specify whether they want
        # to pass that argument or not.
        self.advanced = asbool(self.config_get_default('advanced', 'no'))

        self.password = self.config_get_password('password', self.username)

        url = 'https://%s/xmlrpc.cgi' % self.base_uri
        self.bz = bugzilla.Bugzilla(url=url)
        self.bz.login(self.username, self.password)