mirror of
https://gitee.com/jack_whh/ssh-scp-ssh-pipelines.git
synced 2026-03-09 22:42:55 +08:00
feat: exit(1), don't raise
This commit is contained in:
committed by
GitHub
parent
de52e872d4
commit
a6548c1a21
16
app.py
16
app.py
@@ -60,9 +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:
|
except Exception as err:
|
||||||
print("Connect error")
|
print(f"Connect error\n{err}")
|
||||||
raise
|
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
@@ -106,7 +105,6 @@ def ssh_process(ssh, input_ssh):
|
|||||||
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}")
|
print(f"Error: \n{err}")
|
||||||
raise Exception(err)
|
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
pass
|
pass
|
||||||
@@ -136,18 +134,16 @@ def scp_process(ssh, input_scp):
|
|||||||
remote = l2r.get('r')
|
remote = l2r.get('r')
|
||||||
try:
|
try:
|
||||||
ssh.exec_command(f"mkdir -p {remote}")
|
ssh.exec_command(f"mkdir -p {remote}")
|
||||||
except:
|
except Exception as err:
|
||||||
print(f"Remote mkdir error. Can't create {remote}")
|
print(f"Remote mkdir error. Can't create {remote}\n{err}")
|
||||||
raise
|
|
||||||
sys.exit(1)
|
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:
|
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:
|
except Exception as err:
|
||||||
print(f"scp error. Can't copy {f} on {remote}")
|
print(f"Scp error. Can't copy {f} on {remote}\n{err}")
|
||||||
raise
|
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user