/srv/irclogs.ubuntu.com/2013/02/02/#bzr.txt

=== slank is now known as slank_away
shnatselHello!11:43
shnatselDoes anybody know if I can force bzr to use HTTP transport for Launchpad branches given in "lp:..." format?11:43
shnatselI'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:45
LarstiQshnatsel: remove the launchpad login in the config11:48
LarstiQshnatsel: launchpad_username in ~/.bazaar/bazaar.conf11:49
LarstiQshnatsel: remove/comment out11:49
shnatselLarstiQ: the problem is I still want to keep the SSH transport for operations I perform manually11:49
shnatseland scripts with such side effects are not a great idea11:50
* LarstiQ nods11:50
shnatselmaybe there's some environment variable I can export or something like that?11:50
shnatselif all else fails I can replace all "lp:" with "https://code.launchpad.net/" but that's ugly and error-prone11:51
LarstiQshnatsel: I'm not aware of a good solution, but one is terribly welcome11:52
shnatselLarstiQ: okay, where can I get the code for launchpad plugin?11:53
LarstiQshnatsel: looking at the bzrlib/plugins/launchpad/lp_directory.py code, it shouldn't be too hard to make it more flexible11:53
LarstiQshnatsel: it's part of core bzr, so `bzr branch lp:bzr` will do11:53
shnatselI'm more of a shell scripter than a pythoneer, but I'll see what I can do11:54
LarstiQshnatsel: bug 238776 it looks like11:55
ubot5bug 238776 in Bazaar "Confusing error message if ssh login fails while using lp url" [High,Confirmed] https://launchpad.net/bugs/23877611:55
LarstiQshnatsel: feel free to ask for help on how to proceed with that11:55
LarstiQshnatsel: my bzr coding is very rusty, but I promise to help review whatever you come up with11:56
shnatselLarstiQ: thanks!11:56
* LarstiQ heads for lunch and mathematics11:57
shnatselas far as I can tell, _resolve(...) in bzrlib/plugins/launchpad/lp_directory.py is what turns lp: URI into bzr+ssh:// or https:// URI12:08
LarstiQshnatsel: yes12:08
LarstiQshnatsel: #  Only accept launchpad.net bzr+ssh URLs if we know the user's Launchpad login:12:10
shnatselno, that seems to be an unrelated function12:10
LarstiQshnatsel: that's in _resolve12:10
shnatseloh12:10
shnatselI confused it for another function definition, sorry. I see now, thanks!12:10
LarstiQshnatsel: you could try to see if http comes up as an option but gets rejected because of that logic12:11
LarstiQby say putting a trace.mutter at the start of the loop12:11
shnatseloh, by the way, how do I test the changes I make?12:11
LarstiQand then tailing ~/.bzr.log12:12
LarstiQshnatsel: in the end, by writing a test in test_lp_directory.py I think12:12
LarstiQshnatsel: but for starters, change that file, and then run ./bzr from your branch12:12
LarstiQshnatsel: bzr can run directly from the branch, no installation needed12:13
LarstiQquite handy for development12:13
LarstiQshnatsel: doc/developers/HACKING.txt may have some helpful bits for debugging and such12:14
shnatselNo, it doesn't consider using HTTP transport12:34
shnatselwell, at least when ssh is available12:34
shnatsellet me relogin, I can't kill off ssh-agent for some reason12:35
shnatselno, it doesn't even consider using HTTP URLs12:39
shnatselwhen bzr+ssh is not available12:39
shnatselI'm not sure how to implement proper fallback, it seems to require pretty big changes, as per James Westby's comment on bug 23877612:43
ubot5bug 238776 in Bazaar "Confusing error message if ssh login fails while using lp url" [High,Confirmed] https://launchpad.net/bugs/23877612:43
shnatselwhat I can add is checking for environment variable and forcing HTTP if it's set to "true"12:44
shnatselI'm not sure if that's an acceptable solution12:47
LarstiQshnatsel: I don't think we need to go quite as far as james_w suggested there12:47
LarstiQshnatsel: probably not for bzr proper, but you can take that approach locally of course12:48
* LarstiQ does some testing12:48
shnatselokay, 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:49
LarstiQshnatsel: it should be enough to change 'if _lp_login is not None:' to 'if _lp_login is not None or url in blacklist' or somesuch12:51
LarstiQshnatsel: because when the launchpad username is not set, lp:bzr resolves to http://  , and when it is, to bzr+ssh://12:51
shnatselthat is rather trivial, I'm more worried about the error handling in SFTP/bzr+ssh module12:51
LarstiQshnatsel: what error handling are you thinking of?12:52
shnatselas described in the bug, if bzr+ssh transport fails12:52
LarstiQshnatsel: but you don't actually need that, do you?12:53
shnatselno12:53
shnatselI'm not sure how to pass the blacklist either and what exactly it should contain12:53
LarstiQshnatsel: right12:53
shnatselI could pass URL prefixes probably, as that's what the function operates on12:53
LarstiQshnatsel: can you explain some more how your automatic setup would work?12:53
LarstiQshnatsel: ah hmm12:54
LarstiQshnatsel: I suppose if you are sticking to local, you could indeed go with checking an environment variable12:55
shnatselin fact I'm not12:55
shnatselthis is not even REQUIRED for my latest project, I can get by with sed I think...12:55
shnatselit'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 locked12:56
LarstiQright12:56
shnatselit's not necessary for me right now, but it's something that's been bugging me and striking back for years12:56
LarstiQshnatsel: so there are two things that come to mind12:56
LarstiQshnatsel: one is decorating the url12:57
LarstiQshnatsel: like http+lp:branch12:57
LarstiQshnatsel: and the other is the fallback to http when ssh doesn't work12:57
shnatselthe first is already possible but it's error-prone12:58
shnatselsed 's|lp:|https://code.launchpad.net/|'12:58
shnatselthat does the trick #112:58
LarstiQshnatsel: right, but now with bzr support12:58
shnatseland fallback doesn't work12:58
LarstiQshnatsel: bzr _has_ support for decorating urls12:59
shnatselbecause the script just sits there waiting for user to input password to SSH key12:59
LarstiQbut it needs to be extended to lp:12:59
LarstiQshnatsel: right12:59
LarstiQshnatsel: this could time out, but yeah12:59
shnatselthat's why I thought of environment variable12:59
* LarstiQ nods12:59
LarstiQshnatsel: 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
LarstiQshnatsel: and then `url in blacklist` would be `or no_ssh is not None`13:02
shnatselLarstiQ: makes sense13:02
shnatselyeah that looks good to me13:06
shnatselLarstiQ: shall I create a branch with that and post an RFC/merge request?13:07
shnatselI think it will still need tests and documentation13:07
LarstiQshnatsel: yeah, it might serve as a point for further discussion13:08
LarstiQshnatsel: so a merge request is ok I think13:09
* LarstiQ now really detaches to do some math13:12
shnatselI can't get to the fallback path for some reason13:58
shnatselI get an error:13:58
shnatselbzr: ERROR: Invalid url supplied to transport: "bzr+ssh://bazaar.launchpad.net/+branch/elementaryos": no supported schemes13:58
shnatseland it never considers the http URL14:00
shnatselTurns out the HTTP URL is not even passed to that function.14:10
shnatselOkay, I give up. Pushed what I have so far to lp:~shnatsel/bzr/launchpad-no-ssh-switch14:14
shnatseloh wait, looks like I gave up too early14:24
shnatselwell, tried a bunch of other things, still nothing. Now I really give up.14:38
vilashnatsel: 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.14:57
jelmerJPeterson: sorry, I'm at a conference and I only have limited access to irc15:02
jelmerJPeterson: try /dev/stdin rather than just -15:03

Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!