Bug

Differences between revisions 5 and 9 (spanning 4 versions)
Revision 5 as of 2007-07-24 17:31:30
Size: 3178
Editor: a89-182-112-118
Comment:
Revision 9 as of 2007-09-03 07:03:20
Size: 4791
Editor: a89-182-150-140
Comment:
Deletions are marked like this. Additions are marked like this.
Line 27: Line 27:
'' add a table of all attributes ''
||'''Attribute'''||'''Description'''||'''Example'''||
||.assignee||Person assigned to a bugreport (type: user)|| [#user] ||
||.attachments||List of attachments|| [#attachments] ||
||.bugnumber||Number of a bugreport (type: int)|| ||
||.changed||List of local changes to a bugreport|| [#changed] ||
||.comments||List of comments|| [#comments] ||
||.date|| || ||
||.description|| || ||
||.duplicate_of|| || ||
||.duplicates||List of duplicates of a bug|| ||
||.importance|| || ||
||.info|| || ||
||.infotable|| || ||
||.milestone|| || ||
||.nickname|| || ||
||.private|| || ||
||.reporter|| || ||
||.security|| || ||
||.sourcepackage|| || ||
||.status|| || ||
||.subscribtions|| || ||
||.summary|| || ||
||.tags|| || ||
||.target|| || ||
||.text|| || ||
||.title|| || ||
||.url|| || ||
Line 30: Line 57:
Get a list of attachments:
[[Anchor(attachments)]]
Get a list of attachments:
Line 59: Line 87:
>>> bug.attachments.remove([i for i in bug.attachments.filter(test_filter)]) >>> bug.attachments.remove(test_filter)
Line 88: Line 116:
Get a list of comments: [[Anchor(comments)]] Get a list of comments:
Line 102: Line 130:
=== User ===

[[Anchor(user)]] User are String-like objects with an additional attribute `.realname`.[[BR]]
{{{#!python
>>> str(bug.assignee)
'thekorn'
>>> repr(bug.assignee)
'<user thekorn (Markus Korn)>'
>>> bug.assignee.realname
'Markus Korn'
}}}
Line 106: Line 146:
{{{#!python start=41 [[Anchor(changed)]] {{{#!python start=41
Line 118: Line 158:

There are two possible arguments to `.commit()`:
 * `force_changes=<bool>`:
  * `False (default)`:
  * `True`: ''Example:'' If a user tries to add a tag `foo` to a bugreport and `foo` s not a tag in this product yet, launchpad will raise an error. If this option is set to `True` `foo` will be added to the list of tags to this project and than added to this bugreport.
 * `ignore_lp_errors=<bool>`:
  * `True (default)`: ignores launchpad processing errors
  * `False`: raises a `ValueError` if launchpad is unable to change a value

Bug - tutorial

General workflow

That is the way to use python-launchpad-bugs to get information on a bugreport or to edit a bugreport:

   1 >>> import launchpadbugs.connector as Connector
   2 >>> Bug = Connector.ConnectBug()
   3 >>> bug = Bug(120593)

It is also possible to get a bugreport by its url:

   3 >>> bug = Bug(url="https://bugs.launchpad.net/buglog-data/+bug/120593")

If you want to change the bugreport or view private bugs you have to set Bug.authentication:

   4 >>> Bug.authentication="cookie.txt"

Attributes of a bugreport

Overview

Attribute

Description

Example

.assignee

Person assigned to a bugreport (type: user)

[#user]

.attachments

List of attachments

[#attachments]

.bugnumber

Number of a bugreport (type: int)

.changed

List of local changes to a bugreport

[#changed]

.comments

List of comments

[#comments]

.date

.description

.duplicate_of

.duplicates

List of duplicates of a bug

.importance

.info

.infotable

.milestone

.nickname

.private

.reporter

.security

.sourcepackage

.status

.subscribtions

.summary

.tags

.target

.text

.title

.url

Attachments

Anchor(attachments) Get a list of attachments:

   5 >>> for a in bug.attachments:
   6 ...     print a
   7 ... 
   8 <Attachment (up: 8554243), (down: <path-to-file>/120593/8554243/79140.patch)>
   9 <Attachment (up: 8558770)>
  10 <Attachment (up: 8554203)>
  11 <Attachment (up: 8541039)>

As you can see there are four files attached to the bug and the first attachment has already been downloaded.

You can for example filter the list of attachments by the filename:

  12 >>> def test_filter(a):
  13 ...     import re
  14 ...     return re.match("assignee.*", a.lp_filename)
  15 ... 
  16 >>> [i for i in bug.attachments.filter(test_filter)]
  17 [<Attachment (up: 8541039)>]
  18 >>> bug.attachments[8541039].lp_filename
  19 'assignee.patch'

These filtered attachments can be easily removed:

  20 >>> bug.attachments.remove(test_filter)
  21 True

To add an attachment you have to create an new attachment-object:

  22 >>> attachment = Bug.NewAttachment(localfilename="<path-to-file>/79140.patch")
  23 >>> attachment.description = "example patch"
  24 >>> attachment.is_patch = True
  25 >>> attachment
  26 <Attachment (down: <path-to-file>/79140.patch)>

Now you have to add this attachment to the bugreport:

  27 >>> bug.attachments.add(attachment)
  28 >>> for a in bug.attachments:
  29 ...     print a
  30 ... 
  31 <Attachment (up: 8554243), (down: <path-to-file>/120593/8554243/79140.patch)>
  32 <Attachment (up: 8558770)>
  33 <Attachment (up: 8554203)>
  34 <Attachment (down: <path-to-file>/79140.patch)>

Comments

Anchor(comments) Get a list of comments:

  35 >>> [c for c in bug.comments][0:2]
  36 [<Comment 1 by thekorn on 2007-07-20>, <Comment 2 by thekorn on 2007-07-20>]

Create a new comment and add this comment to the bugreport:

  37 >>> comment = Bug.NewComment(text="this is a test comment")
  38 >>> bug.comments.add(comment)
  39 >>> [c for c in bug.comments]
  40 [<Comment 1 by thekorn on 2007-07-20>, <Comment 2 by thekorn on 2007-07-20>, ... , <Comment 'unknown'>]

User

Anchor(user) User are String-like objects with an additional attribute .realname.BR

   1 >>> str(bug.assignee)
   2 'thekorn'
   3 >>> repr(bug.assignee)
   4 '<user thekorn (Markus Korn)>'
   5 >>> bug.assignee.realname
   6 'Markus Korn'

Commit changes

get a list of changes

Anchor(changed)

  41 >>> for i in bug.changed:
  42 ...     print i
  43 ... 
  44 (<Attachmentlist> changed: (<Attachment (up: 8541039)> deleted), (<Attachment (down: <path-to-file>/79140.patch)> added))
  45 (<Commentslist> changed: (<Comment 'unknown'> added))

commit changes

  46 >>> bug.commit()

There are two possible arguments to .commit():

  • force_changes=<bool>:

    • False (default):

    • True: Example: If a user tries to add a tag foo to a bugreport and foo s not a tag in this product yet, launchpad will raise an error. If this option is set to True foo will be added to the list of tags to this project and than added to this bugreport.

  • ignore_lp_errors=<bool>:

    • True (default): ignores launchpad processing errors

    • False: raises a ValueError if launchpad is unable to change a value

BugHelper/Dev/python-launchpad-bugs/Bug (last edited 2008-08-12 22:24:51 by c-24-21-234-111)