Compare commits
10 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
c9b539abea | |
|
|
5aa3c5e8d1 | |
|
|
1e8a5783bc | |
|
|
fed5e4953c | |
|
|
35fb71b02d | |
|
|
d3b9734a32 | |
|
|
3d97e5b8eb | |
|
|
a6548c1a21 | |
|
|
de52e872d4 | |
|
|
d5d6f7b3cb |
26
app.py
26
app.py
|
|
@ -60,8 +60,14 @@ def connect(callback=None):
|
|||
ssh.connect(INPUT_HOST, port=INPUT_PORT, username=INPUT_USER,
|
||||
pkey=p_key, password=INPUT_PASS,
|
||||
timeout=convert_to_seconds(INPUT_CONNECT_TIMEOUT))
|
||||
except Exception as err:
|
||||
print(f"Connect error\n{err}")
|
||||
sys.exit(1)
|
||||
|
||||
else:
|
||||
if callback:
|
||||
callback(ssh)
|
||||
|
||||
finally:
|
||||
os.unlink(tmp.name)
|
||||
tmp.close()
|
||||
|
|
@ -90,6 +96,8 @@ def ssh_process(ssh, input_ssh):
|
|||
|
||||
stdin, stdout, stderr = ssh.exec_command(command_str)
|
||||
|
||||
ssh_exit_status = stdout.channel.recv_exit_status()
|
||||
|
||||
out = "".join(stdout.readlines())
|
||||
out = out.strip() if out is not None else None
|
||||
if out:
|
||||
|
|
@ -98,11 +106,12 @@ def ssh_process(ssh, input_ssh):
|
|||
err = "".join(stderr.readlines())
|
||||
err = err.strip() if err is not None else None
|
||||
if err:
|
||||
if out is None:
|
||||
raise Exception(err)
|
||||
else:
|
||||
print(f"Error: \n{err}")
|
||||
|
||||
if ssh_exit_status != 0:
|
||||
print(f"ssh exit status: {ssh_exit_status}")
|
||||
sys.exit(1)
|
||||
|
||||
pass
|
||||
|
||||
|
||||
|
|
@ -128,10 +137,19 @@ def scp_process(ssh, input_scp):
|
|||
with scp.SCPClient(ssh.get_transport(), progress=progress, sanitize=lambda x: x) as conn:
|
||||
for l2r in copy_list:
|
||||
remote = l2r.get('r')
|
||||
ssh.exec_command(f"mkdir -p {remote} || true")
|
||||
try:
|
||||
ssh.exec_command(f"mkdir -p {remote}")
|
||||
except Exception as err:
|
||||
print(f"Remote mkdir error. Can't create {remote}\n{err}")
|
||||
sys.exit(1)
|
||||
|
||||
for f in [f for f in glob(l2r.get('l'))]:
|
||||
try:
|
||||
conn.put(f, remote_path=remote, recursive=True)
|
||||
print(f"{f} -> {remote}")
|
||||
except Exception as err:
|
||||
print(f"Scp error. Can't copy {f} on {remote}\n{err}")
|
||||
sys.exit(1)
|
||||
pass
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,5 +3,8 @@
|
|||
echo "+++++++++++++++++++STARTING PIPELINES+++++++++++++++++++"
|
||||
|
||||
python3 /opt/tools/app.py
|
||||
RET=$?
|
||||
|
||||
echo "+++++++++++++++++++END PIPELINES+++++++++++++++++++"
|
||||
|
||||
exit $RET
|
||||
|
|
|
|||
Loading…
Reference in New Issue