mirror of
https://github.com/wcbing/wcbing-apt-repo.git
synced 2025-12-28 18:18:31 +08:00
fix: output error message by logging
This commit is contained in:
parent
891b3d8cf2
commit
179b5fcc2f
@ -72,9 +72,9 @@ if __name__ == "__main__":
|
||||
check_download(args[1], args[2], args[3], args[4])
|
||||
elif len(args) == 4:
|
||||
check_download(args[1], args[2], args[3], "x86_64")
|
||||
elif len(args) > 1:
|
||||
logging.error(f"Unknown Args: {args[1:]}")
|
||||
else:
|
||||
if len(args) > 1:
|
||||
print(f"Unknown Args: {args[1:]}\n")
|
||||
print(f"Usage: {args[0]} <package_name> <version> <url> [arch]")
|
||||
print("options:")
|
||||
print(" arch: x86_64, arm64. default is x86_64")
|
||||
|
||||
@ -31,7 +31,7 @@ def read_repo_list(repo_list_file):
|
||||
with open(repo_list_file, "r") as f:
|
||||
return json.load(f)
|
||||
except Exception as e:
|
||||
logging.warning(f"Error reading repo list: {e}")
|
||||
logging.error(f"Error reading repo list: {e}")
|
||||
return []
|
||||
|
||||
|
||||
@ -41,7 +41,7 @@ def get_remote_packages(repo_url, file_path):
|
||||
try:
|
||||
response = requests.get(file_url, timeout=10)
|
||||
if response.status_code != 200:
|
||||
logging.warning(
|
||||
logging.error(
|
||||
f"GetError: {file_url} returned status {response.status_code}"
|
||||
)
|
||||
return b""
|
||||
@ -52,7 +52,7 @@ def get_remote_packages(repo_url, file_path):
|
||||
content += b"\n"
|
||||
return content.replace(b"Filename: ", f"Filename: {repo_url}".encode())
|
||||
except Exception as e:
|
||||
logging.warning(f"Error fetching packages: {e}")
|
||||
logging.error(f"Error fetching packages: {e}")
|
||||
return b""
|
||||
|
||||
|
||||
@ -86,18 +86,14 @@ def get_latest(deb_packages):
|
||||
def process_repo(r):
|
||||
try:
|
||||
deb_packages = b""
|
||||
if r.get("mix_path"):
|
||||
# 获取扁平 Repo 中包信息
|
||||
if r.get("mix_path"): # 获取扁平 Repo 中包信息
|
||||
deb_packages += get_remote_packages(r["repo"], r["mix_path"])
|
||||
else:
|
||||
if r.get("amd64_path"):
|
||||
# 获取 Repo 中 Amd64 包信息
|
||||
if r.get("amd64_path"): # 获取 Repo 中 Amd64 包信息
|
||||
deb_packages += get_remote_packages(r["repo"], r["amd64_path"])
|
||||
if r.get("arm64_path"):
|
||||
# 获取 Repo 中 Arm64 包信息
|
||||
if r.get("arm64_path"): # 获取 Repo 中 Arm64 包信息
|
||||
deb_packages += get_remote_packages(r["repo"], r["arm64_path"])
|
||||
if r.get("all_path"):
|
||||
# 获取 Repo 中 All 包信息
|
||||
if r.get("all_path"): # 获取 Repo 中 All 包信息
|
||||
deb_packages += get_remote_packages(r["repo"], r["all_path"])
|
||||
get_latest(deb_packages)
|
||||
except Exception as e:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user