mirror of
https://github.com/YunoHost/yunodevtools.git
synced 2024-09-03 20:16:19 +02:00
refactor(clone_packages): reduce indentation for lisibility (and fix two bugs)
This commit is contained in:
parent
8786533ec6
commit
5a2c9ca8e7
1 changed files with 49 additions and 50 deletions
|
@ -55,6 +55,8 @@ def generate_mirrors():
|
|||
if app[0] not in mirror_list:
|
||||
print(f"A mirror for '{repo_name}' must be created.")
|
||||
|
||||
print(f"A mirror for '{repo_name}' must be created.")
|
||||
|
||||
api_header = {
|
||||
"Content-type": "application/json",
|
||||
"Authorization": "{FORGEJO_TOKEN}",
|
||||
|
@ -76,22 +78,19 @@ def generate_mirrors():
|
|||
json=create_mirror_data,
|
||||
)
|
||||
|
||||
if create_mirror.status_code != 201:
|
||||
if create_mirror.status_code == 409:
|
||||
print(f"A repo named '{repo_name}' is already existing.")
|
||||
continue
|
||||
|
||||
if create_mirror.status_code == 422:
|
||||
print(
|
||||
f"We're rate limited. Waiting for 1 minute before continuing."
|
||||
)
|
||||
print("We're rate limited. Waiting for 1 minute before continuing.")
|
||||
time.sleep(60)
|
||||
|
||||
else:
|
||||
if create_mirror.status_code not in (201, 422):
|
||||
raise Exception(
|
||||
"Request failed:", create_mirror.status_code, create_mirror.text
|
||||
)
|
||||
|
||||
else:
|
||||
# configuring properly the new repository
|
||||
settings_mirror_data = {
|
||||
"has_packages": False,
|
||||
|
@ -109,7 +108,7 @@ def generate_mirrors():
|
|||
|
||||
if settings_mirror.status_code != 200:
|
||||
raise Exception("Request failed:", settings_mirror.text)
|
||||
else:
|
||||
|
||||
print("Repository cloned and configured.")
|
||||
time.sleep(5) # Sleeping for 5 seconds to cooldown the API
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue