-
Notifications
You must be signed in to change notification settings - Fork 384
Description
This represents porting Fabric 1.x's limited ability to autorespond to sudo prompts, to Invoke, and making it Better™.
For now, I've gone with a basic "when you see X, always respond with Y" functionality that can be easily configured via a {pattern: response} dict.
This isn't the most powerful implementation; e.g. one might want "only respond to patterns once", "respond to X pattern the first 3 times only", "respond to pattern X but only if you've already responded to pattern Y", etc etc.
However it's arguably more flexible than using e.g. pexpect (which requires you to anticipate exactly what prompts will happen, in what order; Invoke/Fabric use cases tend to have prompts appear arbitrarily) and I expect it will be enhanced in the future, perhaps by ripping out the responder aspects into their own class or something.
The functionality is already pretty much complete after a ~week of hacking, fucking up, getting confused, becoming less confused, and more hacking. I'm making this ticket just so I have something to link in the changelog & a checklist for the random minor tasks left to perform.
Left to do:
- Deal with recently-discovered funkiness in interactive stdin use case
- Make sure the basic functionality works for Fabric 2 as well as with local/subprocess
- Reinstate the Windows support for
handle_input, which mirrors real stdin to the subprocess' stdin. - Doublecheck whether we actually need Windows
getchas per Handle stdin on Windows using msvcrt functions #304 (comment) - Figure out whether to retain the
sleepcall inhandle_input; git-blame the Fab 1 line and doublecheck the rationale. Probably do want it back tho, probably chews more CPU than it really needs to as-is. - Reinstate the "print read stdin data to stdout when pty=False" behavior from fab 1 - it is necessary
- Ditto the "halt stdin mirroring while the local codebase is explicitly trying to prompt for shit it needs" functionality from Fab 1.
- ...does this mean Fab 1 literally can't deal with users manually executing things like
raw_inputandgetpass? Cuz if it can then that implies said halting/locking might not have been necessary? Or is a corner case? - See notes in desc of Convenient sudo() wrapper #294 - probably not going to go down the same road as in Fab 1 which means we wouldn't have to worry about this wrinkle.
- ...does this mean Fab 1 literally can't deal with users manually executing things like
- Centralize & normalize the encoding related noise, as per comments by @pfmoore in comments below.
- Quite possibly via work/discussion being done over on Fixed a number of encoding issues (in
runcontext) #274 and its linked tickets
- Quite possibly via work/discussion being done over on Fixed a number of encoding issues (in
- Try to replicate Pressing enter while running can expose sudo password fabric/fabric#1339 (both in Fabric 1, and here, and in Fabric 2)
- Figure out if it's worth implementing a(n easily disabled and well documented!) convenience "add
\nto response values if not present" feature.- Ye olde "helpfulness can be evil"...
- but in MY OWN TESTING I've fucked up and assumed an implicit
\nmultiple times already, so there's no way tons of users wouldn't make the same assumption. - Spun off as "Conveniently" append newline when autoresponding? #368
- Determine what's up with swallowed exceptions in the out/err/in threads when the main thread gets an eg KeyboardException. Feels like a thing we need to at least partially port from fab v1.
- Python 3 test pass so Travis doesn't get mad at me
- Ascertain why the test suite got slower again and how much of it's due to this branch
- Double-check the doc situation; may want to make a "feature list!" section on index page?
- Changelog entry