Conditions | 4 |
Total Lines | 20 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | #!/usr/bin/env python3 |
||
26 | def run_ssh_command(command, ssh_client=remote_client.ssh_client_origin, client=None): |
||
27 | """ |
||
28 | Running ssh command |
||
29 | :param command: String |
||
30 | :param ssh_client: |
||
31 | :param client: String |
||
32 | :return: |
||
33 | """ |
||
34 | stdin, stdout, stderr = ssh_client.exec_command(command) |
||
35 | exit_status = stdout.channel.recv_exit_status() |
||
36 | |||
37 | err = stderr.read().decode() |
||
38 | |||
39 | if err and exit_status != 0: |
||
40 | helper.run_script(client=client, script='error') |
||
41 | sys.exit(output.message(output.Subject.ERROR, err, False)) |
||
42 | elif err: |
||
43 | output.message(output.Subject.WARNING, err, True) |
||
44 | |||
45 | return stdout |
||
46 |