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