|
2 | 2 | import os
|
3 | 3 | import sys
|
4 | 4 | from util.channel_access import ChannelAccessUtils
|
5 |
| -import paramiko |
| 5 | +from util.ssh_access import runSSHCommand |
6 | 6 | import requests
|
7 | 7 |
|
8 | 8 | EPICS_DIR = "C:\\Instrument\\Apps\\EPICS\\"
|
@@ -54,36 +54,6 @@ def get_insts_on_latest_ibex_via_inst_congif():
|
54 | 54 | return insts_on_latest_ibex
|
55 | 55 |
|
56 | 56 |
|
57 |
| -def runSSHCommand(host, username, password, command): |
58 |
| - """ Run a command on a remote host using SSH. |
59 |
| -
|
60 |
| - Args: |
61 |
| - host (str): The hostname to connect to. |
62 |
| - username (str): The username to use to connect. |
63 |
| - password (str): The password to use to connect. |
64 |
| - command (str): The command to run on the remote host. |
65 |
| -
|
66 |
| - Returns: |
67 |
| - dict: A dictionary with the success status and the output of the command. |
68 |
| - """ |
69 |
| - try: |
70 |
| - client = paramiko.SSHClient() |
71 |
| - client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) |
72 |
| - client.connect(host, port=SSH_PORT, |
73 |
| - username=username, password=password) |
74 |
| - stdin, stdout, stderr = client.exec_command(command) |
75 |
| - output = stdout.read().decode('utf-8') |
76 |
| - error = stderr.read().decode('utf-8') |
77 |
| - client.close() |
78 |
| - if error: |
79 |
| - return {'success': False, 'output': error} |
80 |
| - else: |
81 |
| - return {'success': True, 'output': output} |
82 |
| - except Exception as e: |
83 |
| - print(str(e)) |
84 |
| - return {'success': False, 'output': str(e)} |
85 |
| - |
86 |
| - |
87 | 57 | def check_for_uncommitted_changes(hostname):
|
88 | 58 | """ Check if there are any uncommitted changes on the instrument via SSH.
|
89 | 59 |
|
|
0 commit comments