15 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 54aecff8e4 | |||
| f253466a3f | |||
| 4a8ccfb0a6 | |||
| 3574c0f1bf | |||
| 6cdcd23010 | |||
| 910f10b194 | |||
| f78d08f0d8 | |||
| 888c0495ec | |||
| 04b294917f | |||
| d680d6c5ed | |||
| bafc7fed2a | |||
| 84375cd482 | |||
| 0e18d4abac | |||
| 3a84408436 | |||
| f4c76ebab9 |
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
| 54aecff8e4 |
lib.ExecContext.run(), .sudo(): Rename env
The name of the env parameter to ExecContext.run() and .sudo() is not descriptive enough for which environment is supposed to be modified and how, so rename and split it up as follows: - .run(): env -> mod_env - .sudo(): env -> mod_env_sudo and mod_env_cmd The parameters have the following meaning: - "mod_env*" means that the environment is modified, not replaced - "mod_env" and "mod_env_cmd" modify the environment "cmd" runs in - "mod_env_sudo" modifies the environment sudo runs in Fix the fallout of the API change all over jw-pkg. Signed-off-by: Jan Lindemann <jan@janware.com> |
|||
| f253466a3f |
lib.ec.ssh.Exec._run_ssh(): Fix: interactive ignored
Exec's _run_ssh() ignores its "interactive" parameter and uses the instances' default instead, fix that. Signed-off-by: Jan Lindemann <jan@janware.com> |
|||
| 4a8ccfb0a6 |
lib.ec.ssh.Exec: Honour username and port
Username and port of an Exec SSH client are not passed to the ssh executable, fix that. Signed-off-by: Jan Lindemann <jan@janware.com> |
|||
| 3574c0f1bf |
lib.ec.ssh.Exec: Support Caps.Env
Add support for modifying the execution environment via the env parameter to Exec. Signed-off-by: Jan Lindemann <jan@janware.com> |
|||
| 6cdcd23010 |
lib.ec.ssh.Exec._run_ssh(): Fix interactivity translation
cmd_input is passed as None to _run(), which is legal, but then used in a call to cmd_run(), which is a public API and, hence, illegal. InputMode.NonInteractive should be used instead, do that. Signed-off-by: Jan Lindemann <jan@janware.com> |
|||
| 910f10b194 |
lib.util.run_cmd(): Remove parameter interactive
run_cmd() is a thin layer over the public ExecContext API, which falls back to using a Local instance if not other ExecContext is specified explicitly. Both the default Local context as the subsequent call to run() should have the same idea about interactivity, so allowing to specify it in two parameters ("interactive" and "cmd_input") is a bad idea. Remove "interactive". Signed-off-by: Jan Lindemann <jan@janware.com> |
|||
| f78d08f0d8 |
lib.ec.ssh.Exec: Fix cmd_input == None
cmd_input is passed as None to _run(), which is legal, but then used in a call to cmd_run(), which is a public API and, hence, illegal. Fix that. Signed-off-by: Jan Lindemann <jan@janware.com> |
|||
| 888c0495ec |
lib.base: Add module
Add lib.base to provide basic definitions. For now, move the definiions of Result, Input and InputMode from ExecContext into lib.base. Having to import them from the ExecContect module is too heavy-handed for those simple types. Signed-off-by: Jan Lindemann <jan@janware.com> |
|||
| 04b294917f |
lib.ExecContext: Support bytes-typed cmd_input
The Input instance passed as cmd_input to ExecContext.run() and .sudo() currently may be of type str. Allow to pass bytes, too. At the same time, disallow None to be passed as cmd_input. Force the caller to be more explicit how it wants input to be handled, notably with respect to interactivity. Along the way fix a bug: Content in cmd_input should result in CallContext.interactive == False but doesn't. Fix that. Signed-off-by: Jan Lindemann <jan@janware.com> |
|||
| d680d6c5ed |
lib.ec.ssh.Exec._run_ssh(): run_cmd(throw=False)
_run_ssh() of ssh.Exec doesn't pass throw=False to run_cmd(), which makes it throw exceptions, and effectively strips the caller of any chance to get hold of stdout and stderr. Pass throw=False and let run() decide according the the caller-provided throw parameter whether or not a problem should propagate up as exception or return value. Signed-off-by: Jan Lindemann <jan@janware.com> |
|||
| bafc7fed2a |
lib.ec.ssh.Exec: Honour self.interactive
The Exec SSHClient ignores the "interactive" argument passed to its constructor, fix that. Signed-off-by: Jan Lindemann <jan@janware.com> |
|||
| 84375cd482 |
lib.ec.ssh: Don't quote shell operators
Naively join()ing a command list to be executed remotely via SSH also quotes shell operators which doesn't work, of course. Work around that. The workaround will not always work but covers lots of cases. Signed-off-by: Jan Lindemann <jan@janware.com> |
|||
| 0e18d4abac |
lib.ec.ssh.Exec|Paramiko: Don't # export
The SSHClient classes Paramiko and Exec are exported via # export. This is a bad idea, because if Paramiko is not installed, none of the other's can be instantiated either: On the attempt to load them, __init__.py is loaded first and fails. SSHClient.ssh_client() knows what to do, no need to auto-import them into the lib.ec.ssh module. Signed-off-by: Jan Lindemann <jan@janware.com> |
|||
| 3a84408436 |
lib.ec.SSHClient.__init__(): Add parameter caps
Add an optional caps ("capabilities") argument to the constructor of SSHClient. It is meant to be used by derived classes in order to declare that they don't want the base class to handle a default behaviour for a certain capability, but that they want to implement it themselves instead. Also, give the _run_ssh() callbacks the necessary info as parameters, so that the derived classes have the means to do so. Signed-off-by: Jan Lindemann <jan@janware.com> |
|||
| f4c76ebab9 |
lib.ec.SSHClientInternal|SSHClientCmd: Own .py
Move the code of SSHClientInternal and SSCClientCmd into lib.ec.ssh, as "Paramiko" and "Exec", respectively. This makes the class layout a little more modular, and along the way fixes a bug where SSHClientInternal could be instantiated but was unusable (if the Paramiko is not installed). Signed-off-by: Jan Lindemann <jan@janware.com> |