Conditions | 4 |
Total Lines | 18 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | #!/usr/bin/env python3 |
||
22 | def run_ssh_command(command, ssh_client=remote_client.ssh_client_origin): |
||
23 | """ |
||
24 | Running ssh command |
||
25 | :param command: String |
||
26 | :param ssh_client: |
||
27 | :return: |
||
28 | """ |
||
29 | stdin, stdout, stderr = ssh_client.exec_command(command) |
||
30 | exit_status = stdout.channel.recv_exit_status() |
||
31 | |||
32 | err = stderr.read().decode() |
||
33 | |||
34 | if err and 0 != exit_status: |
||
35 | sys.exit(output.message(output.Subject.ERROR, err, False)) |
||
36 | elif err: |
||
37 | output.message(output.Subject.WARNING, err, True) |
||
38 | |||
39 | return stdout |
||