0

This question has been updated

I am writing a python script using the python-bugzilla 1.1.0 pypi. I am able to get all the bug IDs but I want to know if there is a way for me to access each bug's XML page? Here is the code I have so far:

bz = bugzilla.Bugzilla(url='https://bugzilla.mycompany.com/xmlrpc.cgi')
try:
   bz.login('name@email.com', 'password');
   print'Authorization cookie received.'
except bugzilla.BugzillaError:
   print(str(sys.exc_info()[1]))
   sys.exit(1)

#getting all the bug ID's and displaying them
bugs = bz.query(bz.build_query(assigned_to="your-bugzilla-account"))
for bug in bugs:
    print bug.id

I don't know how to access each bug's XML page and not sure if it is even possible to do so. Can anyone help me with this? Thanks.

Redson
  • 2,098
  • 4
  • 25
  • 50
  • Why do you need the XML page? Maybe you should describe this, because otherwiese you can do a bug.__dict__ instead of bug.id and you will see the information stored in the bug. – Sven Jan 19 '15 at 16:05
  • @Sven Could you please elaborate on what bug.__dict__ does? I am trying to access the XML page because I can't get attributes such as comments, dupe_of, QA and assignee's name when I'm trying to access them using xml-rpc – Redson Jan 19 '15 at 16:15
  • Ok, bug.__dict__ can show you some internal defined things which can be accessed. for e.g. bug.assigned_to will give you the assigned person and bug.depends_on the dependencies. Using the XML directly is not neccessary, but for the whiteboard things there must be an extra option it is omitted by default. But I have no example for the moment. Maybe looging to the bug.py or the base.py in the plugins diretory. – Sven Jan 20 '15 at 16:13

2 Answers2

0
bz.getbugs()

Will get all bugs, bz.getbugssimple is also worth a look.

Steve Barnes
  • 27,618
  • 6
  • 63
  • 73
  • For both of those methods, I need to pass a list of bug IDs as parameters. I want to know if I can query for all bug IDs – Redson Jan 12 '15 at 14:35
0
#!/usr/bin/env python

import bugzilla

bz = bugzilla.Bugzilla(url='https://bugzilla.company.com/xmlrpc.cgi')
bz.login('username@company.com', 'password')

results = bz.query(bz.url_to_query(queryUrl))

bids = []

for b in results:
   bids.append(b.id)

print bids
Eric
  • 636
  • 2
  • 9
  • 23