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