[11:43] <shnatsel> Hello!
[11:43] <shnatsel> Does anybody know if I can force bzr to use HTTP transport for Launchpad branches given in "lp:..." format?
[11:45] <shnatsel> I'm going to run an unattended script on a machine that's authenticated to Launchpad with SSH, but the key has a password and it's typically locked, so the script tries to use SFTP transport and fails.
[11:48] <LarstiQ> shnatsel: remove the launchpad login in the config
[11:49] <LarstiQ> shnatsel: launchpad_username in ~/.bazaar/bazaar.conf
[11:49] <LarstiQ> shnatsel: remove/comment out
[11:49] <shnatsel> LarstiQ: the problem is I still want to keep the SSH transport for operations I perform manually
[11:50] <shnatsel> and scripts with such side effects are not a great idea
[11:50]  * LarstiQ nods
[11:50] <shnatsel> maybe there's some environment variable I can export or something like that?
[11:51] <shnatsel> if all else fails I can replace all "lp:" with "https://code.launchpad.net/" but that's ugly and error-prone
[11:52] <LarstiQ> shnatsel: I'm not aware of a good solution, but one is terribly welcome
[11:53] <shnatsel> LarstiQ: okay, where can I get the code for launchpad plugin?
[11:53] <LarstiQ> shnatsel: looking at the bzrlib/plugins/launchpad/lp_directory.py code, it shouldn't be too hard to make it more flexible
[11:53] <LarstiQ> shnatsel: it's part of core bzr, so `bzr branch lp:bzr` will do
[11:54] <shnatsel> I'm more of a shell scripter than a pythoneer, but I'll see what I can do
[11:55] <LarstiQ> shnatsel: bug 238776 it looks like
[11:55] <LarstiQ> shnatsel: feel free to ask for help on how to proceed with that
[11:56] <LarstiQ> shnatsel: my bzr coding is very rusty, but I promise to help review whatever you come up with
[11:56] <shnatsel> LarstiQ: thanks!
[11:57]  * LarstiQ heads for lunch and mathematics
[12:08] <shnatsel> as far as I can tell, _resolve(...) in bzrlib/plugins/launchpad/lp_directory.py is what turns lp: URI into bzr+ssh:// or https:// URI
[12:08] <LarstiQ> shnatsel: yes
[12:10] <LarstiQ> shnatsel: #  Only accept launchpad.net bzr+ssh URLs if we know the user's Launchpad login:
[12:10] <shnatsel> no, that seems to be an unrelated function
[12:10] <LarstiQ> shnatsel: that's in _resolve
[12:10] <shnatsel> oh
[12:10] <shnatsel> I confused it for another function definition, sorry. I see now, thanks!
[12:11] <LarstiQ> shnatsel: you could try to see if http comes up as an option but gets rejected because of that logic
[12:11] <LarstiQ> by say putting a trace.mutter at the start of the loop
[12:11] <shnatsel> oh, by the way, how do I test the changes I make?
[12:12] <LarstiQ> and then tailing ~/.bzr.log
[12:12] <LarstiQ> shnatsel: in the end, by writing a test in test_lp_directory.py I think
[12:12] <LarstiQ> shnatsel: but for starters, change that file, and then run ./bzr from your branch
[12:13] <LarstiQ> shnatsel: bzr can run directly from the branch, no installation needed
[12:13] <LarstiQ> quite handy for development
[12:14] <LarstiQ> shnatsel: doc/developers/HACKING.txt may have some helpful bits for debugging and such
[12:34] <shnatsel> No, it doesn't consider using HTTP transport
[12:34] <shnatsel> well, at least when ssh is available
[12:35] <shnatsel> let me relogin, I can't kill off ssh-agent for some reason
[12:39] <shnatsel> no, it doesn't even consider using HTTP URLs
[12:39] <shnatsel> when bzr+ssh is not available
[12:43] <shnatsel> I'm not sure how to implement proper fallback, it seems to require pretty big changes, as per James Westby's comment on bug 238776
[12:44] <shnatsel> what I can add is checking for environment variable and forcing HTTP if it's set to "true"
[12:47] <shnatsel> I'm not sure if that's an acceptable solution
[12:47] <LarstiQ> shnatsel: I don't think we need to go quite as far as james_w suggested there
[12:48] <LarstiQ> shnatsel: probably not for bzr proper, but you can take that approach locally of course
[12:48]  * LarstiQ does some testing
[12:49] <shnatsel> okay, so I shall add some kind of a URL blacklist parameter to the lookup function, then add error handling to SFTP module that checks if it's a launchpad branch and if it is, try to fall back to other URLs?
[12:51] <LarstiQ> shnatsel: it should be enough to change 'if _lp_login is not None:' to 'if _lp_login is not None or url in blacklist' or somesuch
[12:51] <LarstiQ> shnatsel: because when the launchpad username is not set, lp:bzr resolves to http://  , and when it is, to bzr+ssh://
[12:51] <shnatsel> that is rather trivial, I'm more worried about the error handling in SFTP/bzr+ssh module
[12:52] <LarstiQ> shnatsel: what error handling are you thinking of?
[12:52] <shnatsel> as described in the bug, if bzr+ssh transport fails
[12:53] <LarstiQ> shnatsel: but you don't actually need that, do you?
[12:53] <shnatsel> no
[12:53] <shnatsel> I'm not sure how to pass the blacklist either and what exactly it should contain
[12:53] <LarstiQ> shnatsel: right
[12:53] <shnatsel> I could pass URL prefixes probably, as that's what the function operates on
[12:53] <LarstiQ> shnatsel: can you explain some more how your automatic setup would work?
[12:54] <LarstiQ> shnatsel: ah hmm
[12:55] <LarstiQ> shnatsel: I suppose if you are sticking to local, you could indeed go with checking an environment variable
[12:55] <shnatsel> in fact I'm not
[12:55] <shnatsel> this is not even REQUIRED for my latest project, I can get by with sed I think...
[12:56] <shnatsel> it's just... there are lots of cases when http is desired over ssh for accessing Launchpad, such as running a script under su or sudo (ssh can't access keys), or when you want a script to work on other users' machines and want it to run unattended even if their SSH keys is locked
[12:56] <LarstiQ> right
[12:56] <shnatsel> it's not necessary for me right now, but it's something that's been bugging me and striking back for years
[12:56] <LarstiQ> shnatsel: so there are two things that come to mind
[12:57] <LarstiQ> shnatsel: one is decorating the url
[12:57] <LarstiQ> shnatsel: like http+lp:branch
[12:57] <LarstiQ> shnatsel: and the other is the fallback to http when ssh doesn't work
[12:58] <shnatsel> the first is already possible but it's error-prone
[12:58] <shnatsel> sed 's|lp:|https://code.launchpad.net/|'
[12:58] <shnatsel> that does the trick #1
[12:58] <LarstiQ> shnatsel: right, but now with bzr support
[12:58] <shnatsel> and fallback doesn't work
[12:59] <LarstiQ> shnatsel: bzr _has_ support for decorating urls
[12:59] <shnatsel> because the script just sits there waiting for user to input password to SSH key
[12:59] <LarstiQ> but it needs to be extended to lp:
[12:59] <LarstiQ> shnatsel: right
[12:59] <LarstiQ> shnatsel: this could time out, but yeah
[12:59] <shnatsel> that's why I thought of environment variable
[12:59]  * LarstiQ nods
[13:02] <LarstiQ> shnatsel: so the environment variable thing would be something like "try: no_ssh = os.environ('NO_LP_SSH') except (KeyError, ValueError): no_ssh = None"
[13:02] <LarstiQ> shnatsel: and then `url in blacklist` would be `or no_ssh is not None`
[13:02] <shnatsel> LarstiQ: makes sense
[13:06] <shnatsel> yeah that looks good to me
[13:07] <shnatsel> LarstiQ: shall I create a branch with that and post an RFC/merge request?
[13:07] <shnatsel> I think it will still need tests and documentation
[13:08] <LarstiQ> shnatsel: yeah, it might serve as a point for further discussion
[13:09] <LarstiQ> shnatsel: so a merge request is ok I think
[13:12]  * LarstiQ now really detaches to do some math
[13:58] <shnatsel> I can't get to the fallback path for some reason
[13:58] <shnatsel> I get an error:
[13:58] <shnatsel> bzr: ERROR: Invalid url supplied to transport: "bzr+ssh://bazaar.launchpad.net/+branch/elementaryos": no supported schemes
[14:00] <shnatsel> and it never considers the http URL
[14:10] <shnatsel> Turns out the HTTP URL is not even passed to that function.
[14:14] <shnatsel> Okay, I give up. Pushed what I have so far to lp:~shnatsel/bzr/launchpad-no-ssh-switch
[14:24] <shnatsel> oh wait, looks like I gave up too early
[14:38] <shnatsel> well, tried a bunch of other things, still nothing. Now I really give up.
[14:57] <vila> shnatsel: another solution would be to use a different user for your unattended operations. But you may run into access rights issue if these operations need write access. But using the same user, you can override BZR_HOME (which controls how bazaar.conf is reached) to point to a directory with whatever is needed for your unattended operations.
[15:02] <jelmer> JPeterson: sorry, I'm at a conference and I only have limited access to irc
[15:03] <jelmer> JPeterson: try /dev/stdin rather than just -