strip quotes

This commit is contained in:
Nguyen Huu Thuong
2020-06-13 09:10:12 +02:00
parent 013057800c
commit 6bf8174723
2 changed files with 22 additions and 11 deletions

View File

@@ -24,7 +24,7 @@ jobs:
local: './test/*' local: './test/*'
remote: /home/github/test/ remote: /home/github/test/
scp: | scp: |
./test/test*.csv => "/home/github/test/test2/" './test/test*.csv' => "/home/github/test/test2/"
- name: local remote scp - name: local remote scp
uses: cross-the-world/scp-pipeline@master uses: cross-the-world/scp-pipeline@master

17
app.py
View File

@@ -34,6 +34,17 @@ def convert_to_seconds(s):
return 30 return 30
strips = ["", "\"", "", "'", ""]
def strip_path(p):
if not p:
return None
for c in strips:
p = p.strip(c)
return p
def connect(): def connect():
ssh = paramiko.SSHClient() ssh = paramiko.SSHClient()
p_key = paramiko.RSAKey.from_private_key(INPUT_KEY) if INPUT_KEY else None p_key = paramiko.RSAKey.from_private_key(INPUT_KEY) if INPUT_KEY else None
@@ -64,8 +75,8 @@ def scp_process():
continue continue
l2r = c.split("=>") l2r = c.split("=>")
if len(l2r) == 2: if len(l2r) == 2:
local = l2r[0].strip() local = strip_path(l2r[0])
remote = l2r[1].strip() remote = strip_path(l2r[1])
if local and remote: if local and remote:
copy_list.append({"l": local, "r": remote}) copy_list.append({"l": local, "r": remote})
continue continue
@@ -76,7 +87,7 @@ def scp_process():
print("SCP no copy list found") print("SCP no copy list found")
return return
ssh = connect() with connect() as ssh:
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')