|
|
@ -7,11 +7,16 @@ from util import macos
|
|
|
|
from invoke import exceptions
|
|
|
|
from invoke import exceptions
|
|
|
|
import sys
|
|
|
|
import sys
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
c = None
|
|
|
|
|
|
|
|
|
|
|
|
def sftp_send_data(config, filename, filetype):
|
|
|
|
def sftp_send_data(config, filename, filetype):
|
|
|
|
setup_child()
|
|
|
|
setup_child()
|
|
|
|
if not macos:
|
|
|
|
if not macos:
|
|
|
|
fprint("Connecting over SSH to " + config['sftp']['host'])
|
|
|
|
fprint("Connecting over SSH to " + config['sftp']['host'])
|
|
|
|
c = Connection(host=config['sftp']['host'], user=config['sftp']['user'], port=config['sftp']['port'], connect_kwargs={"key_filename": find_data_file(config['sftp']['keyfile']),})
|
|
|
|
global c
|
|
|
|
|
|
|
|
if c is None:
|
|
|
|
|
|
|
|
c = Connection(host=config['sftp']['host'], user=config['sftp']['user'], port=config['sftp']['port'], connect_kwargs={"key_filename": find_data_file(config['sftp']['keyfile']),})
|
|
|
|
|
|
|
|
|
|
|
|
fprint("Sending data over SFTP: " + filename)
|
|
|
|
fprint("Sending data over SFTP: " + filename)
|
|
|
|
fprint(c.put(find_data_file(filename), remote=config['sftp']['filepath'][filetype]))
|
|
|
|
fprint(c.put(find_data_file(filename), remote=config['sftp']['filepath'][filetype]))
|
|
|
|
fprint("Data sent over SFTP successfully")
|
|
|
|
fprint("Data sent over SFTP successfully")
|
|
|
@ -21,7 +26,9 @@ def sftp_send_data(config, filename, filetype):
|
|
|
|
def check_for_file(config, filename, location):
|
|
|
|
def check_for_file(config, filename, location):
|
|
|
|
setup_child()
|
|
|
|
setup_child()
|
|
|
|
fprint("Connecting over SSH to " + config['sftp']['host'])
|
|
|
|
fprint("Connecting over SSH to " + config['sftp']['host'])
|
|
|
|
c = Connection(host=config['sftp']['host'], user=config['sftp']['user'], port=config['sftp']['port'], connect_kwargs={"key_filename": find_data_file(config['sftp']['keyfile']),})
|
|
|
|
global c
|
|
|
|
|
|
|
|
if c is None:
|
|
|
|
|
|
|
|
c = Connection(host=config['sftp']['host'], user=config['sftp']['user'], port=config['sftp']['port'], connect_kwargs={"key_filename": find_data_file(config['sftp']['keyfile']),})
|
|
|
|
fprint("Checking for existence of file " + config['sftp']['filepath'][location] + "/" + filename)
|
|
|
|
fprint("Checking for existence of file " + config['sftp']['filepath'][location] + "/" + filename)
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
res = c.run("ls -l " + config['sftp']['filepath'][location] + "/" + filename, hide=True)
|
|
|
|
res = c.run("ls -l " + config['sftp']['filepath'][location] + "/" + filename, hide=True)
|
|
|
@ -33,7 +40,9 @@ def check_for_file(config, filename, location):
|
|
|
|
def run_ssh(config, command, location):
|
|
|
|
def run_ssh(config, command, location):
|
|
|
|
setup_child()
|
|
|
|
setup_child()
|
|
|
|
fprint("Connecting over SSH to " + config['sftp']['host'])
|
|
|
|
fprint("Connecting over SSH to " + config['sftp']['host'])
|
|
|
|
c = Connection(host=config['sftp']['host'], user=config['sftp']['user'], port=config['sftp']['port'], connect_kwargs={"key_filename": find_data_file(config['sftp']['keyfile']),})
|
|
|
|
global c
|
|
|
|
|
|
|
|
if c is None:
|
|
|
|
|
|
|
|
c = Connection(host=config['sftp']['host'], user=config['sftp']['user'], port=config['sftp']['port'], connect_kwargs={"key_filename": find_data_file(config['sftp']['keyfile']),})
|
|
|
|
fprint("cd to " + config['sftp']['filepath'][location])
|
|
|
|
fprint("cd to " + config['sftp']['filepath'][location])
|
|
|
|
with c.cd(config['sftp']['filepath'][location]):
|
|
|
|
with c.cd(config['sftp']['filepath'][location]):
|
|
|
|
fprint("Running ssh command: " + command)
|
|
|
|
fprint("Running ssh command: " + command)
|
|
|
|