Bug
|
Size: 7634
Comment:
|
Size: 8836
Comment:
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 1: | Line 1: |
| ||<tablestyle="float:right; font-size: 0.9em; width:40%; background:#F1F1ED; margin: 0 0 1em 1em;" style="padding:0.5em;">'''Contents'''[[BR]][[TableOfContents]]|| | ||<tablestyle="float:right; font-size: 0.9em; width:40%; background:#F1F1ED; margin: 0 0 1em 1em;" style="padding:0.5em;"><<TableOfContents>>|| |
| Line 9: | Line 9: |
| >>> import launchpadbugs.connector as Connector >>> Bug = Connector.ConnectBug() |
>>> from launchpadbugs.connector import ConnectBug >>> Bug = ConnectBug() # using the html mode of launchpad |
| Line 14: | Line 14: |
| This will give you read-write access to a bugreport, but if you are looking for a faster but read-only method you can also use: {{{#!python start=2 >>> Bug = ConnectBug("text") # using the text mode of launchpad }}} |
|
| Line 16: | Line 22: |
| {{{#!python start=3 | {{{#!python start=4 |
| Line 22: | Line 28: |
| {{{#!python start=4 | {{{#!python start=5 |
| Line 24: | Line 30: |
| >>> Bug.authentication="cookie.sql" #for sql mozilla cookie files or | >>> Bug.authentication="cookie.sql" #for sql mozilla cookie files }}} It is also possible to do authentication via email-login and password. Note: This takes much longer than using cookie files, therefor python-launchpad-bugs provides a method to save the resulting cookie into a file {{{#!python start=7 |
| Line 26: | Line 37: |
| }}} There are currently different versions of launchpad, the stable bugs.launchpad.net and the testing environment bugs.edge.launchpad.net. Sometimes it makes sense to explicitly choose one of these versions to work with. In python-launchpad-bugs it is possible to define which version to use (''this currently only works in lp:~bughelper-dev/python-launchpad-bugs/intrepid.merge'') |
>>> Bug.connection.save_cookie("/home/markus/.lpcookie") }}} There are currently different versions of launchpad, the stable bugs.launchpad.net and the testing environment bugs.edge.launchpad.net. Sometimes it makes sense to explicitly choose one of these versions to work with. In python-launchpad-bugs it is possible to define which version to use. |
| Line 46: | Line 58: |
| ||.activity||Activity Log of a bugreport (type: list)|| [#activity] || ||.assignee||Person assigned to a bugreport (type: user)|| [#user] || ||.attachments||List of attachments|| [#attachments] || |
||.activity||Activity Log of a bugreport (type: list)|| [[#activity]] || ||.assignee||Person assigned to a bugreport (type: user)|| [[#user]] || ||.attachments||List of attachments|| [[#attachments]] || |
| Line 51: | Line 63: |
| ||.changed||List of local changes to a bugreport|| [#changed] || ||.comments||List of comments|| [#comments] || |
||.changed||List of local changes to a bugreport|| [[#changed]] || ||.comments||List of comments|| [[#comments]] || |
| Line 60: | Line 72: |
| ||.infotable|| || || | ||.infotable|| || [[#tasks]] || |
| Line 78: | Line 90: |
| [[Anchor(activity)]] Get the Activity Log: | <<Anchor(activity)>> Get the Activity Log: |
| Line 95: | Line 107: |
| [[Anchor(attachments)]] Get a list of attachments: | <<Anchor(attachments)>> Get a list of attachments: |
| Line 109: | Line 121: |
| There are two ways of downloading an attachment: {{{#!python start=7 >>> bug.attachments[0].text #this will get the content and # download the file to # ~/.bughelper/attachments-cache/<package>/<bugnumber>/<attachment_id>/<filename> 'content of the file' >>> bug.attachments[0].download("/tmp/filename.ext") #this will download the file to /tmp/filename.ext }}} |
|
| Line 123: | Line 145: |
| Line 124: | Line 147: |
| >>> bug.attachments.remove(test_filter) | >>> bug.attachments.remove(func=test_filter) |
| Line 153: | Line 176: |
| [[Anchor(comments)]] Get a list of comments: | <<Anchor(comments)>> Get a list of comments: |
| Line 167: | Line 190: |
| === Tasks === <<Anchor(tasks)>> Create a new task: {{{#!python >>> import launchpadbugs.connector as con >>> Bug = con.ConnectBug() >>> Bug.authentication = "cookies.sqlite" >>> task = Bug.NewTask("project", "bzr-fs") >>> b = Bug(214490) >>> b.infotable.addTask(task) >>> b.commit() }}} |
|
| Line 169: | Line 205: |
| [[Anchor(user)]] User are String-like objects with an additional attribute `.realname`.[[BR]] | <<Anchor(user)>> User are String-like objects with an additional attribute `.realname`.<<BR>> |
| Line 183: | Line 219: |
| [[Anchor(changed)]] {{{#!python start=41 | <<Anchor(changed)>> {{{#!python start=41 |
Bug - tutorial
General workflow
That is the way to use python-launchpad-bugs to get information on a bugreport or to edit a bugreport:
This will give you read-write access to a bugreport, but if you are looking for a faster but read-only method you can also use:
2 >>> Bug = ConnectBug("text") # using the text mode of launchpad
It is also possible to get a bugreport by its url:
4 >>> 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:
It is also possible to do authentication via email-login and password. Note: This takes much longer than using cookie files, therefor python-launchpad-bugs provides a method to save the resulting cookie into a file
There are currently different versions of launchpad, the stable bugs.launchpad.net and the testing environment bugs.edge.launchpad.net. Sometimes it makes sense to explicitly choose one of these versions to work with. In python-launchpad-bugs it is possible to define which version to use.
1 >>> from launchpadbugs.lpconstants import HTTPCONNECTION
2 >>> b = Bug(123456)
3 >>> b.url
4 'https://bugs.launchpad.net/ubuntu/+source/xine-lib/+bug/123456'
5 >>> Bug.set_connection_mode(HTTPCONNECTION.MODE.EDGE)
6 >>> b = Bug(123456)
7 >>> b.url
8 'https://bugs.edge.launchpad.net/ubuntu/+source/xine-lib/+bug/123456'
Attributes of a bugreport
Overview
Attribute |
Description |
Example |
.activity |
Activity Log of a bugreport (type: list) |
|
.assignee |
Person assigned to a bugreport (type: user) |
|
.attachments |
List of attachments |
|
.branches |
List of bzr branches (only available in html mode) |
|
.bugnumber |
Number of a bugreport (type: int) |
|
.changed |
List of local changes to a bugreport |
|
.comments |
List of comments |
|
.date |
|
|
.description |
|
|
.duplicate_of |
|
|
.duplicates |
List of duplicates of a bug |
|
.get_subscriptions_category |
Subscribers broken into 'directly', 'notified', and 'duplicates' |
|
.importance |
|
|
.info |
|
|
.infotable |
|
|
.milestone |
|
|
.nickname |
|
|
.private |
|
|
.reporter |
|
|
.security |
|
|
.sourcepackage |
|
|
.status |
|
|
.subscriptions |
All subscribers |
|
.summary |
|
|
.tags |
|
|
.target |
|
|
.text |
|
|
.title |
|
|
.url |
|
|
Activity Log
Get the Activity Log:
Members of this list have the following attributes:
- .date, datetime object indicating the time of the change
- .user, lphelper.user object
- .what, string saying what changed
- .old_value. of type str
- .new_value, of type str
- .message, of type str
Attachments
Get a list of attachments:
As you can see there are four files attached to the bug and the first attachment has already been downloaded.
There are two ways of downloading an attachment:
7 >>> bug.attachments[0].text #this will get the content and
8 # download the file to
9 # ~/.bughelper/attachments-cache/<package>/<bugnumber>/<attachment_id>/<filename>
10 'content of the file'
11 >>> bug.attachments[0].download("/tmp/filename.ext") #this will download the file to /tmp/filename.ext
You can for example filter the list of attachments by the filename:
These filtered attachments can be easily removed:
To add an attachment you have to create an new attachment-object:
Now you have to add this attachment to the bugreport:
Comments
Get a list of comments:
Create a new comment and add this comment to the bugreport:
Tasks
Create a new task:
User
User are String-like objects with an additional attribute .realname.
Commit changes
get a list of changes
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
Filing a bug report
product is a dictionary like {"name": <lpname of the product>, "target": <distribution>}
product={"name": "python-launchpad-bugs"} creates a bug in https://bugs.launchpad.net/python-launchpad-bugs/
product={"name": "python-launchpad-bugs", "target": "ubuntu"} creates a bug in https://bugs.launchpad.net/ubuntu/+source/python-launchpad-bugs/
product={"name": "ubuntu"} creates a bug in https://bugs.launchpad.net/ubuntu/ (bug in "ubuntu" without a sourcepackage)
other optional arguments to .New():
tags: list of tags like ["foo", "bar"]
security_related (default: False)
BugHelper/Dev/python-launchpad-bugs/Bug (last edited 2008-08-12 22:24:51 by c-24-21-234-111)