Skip to content

Commit

Permalink
Merge branch 'master' into latest
Browse files Browse the repository at this point in the history
  • Loading branch information
Nguyen Huu Thuong committed Mar 4, 2021
2 parents aa298e0 + 35fb71b commit 6582a0b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
31 changes: 22 additions & 9 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -91,7 +97,7 @@ def ssh_process(ssh, input_ssh):
print(command_str)

stdin, stdout, stderr = ssh.exec_command(command_str)

out = "".join(stdout.readlines())
out = out.strip() if out is not None else None
if out:
Expand All @@ -100,11 +106,9 @@ 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}")

print(f"Error: \n{err}")
sys.exit(1)

pass


Expand All @@ -130,10 +134,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'))]:
conn.put(f, remote_path=remote, recursive=True)
print(f"{f} -> {remote}")
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


Expand Down
3 changes: 3 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
echo "+++++++++++++++++++STARTING PIPELINES+++++++++++++++++++"

python3 /opt/tools/app.py
RET=$?

echo "+++++++++++++++++++END PIPELINES+++++++++++++++++++"

exit $RET

0 comments on commit 6582a0b

Please sign in to comment.