Merge commit '78263b7f13bf5d0fac824a4c025c46c88138a59c' into puvvadar/gitflow_211118_o3de
This commit is contained in:
@@ -490,7 +490,7 @@ def register_repo(json_data: dict,
|
||||
repo_sha256 = hashlib.sha256(url.encode())
|
||||
cache_file = manifest.get_o3de_cache_folder() / str(repo_sha256.hexdigest() + '.json')
|
||||
|
||||
result = utils.download_file(parsed_uri, cache_file)
|
||||
result = utils.download_file(parsed_uri, cache_file, True)
|
||||
if result == 0:
|
||||
json_data.setdefault('repos', []).insert(0, repo_uri)
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ def process_add_o3de_repo(file_name: str or pathlib.Path,
|
||||
repo_set: set) -> int:
|
||||
file_name = pathlib.Path(file_name).resolve()
|
||||
if not validation.valid_o3de_repo_json(file_name):
|
||||
logger.error(f'Repository JSON {file_name} could not be loaded or is missing required values')
|
||||
return 1
|
||||
cache_folder = manifest.get_o3de_cache_folder()
|
||||
|
||||
@@ -113,7 +114,7 @@ def get_gem_json_paths_from_cached_repo(repo_uri: str) -> set:
|
||||
|
||||
file_name = pathlib.Path(cache_filename).resolve()
|
||||
if not file_name.is_file():
|
||||
logger.error(f'Could not find cached repo json file for {repo_uri}')
|
||||
logger.error(f'Could not find cached repository json file for {repo_uri}. Try refreshing the repository.')
|
||||
return gem_set
|
||||
|
||||
with file_name.open('r') as f:
|
||||
@@ -166,6 +167,7 @@ def refresh_repo(repo_uri: str,
|
||||
|
||||
download_file_result = utils.download_file(parsed_uri, cache_file, True)
|
||||
if download_file_result != 0:
|
||||
logger.error(f'Repo json {repo_uri} could not download.')
|
||||
return download_file_result
|
||||
|
||||
if not validation.valid_o3de_repo_json(cache_file):
|
||||
|
||||
+22
-16
@@ -125,7 +125,8 @@ def download_file(parsed_uri, download_path: pathlib.Path, force_overwrite: bool
|
||||
"""
|
||||
if download_path.is_file():
|
||||
if not force_overwrite:
|
||||
logger.warn(f'File already downloaded to {download_path}.')
|
||||
logger.error(f'File already downloaded to {download_path} and force_overwrite is not set.')
|
||||
return 1
|
||||
else:
|
||||
try:
|
||||
os.unlink(download_path)
|
||||
@@ -134,20 +135,25 @@ def download_file(parsed_uri, download_path: pathlib.Path, force_overwrite: bool
|
||||
return 1
|
||||
|
||||
if parsed_uri.scheme in ['http', 'https', 'ftp', 'ftps']:
|
||||
with urllib.request.urlopen(parsed_uri.geturl()) as s:
|
||||
download_file_size = 0
|
||||
try:
|
||||
download_file_size = s.headers['content-length']
|
||||
except KeyError:
|
||||
pass
|
||||
def download_progress(downloaded_bytes):
|
||||
if download_progress_callback:
|
||||
return download_progress_callback(int(downloaded_bytes), int(download_file_size))
|
||||
return False
|
||||
with download_path.open('wb') as f:
|
||||
download_cancelled = copyfileobj(s, f, download_progress)
|
||||
if download_cancelled:
|
||||
return 1
|
||||
try:
|
||||
with urllib.request.urlopen(parsed_uri.geturl()) as s:
|
||||
download_file_size = 0
|
||||
try:
|
||||
download_file_size = s.headers['content-length']
|
||||
except KeyError:
|
||||
pass
|
||||
def download_progress(downloaded_bytes):
|
||||
if download_progress_callback:
|
||||
return download_progress_callback(int(downloaded_bytes), int(download_file_size))
|
||||
return False
|
||||
with download_path.open('wb') as f:
|
||||
download_cancelled = copyfileobj(s, f, download_progress)
|
||||
if download_cancelled:
|
||||
logger.warn(f'Download of file to {download_path} cancelled.')
|
||||
return 1
|
||||
except urllib.error.HTTPError as e:
|
||||
logger.error(f'HTTP Error {e.code} opening {parsed_uri.geturl()}')
|
||||
return 1
|
||||
else:
|
||||
origin_file = pathlib.Path(parsed_uri.geturl()).resolve()
|
||||
if not origin_file.is_file():
|
||||
@@ -167,7 +173,7 @@ def download_zip_file(parsed_uri, download_zip_path: pathlib.Path, force_overwri
|
||||
return download_file_result
|
||||
|
||||
if not zipfile.is_zipfile(download_zip_path):
|
||||
logger.error(f"File zip {download_zip_path} is invalid.")
|
||||
logger.error(f"File zip {download_zip_path} is invalid. Try re-downloading the file.")
|
||||
download_zip_path.unlink()
|
||||
return 1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user