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:
|
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.")
|
||||||
|
|
||||||
|
print(f"A mirror for '{repo_name}' must be created.")
|
||||||
|
|
||||||
api_header = {
|
api_header = {
|
||||||
"Content-type": "application/json",
|
"Content-type": "application/json",
|
||||||
"Authorization": "{FORGEJO_TOKEN}",
|
"Authorization": "{FORGEJO_TOKEN}",
|
||||||
|
@ -76,22 +78,19 @@ def generate_mirrors():
|
||||||
json=create_mirror_data,
|
json=create_mirror_data,
|
||||||
)
|
)
|
||||||
|
|
||||||
if create_mirror.status_code != 201:
|
|
||||||
if create_mirror.status_code == 409:
|
if create_mirror.status_code == 409:
|
||||||
print(f"A repo named '{repo_name}' is already existing.")
|
print(f"A repo named '{repo_name}' is already existing.")
|
||||||
|
continue
|
||||||
|
|
||||||
if create_mirror.status_code == 422:
|
if create_mirror.status_code == 422:
|
||||||
print(
|
print("We're rate limited. Waiting for 1 minute before continuing.")
|
||||||
f"We're rate limited. Waiting for 1 minute before continuing."
|
|
||||||
)
|
|
||||||
time.sleep(60)
|
time.sleep(60)
|
||||||
|
|
||||||
else:
|
if create_mirror.status_code not in (201, 422):
|
||||||
raise Exception(
|
raise Exception(
|
||||||
"Request failed:", create_mirror.status_code, create_mirror.text
|
"Request failed:", create_mirror.status_code, create_mirror.text
|
||||||
)
|
)
|
||||||
|
|
||||||
else:
|
|
||||||
# configuring properly the new repository
|
# configuring properly the new repository
|
||||||
settings_mirror_data = {
|
settings_mirror_data = {
|
||||||
"has_packages": False,
|
"has_packages": False,
|
||||||
|
@ -109,7 +108,7 @@ def generate_mirrors():
|
||||||
|
|
||||||
if settings_mirror.status_code != 200:
|
if settings_mirror.status_code != 200:
|
||||||
raise Exception("Request failed:", settings_mirror.text)
|
raise Exception("Request failed:", settings_mirror.text)
|
||||||
else:
|
|
||||||
print("Repository cloned and configured.")
|
print("Repository cloned and configured.")
|
||||||
time.sleep(5) # Sleeping for 5 seconds to cooldown the API
|
time.sleep(5) # Sleeping for 5 seconds to cooldown the API
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue