Merge lp:~doctormo/python-snippets/lp-merge-request-example into lp:~jonobacon/python-snippets/trunk

Proposed by Martin Owens
Status: Needs review
Proposed branch: lp:~doctormo/python-snippets/lp-merge-request-example
Merge into: lp:~jonobacon/python-snippets/trunk
Diff against target: 34 lines (+30/-0)
1 file modified
launchpadlib/merge-request.py (+30/-0)
To merge this branch: bzr merge lp:~doctormo/python-snippets/lp-merge-request-example
Reviewer Review Type Date Requested Status
Jono Bacon Needs Fixing
Martin Owens (community) Needs Resubmitting
Review via email: mp+18278@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Martin Owens (doctormo) wrote :

Added in a new merge request example... which I'm using to submit this merge request.

Revision history for this message
Jono Bacon (jonobacon) wrote :

I am getting an error, Martin:

jono@forge:~/source/bzr/python-snippets/launchpadlib$ python merge-request.py
Traceback (most recent call last):
  File "merge-request.py", line 11, in <module>
    os.makedir(CACHE_DIR)
AttributeError: 'module' object has no attribute 'makedir'

Could you take a look and fix?

Also, the snippet does not have the meta-data required, see https://wiki.ubuntu.com/PythonSnippets for details. :-)

Revision history for this message
Jono Bacon (jonobacon) :
review: Needs Fixing
Revision history for this message
Martin Owens (doctormo) wrote :

Updated with a fix.

review: Needs Resubmitting
21. By Martin Owens

Fix the make directory line.

Revision history for this message
Jono Bacon (jonobacon) wrote :

Still getting problems, and still no meta data at the top.

jono@forge:~/source/bzr/python-snippets/launchpadlib$ python merge-request.py
Traceback (most recent call last):
  File "merge-request.py", line 14, in <module>
    lp = Launchpad.login_with("python-snippets", STAGING_SERVICE_ROOT)
  File "/usr/lib/pymodules/python2.6/launchpadlib/launchpad.py", line 243, in login_with
    timeout=timeout, proxy_info=proxy_info)
  File "/usr/lib/pymodules/python2.6/launchpadlib/launchpad.py", line 99, in __init__
    credentials, service_root, cache, timeout, proxy_info)
  File "/usr/lib/pymodules/python2.6/lazr/restfulclient/resource.py", line 394, in __init__
    self._wadl = self._browser.get_wadl_application(self._root_uri)
  File "/usr/lib/pymodules/python2.6/lazr/restfulclient/_browser.py", line 241, in get_wadl_application
    url, media_type=wadl_type, extra_headers={'Accept': accept})
  File "/usr/lib/pymodules/python2.6/lazr/restfulclient/_browser.py", line 217, in _request
    raise HTTPError(response, content)
lazr.restfulclient.errors.HTTPError: HTTP Error 401: Unauthorized
Response headers:
---
content-length: 44
content-type: text/plain
date: Sat, 06 Feb 2010 22:51:56 GMT
server: zope.server.http (HTTP)
status: 401
via: 1.1 wildcard.staging.launchpad.net
x-lazr-oopsid: OOPS-1498S207
x-powered-by: Zope (www.zope.org), Python (www.python.org)
---
Response body:
---
Unknown access token (tCLqh00lwH8ZRT5rzXd5).
---

jono@forge:~/source/bzr/python-snippets/launchpadlib$

review: Needs Fixing
Revision history for this message
Tim Penhey (thumper) wrote :

Martin, the Resubmit review isn't normally for you to say it is done, but for a reviewer to say that they think you have completely the wrong idea. Perhaps we should document this better.

Unmerged revisions

21. By Martin Owens

Fix the make directory line.

20. By Martin Owens

Add in new merge request example.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'launchpadlib/merge-request.py'
2--- launchpadlib/merge-request.py 1970-01-01 00:00:00 +0000
3+++ launchpadlib/merge-request.py 2010-02-06 21:59:10 +0000
4@@ -0,0 +1,30 @@
5+# Code by Martin Owens, (c) 2010 GPLv3
6+
7+import os
8+import time
9+from launchpadlib.launchpad import Launchpad, STAGING_SERVICE_ROOT
10+from launchpadlib.credentials import Credentials
11+
12+CACHE_DIR = os.path.expanduser('~/.cache/launchpadlib/')
13+
14+if not os.path.exists(CACHE_DIR):
15+ os.mkdir(CACHE_DIR)
16+
17+# connect ot the staging service of launchpad
18+lp = Launchpad.login_with("python-snippets", STAGING_SERVICE_ROOT)
19+
20+branch = lp.branches.getByUniqueName(unique_name='lp:~foo/bar/child')
21+parent = lp.branches.getByUniqueName(unique_name='lp:~foo/bar/parent')
22+
23+reviewer = parent.reviewer
24+if not reviewer:
25+ reviewer = parent.owner
26+
27+result = self.source_branch.createMergeProposal(
28+ initial_comment=comment,
29+ needs_review=True,
30+ target_branch=parent,
31+ reviewers=(reviewer),
32+ review_types=('')
33+)
34+

Subscribers

People subscribed via source and target branches