Merge lp:~jelmer/bzr-builddeb/newlplib into lp:bzr-builddeb

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: 537
Merged at revision: 537
Proposed branch: lp:~jelmer/bzr-builddeb/newlplib
Merge into: lp:bzr-builddeb
Diff against target: 33 lines (+12/-10)
1 file modified
launchpad.py (+12/-10)
To merge this branch: bzr merge lp:~jelmer/bzr-builddeb/newlplib
Reviewer Review Type Date Requested Status
James Westby Approve
Review via email: mp+52276@code.launchpad.net

This proposal supersedes a proposal from 2011-03-04.

Description of the change

Support the new mechanism for logging in in launchpadlib.

To post a comment you must log in.
Revision history for this message
James Westby (james-w) wrote : Posted in a previous version of this proposal

Hi,

This change doesn't preserve this existing behaviour.

22 + if not os.path.exists(creds_path):
23 + return None

Maybe we don't want that any more, but if not we should
drop it from both code paths.

Thanks,

James

review: Needs Fixing
Revision history for this message
Jelmer Vernooij (jelmer) wrote : Posted in a previous version of this proposal

> This change doesn't preserve this existing behaviour.
>
> 22 + if not os.path.exists(creds_path):
> 23 + return None
>
> Maybe we don't want that any more, but if not we should
> drop it from both code paths.
In what way is that incompatible? Because we'll now perhaps prompt the user to log in ?

I guess we could use "Launchpad.login_anonymously" as an alternative.

Cheers,

Jelmer

Revision history for this message
James Westby (james-w) wrote : Posted in a previous version of this proposal

On Fri, 04 Mar 2011 19:06:17 -0000, Jelmer Vernooij <email address hidden> wrote:
> > This change doesn't preserve this existing behaviour.
> >
> > 22 + if not os.path.exists(creds_path):
> > 23 + return None
> >
> > Maybe we don't want that any more, but if not we should
> > drop it from both code paths.
> In what way is that incompatible? Because we'll now perhaps prompt the user to log in ?

Yeah. IIRC this was done so that you had to explicitly configure it, as
I didn't want to prompt everyone for credentials when this is a feature
that won't have any effect in the vast majority of cases, except for the
importer.

> I guess we could use "Launchpad.login_anonymously" as an alternative.

That would at least avoid the prompt wouldn't it? I'm still not sure it
is worth the round trips, given that the feature is mainly useful for
the importer.

Thanks,

James

Revision history for this message
James Westby (james-w) wrote :

19 + return Launchpad.login_anonymously("bzr-builddeb", "production")

I think I would prefer the keyword form of the service_root argument there
(assuming it has one), but other than that this looks good now.

Thanks,

James

review: Approve
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

> 19 + return Launchpad.login_anonymously("bzr-builddeb",
> "production")
>
> I think I would prefer the keyword form of the service_root argument there
> (assuming it has one), but other than that this looks good now.
WFM, fixed and merged.

Cheers,

Jelmer

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'launchpad.py'
2--- launchpad.py 2010-09-10 02:46:41 +0000
3+++ launchpad.py 2011-03-05 01:24:25 +0000
4@@ -33,17 +33,19 @@
5
6
7 def _get_launchpad():
8- creds_path = os.path.join(config_dir(), "builddeb.lp_creds.txt")
9- if not os.path.exists(creds_path):
10- return None
11- creds = Credentials("bzr-builddeb")
12- f = open(creds_path)
13 try:
14- creds.load(f)
15- finally:
16- f.close()
17- lp = Launchpad(creds, service_root=LPNET_SERVICE_ROOT)
18- return lp
19+ return Launchpad.login_anonymously("bzr-builddeb", "production")
20+ except AttributeError: # older version of launchpadlib
21+ creds_path = os.path.join(config_dir(), "builddeb.lp_creds.txt")
22+ if not os.path.exists(creds_path):
23+ return None
24+ creds = Credentials("bzr-builddeb")
25+ f = open(creds_path)
26+ try:
27+ creds.load(f)
28+ finally:
29+ f.close()
30+ return Launchpad(creds, service_root=LPNET_SERVICE_ROOT)
31
32
33 def ubuntu_bugs_for_debian_bug(bug_id):

Subscribers

People subscribed via source and target branches