Skip to content

Commit 6e7bc44

Browse files
committed
extract sleep duration to constant
1 parent ba980c2 commit 6e7bc44

6 files changed

Lines changed: 12 additions & 11 deletions

File tree

scripts/deploy.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import pathlib
44
import re
55
import sys
6-
import time
76

87
from typing import Iterable
98

@@ -45,7 +44,6 @@ def deploy_all_files_for_wiki(
4544
session, file_path, file_content, wiki, page, token, deploy_reason
4645
)
4746
all_modules_deployed = all_modules_deployed and module_deployed
48-
time.sleep(4)
4947
print("::endgroup::")
5048
return all_modules_deployed
5149

scripts/deploy_res.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import pathlib
33
import sys
44
import subprocess
5-
import time
65

76
from typing import Iterable
87

@@ -41,7 +40,6 @@ def deploy_resources(
4140
all_deployed = all_deployed and deploy_result[0]
4241
changes_made = changes_made or deploy_result[1]
4342
print("::endgroup::")
44-
time.sleep(4)
4543
return (all_deployed, changes_made)
4644

4745

scripts/deploy_util.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
__all__ = [
1111
"DEPLOY_TRIGGER",
1212
"HEADER",
13+
"SLEEP_DURATION",
1314
"deploy_file_to_wiki",
1415
"get_git_deploy_reason",
1516
"get_wiki_api_url",
@@ -28,6 +29,7 @@
2829
"accept": "application/json",
2930
"Accept-Encoding": "gzip",
3031
}
32+
SLEEP_DURATION = 4
3133

3234

3335
def get_wikis() -> set[str]:
@@ -36,7 +38,7 @@ def get_wikis() -> set[str]:
3638
headers=HEADER,
3739
)
3840
wikis = response.json()
39-
time.sleep(4)
41+
time.sleep(SLEEP_DURATION)
4042
return set(wikis["allwikis"].keys())
4143

4244

@@ -94,6 +96,7 @@ def deploy_file_to_wiki(
9496
print(f"::warning file={str(file_path)}::failed to deploy")
9597
write_to_github_summary_file(f":warning: {str(file_path)} failed to deploy")
9698
deployed = False
99+
time.sleep(SLEEP_DURATION)
97100
return deployed, change_made
98101

99102

scripts/login_and_get_token.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import requests
66

7-
from deploy_util import HEADER, get_wiki_api_url, read_cookie_jar
7+
from deploy_util import HEADER, SLEEP_DURATION, get_wiki_api_url, read_cookie_jar
88

99
__all__ = ["get_token"]
1010

@@ -43,7 +43,7 @@ def login(wiki: str):
4343
)
4444
loggedin.add(wiki)
4545
cookie_jar.save(ignore_discard=True)
46-
time.sleep(4)
46+
time.sleep(SLEEP_DURATION)
4747

4848

4949
@functools.cache

scripts/protect_page.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from deploy_util import (
88
HEADER,
9+
SLEEP_DURATION,
910
get_wiki_api_url,
1011
read_cookie_jar,
1112
write_to_github_summary_file,
@@ -48,7 +49,7 @@ def protect_page(page: str, wiki: str, protect_mode: Literal["edit", "create"]):
4849
},
4950
).json()
5051

51-
time.sleep(4)
52+
time.sleep(SLEEP_DURATION)
5253
protections = response["protect"].get("protections")
5354
for protection in protections:
5455
if protection[protect_mode] == "allow-only-sysop":
@@ -68,7 +69,7 @@ def check_if_page_exists(page: str, wiki: str) -> bool:
6869
data={"titles": page, "prop": "info"},
6970
).text
7071

71-
time.sleep(4)
72+
time.sleep(SLEEP_DURATION)
7273
return 'missing":"' in result
7374

7475

scripts/remove_dev.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from deploy_util import (
77
HEADER,
8+
SLEEP_DURATION,
89
get_wiki_api_url,
910
get_wikis,
1011
read_cookie_jar,
@@ -34,7 +35,7 @@ def remove_page(session: requests.Session, page: str, wiki: str):
3435
"token": token,
3536
},
3637
).text
37-
time.sleep(8)
38+
time.sleep(SLEEP_DURATION)
3839

3940
if '"delete"' not in result:
4041
print(f"::warning::could not delete {page} on {wiki}")
@@ -57,7 +58,7 @@ def search_and_remove(wiki: str):
5758
"srprop": "",
5859
},
5960
).json()
60-
time.sleep(4)
61+
time.sleep(SLEEP_DURATION)
6162
pages = search_result["query"].get("search")
6263

6364
if len(pages) == 0:

0 commit comments

Comments
 (0)