mirror of
https://github.com/cross-the-world/scp-pipeline.git
synced 2025-09-11 03:48:58 +08:00
strip quotes
This commit is contained in:
2
.github/workflows/deploy.yml
vendored
2
.github/workflows/deploy.yml
vendored
@@ -24,7 +24,7 @@ jobs:
|
||||
local: './test/*'
|
||||
remote: /home/github/test/
|
||||
scp: |
|
||||
./test/test*.csv => "/home/github/test/test2/"
|
||||
'./test/test*.csv' => "/home/github/test/test2/"
|
||||
|
||||
- name: local remote scp
|
||||
uses: cross-the-world/scp-pipeline@master
|
||||
|
17
app.py
17
app.py
@@ -34,6 +34,17 @@ def convert_to_seconds(s):
|
||||
return 30
|
||||
|
||||
|
||||
strips = ["", "\"", "", "'", ""]
|
||||
|
||||
|
||||
def strip_path(p):
|
||||
if not p:
|
||||
return None
|
||||
for c in strips:
|
||||
p = p.strip(c)
|
||||
return p
|
||||
|
||||
|
||||
def connect():
|
||||
ssh = paramiko.SSHClient()
|
||||
p_key = paramiko.RSAKey.from_private_key(INPUT_KEY) if INPUT_KEY else None
|
||||
@@ -64,8 +75,8 @@ def scp_process():
|
||||
continue
|
||||
l2r = c.split("=>")
|
||||
if len(l2r) == 2:
|
||||
local = l2r[0].strip()
|
||||
remote = l2r[1].strip()
|
||||
local = strip_path(l2r[0])
|
||||
remote = strip_path(l2r[1])
|
||||
if local and remote:
|
||||
copy_list.append({"l": local, "r": remote})
|
||||
continue
|
||||
@@ -76,7 +87,7 @@ def scp_process():
|
||||
print("SCP no copy list found")
|
||||
return
|
||||
|
||||
ssh = connect()
|
||||
with connect() as ssh:
|
||||
with scp.SCPClient(ssh.get_transport(), progress=progress, sanitize=lambda x: x) as conn:
|
||||
for l2r in copy_list:
|
||||
remote = l2r.get('r')
|
||||
|
Reference in New Issue
Block a user