Fix including debian package file
This commit is contained in:
parent
629b4b5fcf
commit
adb45e01ea
1 changed files with 22 additions and 6 deletions
|
@ -142,13 +142,29 @@ def include_changes_file(repo_name, package_name, changes_file):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def include_deb_package(repo_name, path):
|
def include_deb_package(repo_name, package_name, path):
|
||||||
"""Include a changes file using Aptly API"""
|
"""Include a changes file using Aptly API"""
|
||||||
url = f"{args.api_url}/repos/{repo_name}/file/{os.path.basename(path)}"
|
url = f"{args.api_url}/repos/{repo_name}/file/{package_name}/{os.path.basename(path)}"
|
||||||
result = session.post(url)
|
result = session.post(url)
|
||||||
if result.status_code < 200 or result.status_code > 299:
|
data = result.json()
|
||||||
data = result.json()
|
logging.debug(
|
||||||
logging.error("Failed to include Debian package %s: %s", path, data.get("error"))
|
"include_deb_package(%s, %s, %s): API return (%d): %s",
|
||||||
|
repo_name, package_name, path, result.status_code, data
|
||||||
|
)
|
||||||
|
if data.get("FailedFiles"):
|
||||||
|
logging.error(
|
||||||
|
"Some error occurred including %s:\nFailed files:\n - %s\nWarnings: - %s",
|
||||||
|
path,
|
||||||
|
"\n - ".join(data["FailedFiles"]),
|
||||||
|
"\n - ".join(data.get("Report", {}).get("Warnings"))
|
||||||
|
if data.get("Report", {}).get("Warnings")
|
||||||
|
else "No warning",
|
||||||
|
)
|
||||||
|
return False
|
||||||
|
if not (result.status_code == 200 and data.get("Report", {}).get("Added")):
|
||||||
|
logging.error(
|
||||||
|
"Unknown error occurred including %s. See APTLY API logs for details.", path
|
||||||
|
)
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -231,7 +247,7 @@ def handle_deb_package(args, session, path):
|
||||||
logging.info(" Debian package %s uploaded.", path)
|
logging.info(" Debian package %s uploaded.", path)
|
||||||
|
|
||||||
logging.info(" Adding Debian package %s...", path)
|
logging.info(" Adding Debian package %s...", path)
|
||||||
if not include_deb_package(repo_name, path):
|
if not include_deb_package(repo_name, package_name, path):
|
||||||
logging.error("Failed to add file. See APTLY API logs for details.")
|
logging.error("Failed to add file. See APTLY API logs for details.")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
logging.info(" Debian package %s added.", path)
|
logging.info(" Debian package %s added.", path)
|
||||||
|
|
Loading…
Add table
Reference in a new issue