Make the push files utils handle recursing dirs
Change-Id: I45daa1d5771e380f0c251f380fae7a0780e6cbaf
This commit is contained in:
@@ -207,17 +207,28 @@ def push_file(job_log_dir, file_path, publish_config):
|
|||||||
|
|
||||||
def swift_push_file(job_log_dir, file_path, swift_config):
|
def swift_push_file(job_log_dir, file_path, swift_config):
|
||||||
""" Push a log file to a swift server. """
|
""" Push a log file to a swift server. """
|
||||||
with open(file_path, 'r') as fd:
|
def _push_individual_file(job_log_dir, file_path, swift_config):
|
||||||
name = os.path.join(job_log_dir, os.path.basename(file_path))
|
with open(file_path, 'r') as fd:
|
||||||
con = swiftclient.client.Connection(
|
name = os.path.join(job_log_dir, os.path.basename(file_path))
|
||||||
authurl=swift_config['authurl'],
|
con = swiftclient.client.Connection(
|
||||||
user=swift_config['user'],
|
authurl=swift_config['authurl'],
|
||||||
key=swift_config['password'],
|
user=swift_config['user'],
|
||||||
os_options={'region_name': swift_config['region']},
|
key=swift_config['password'],
|
||||||
tenant_name=swift_config['tenant'],
|
os_options={'region_name': swift_config['region']},
|
||||||
auth_version=2.0)
|
tenant_name=swift_config['tenant'],
|
||||||
con.put_object(swift_config['container'], name, fd)
|
auth_version=2.0)
|
||||||
return swift_config['prepend_url'] + name
|
con.put_object(swift_config['container'], name, fd)
|
||||||
|
|
||||||
|
if os.path.isfile(file_path):
|
||||||
|
_push_individual_file(job_log_dir, file_path, swift_config)
|
||||||
|
elif os.path.isdir(file_path):
|
||||||
|
for path, folders, files in os.walk(file_path):
|
||||||
|
for f in files:
|
||||||
|
f_path = os.path.join(path, f)
|
||||||
|
_push_individual_file(job_log_dir, f_path, swift_config)
|
||||||
|
|
||||||
|
return (swift_config['prepend_url'] +
|
||||||
|
os.path.join(job_log_dir, os.path.basename(file_path)))
|
||||||
|
|
||||||
|
|
||||||
def local_push_file(job_log_dir, file_path, local_config):
|
def local_push_file(job_log_dir, file_path, local_config):
|
||||||
@@ -229,13 +240,17 @@ def local_push_file(job_log_dir, file_path, local_config):
|
|||||||
|
|
||||||
dest_file = os.path.join(dest_dir, dest_filename)
|
dest_file = os.path.join(dest_dir, dest_filename)
|
||||||
|
|
||||||
shutil.copyfile(file_path, dest_file)
|
if os.path.isfile(file_path):
|
||||||
|
shutil.copyfile(file_path, dest_file)
|
||||||
|
elif os.path.isdir(file_path):
|
||||||
|
shutil.copytree(file_path, dest_file)
|
||||||
return local_config['prepend_url'] + os.path.join(job_log_dir,
|
return local_config['prepend_url'] + os.path.join(job_log_dir,
|
||||||
dest_filename)
|
dest_filename)
|
||||||
|
|
||||||
|
|
||||||
def scp_push_file(job_log_dir, file_path, local_config):
|
def scp_push_file(job_log_dir, file_path, local_config):
|
||||||
""" Copy the file remotely over ssh """
|
""" Copy the file remotely over ssh """
|
||||||
|
# TODO!
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user