Fix upload-dir respond missing info
This commit is to fix 'software upload-dir' not having respond that contains uploaded release info. Test Plan: PASS: upload files using 'software upload-dir' Task: 49634 Story: 2010676 Change-Id: I635554fdbdb80fe31a38d1170202405fe6f32d3a Signed-off-by: junfeng-li <junfeng.li@windriver.com>
This commit is contained in:
parent
b0afdd45f1
commit
1d78ce4cec
|
@ -67,7 +67,7 @@ class ReleaseManager(base.Manager):
|
||||||
valid_files = [os.path.abspath(software_file) for software_file in releases if os.path.isfile(
|
valid_files = [os.path.abspath(software_file) for software_file in releases if os.path.isfile(
|
||||||
software_file) and os.path.splitext(software_file)[1] in constants.SUPPORTED_UPLOAD_FILE_EXT]
|
software_file) and os.path.splitext(software_file)[1] in constants.SUPPORTED_UPLOAD_FILE_EXT]
|
||||||
invalid_files = [os.path.abspath(software_file) for software_file in releases
|
invalid_files = [os.path.abspath(software_file) for software_file in releases
|
||||||
if os.path.abspath(software_file) not in valid_files]
|
if os.path.abspath(software_file) not in valid_files]
|
||||||
|
|
||||||
for software_file in invalid_files:
|
for software_file in invalid_files:
|
||||||
if os.path.isdir(software_file):
|
if os.path.isdir(software_file):
|
||||||
|
@ -110,7 +110,7 @@ class ReleaseManager(base.Manager):
|
||||||
for release_dir in release_dirs:
|
for release_dir in release_dirs:
|
||||||
if os.path.isdir(release_dir):
|
if os.path.isdir(release_dir):
|
||||||
raw_files = [f for f in os.listdir(release_dir)
|
raw_files = [f for f in os.listdir(release_dir)
|
||||||
if os.path.isfile(os.path.join(release_dir, f))]
|
if os.path.isfile(os.path.join(release_dir, f))]
|
||||||
|
|
||||||
# Get absolute path of files
|
# Get absolute path of files
|
||||||
raw_files = [os.path.abspath(os.path.join(release_dir, f)) for f in raw_files]
|
raw_files = [os.path.abspath(os.path.join(release_dir, f)) for f in raw_files]
|
||||||
|
@ -127,13 +127,13 @@ class ReleaseManager(base.Manager):
|
||||||
temp_iso_files = [f for f in all_raw_files if f.endswith(constants.ISO_EXTENSION)]
|
temp_iso_files = [f for f in all_raw_files if f.endswith(constants.ISO_EXTENSION)]
|
||||||
if len(temp_iso_files) > 1: # Verify that only one ISO file is being uploaded
|
if len(temp_iso_files) > 1: # Verify that only one ISO file is being uploaded
|
||||||
print("Only one ISO file can be uploaded at a time. Found: %s" %
|
print("Only one ISO file can be uploaded at a time. Found: %s" %
|
||||||
temp_iso_files, file=sys.stderr)
|
temp_iso_files, file=sys.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
temp_sig_files = [f for f in all_raw_files if f.endswith(constants.SIG_EXTENSION)]
|
temp_sig_files = [f for f in all_raw_files if f.endswith(constants.SIG_EXTENSION)]
|
||||||
if len(temp_sig_files) > 1: # Verify that only one SIG file is being uploaded
|
if len(temp_sig_files) > 1: # Verify that only one SIG file is being uploaded
|
||||||
print("Only one SIG file can be uploaded at a time. Found: %s" %
|
print("Only one SIG file can be uploaded at a time. Found: %s" %
|
||||||
temp_sig_files, file=sys.stderr)
|
temp_sig_files, file=sys.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
|
||||||
|
@ -141,6 +141,8 @@ class ReleaseManager(base.Manager):
|
||||||
_, ext = os.path.splitext(software_file)
|
_, ext = os.path.splitext(software_file)
|
||||||
if ext in constants.SUPPORTED_UPLOAD_FILE_EXT:
|
if ext in constants.SUPPORTED_UPLOAD_FILE_EXT:
|
||||||
to_upload_files[software_file] = (software_file, open(software_file, 'rb'))
|
to_upload_files[software_file] = (software_file, open(software_file, 'rb'))
|
||||||
|
else:
|
||||||
|
print("Skipping unsupported file: %s" % software_file, file=sys.stderr)
|
||||||
|
|
||||||
encoder = MultipartEncoder(fields=to_upload_files)
|
encoder = MultipartEncoder(fields=to_upload_files)
|
||||||
headers = {'Content-Type': encoder.content_type}
|
headers = {'Content-Type': encoder.content_type}
|
||||||
|
@ -151,14 +153,14 @@ class ReleaseManager(base.Manager):
|
||||||
else:
|
else:
|
||||||
utils.print_software_op_result(req, data)
|
utils.print_software_op_result(req, data)
|
||||||
data = json.loads(req.text)
|
data = json.loads(req.text)
|
||||||
data_list = [(k, v["id"])
|
data_list = [(lambda key, value: (key, value["id"]))(k, v)
|
||||||
for d in data["upload_info"] for k, v in d.items()
|
for d in data["upload_info"]
|
||||||
|
for k, v in d.items()
|
||||||
if not k.endswith(".sig")]
|
if not k.endswith(".sig")]
|
||||||
|
|
||||||
header_data_list = ["Uploaded File", "Id"]
|
header_data_list = ["Uploaded File", "Id"]
|
||||||
has_error = 'error' in data and data["error"]
|
has_error = 'error' in data and data["error"]
|
||||||
utils.print_result_list(header_data_list, data_list, has_error)
|
utils.print_result_list(header_data_list, data_list, has_error)
|
||||||
|
|
||||||
return utils.check_rc(req, data)
|
return utils.check_rc(req, data)
|
||||||
|
|
||||||
def commit_patch(self, args):
|
def commit_patch(self, args):
|
||||||
|
@ -241,7 +243,7 @@ class ReleaseManager(base.Manager):
|
||||||
|
|
||||||
print()
|
print()
|
||||||
commit_warning = "WARNING: Committing a patch is an irreversible operation. " + \
|
commit_warning = "WARNING: Committing a patch is an irreversible operation. " + \
|
||||||
"Committed patches cannot be removed."
|
"Committed patches cannot be removed."
|
||||||
print(textwrap.fill(commit_warning, width=utils.TERM_WIDTH, subsequent_indent=' ' * 9))
|
print(textwrap.fill(commit_warning, width=utils.TERM_WIDTH, subsequent_indent=' ' * 9))
|
||||||
print()
|
print()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue