Retries
This commit is contained in:
parent
54876a052d
commit
f3dc9bb001
3 changed files with 78 additions and 59 deletions
|
|
@ -17,12 +17,12 @@ export default async (req: Request, res: Response) => {
|
||||||
|
|
||||||
// Determine how many items in the queue are ahead of this one
|
// Determine how many items in the queue are ahead of this one
|
||||||
const aheadInQueue = await Jobs.find({
|
const aheadInQueue = await Jobs.find({
|
||||||
queue_place: { $lt: job.queuePlace },
|
queue_place: { $lte: job.queuePlace },
|
||||||
});
|
});
|
||||||
|
|
||||||
let text: string = "";
|
let text: string = "";
|
||||||
if (job.status == Status.ENQUEUED) {
|
if (job.status == Status.ENQUEUED) {
|
||||||
text = `Enqueued: ${aheadInQueue.length} Job(s) ahead in queue`;
|
text = `Enqueued: ${aheadInQueue.length + 1} Job(s) ahead in queue`;
|
||||||
} else if (job.status == Status.PROCESSING) {
|
} else if (job.status == Status.PROCESSING) {
|
||||||
text = `Currently Processing\n${job.logs}`;
|
text = `Currently Processing\n${job.logs}`;
|
||||||
} else if (job.status == Status.COMPLETE) {
|
} else if (job.status == Status.COMPLETE) {
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,9 @@ from os import environ as env
|
||||||
from os import unlink as rm
|
from os import unlink as rm
|
||||||
from textwrap import dedent
|
from textwrap import dedent
|
||||||
from typing import List
|
from typing import List
|
||||||
from urllib3.exceptions import ProtocolError
|
|
||||||
import requests
|
import requests
|
||||||
|
from urllib3.exceptions import ProtocolError, ReadTimeoutError
|
||||||
|
|
||||||
import curse_api as cf
|
import curse_api as cf
|
||||||
from common import Job, Status
|
from common import Job, Status
|
||||||
|
|
@ -90,37 +91,44 @@ class FastProvider(MgmtApiLogger):
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
tries, msg = 1, ""
|
||||||
response = requests.post(
|
while tries <= 5:
|
||||||
"https://api.modrinth.com/v2/version",
|
try:
|
||||||
timeout=30,
|
response = requests.post(
|
||||||
headers={"Authorization": self._job.github_pat},
|
"https://api.modrinth.com/v2/version",
|
||||||
files=[
|
timeout=30,
|
||||||
("data", (None, payload, None)),
|
headers={"Authorization": self._job.github_pat},
|
||||||
("files", (jar_fn, jar_data, "application/octet-stream")),
|
files=[
|
||||||
],
|
("data", (None, payload, None)),
|
||||||
)
|
("files", (jar_fn, jar_data, "application/octet-stream")),
|
||||||
if response.status_code == 200:
|
],
|
||||||
statuses.append(Status.SUCCESS)
|
|
||||||
self.logmsg(f"✅ {display_nm}")
|
|
||||||
else:
|
|
||||||
statuses.append(Status.FAIL)
|
|
||||||
self.logmsg(
|
|
||||||
dedent(
|
|
||||||
f"""----- 🔥 {display_nm} -----
|
|
||||||
API Response from Modrinth FAIL for {display_nm}:
|
|
||||||
{self.decode_modrinth_resp(response)}
|
|
||||||
"""
|
|
||||||
).strip("\n")
|
|
||||||
)
|
)
|
||||||
|
if response.status_code == 200:
|
||||||
|
statuses.append(Status.SUCCESS)
|
||||||
|
self.logmsg(f"✅ {display_nm}")
|
||||||
|
else:
|
||||||
|
statuses.append(Status.FAIL)
|
||||||
|
self.logmsg(
|
||||||
|
dedent(
|
||||||
|
f"""----- 🔥 {display_nm} -----
|
||||||
|
API Response from Modrinth FAIL for {display_nm}:
|
||||||
|
{self.decode_modrinth_resp(response)}
|
||||||
|
"""
|
||||||
|
).strip("\n")
|
||||||
|
)
|
||||||
|
|
||||||
rm(jar_fn)
|
rm(jar_fn)
|
||||||
except (ProtocolError, requests.exceptions.ChunkedEncodingError):
|
break
|
||||||
self.logmsg(f"🔥 Uploading {display_nm} to Modrinth failed, skipping..")
|
except (ReadTimeoutError, TimeoutError):
|
||||||
statuses.append(Status.FAIL)
|
tries += 1
|
||||||
continue
|
msg = f"🕜 Timed out uploading {jar_fn}. Manual upload required"
|
||||||
except TimeoutError:
|
continue
|
||||||
self.logmsg(f"🕜 Timed out uploading {jar_fn}. Manual upload required")
|
except (ProtocolError, requests.exceptions.ChunkedEncodingError):
|
||||||
|
tries += 1
|
||||||
|
msg = f"🔥 Uploading {display_nm} to Modrinth failed, skipping.."
|
||||||
|
continue
|
||||||
|
if tries == 5:
|
||||||
|
self.logmsg(msg)
|
||||||
statuses.append(Status.FAIL)
|
statuses.append(Status.FAIL)
|
||||||
# endregion UPLOAD JAR FILE
|
# endregion UPLOAD JAR FILE
|
||||||
return statuses
|
return statuses
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ from selenium.webdriver.chrome.service import Service
|
||||||
from selenium.webdriver.common.by import By
|
from selenium.webdriver.common.by import By
|
||||||
from selenium.webdriver.support import expected_conditions as EC
|
from selenium.webdriver.support import expected_conditions as EC
|
||||||
from selenium.webdriver.support.ui import WebDriverWait
|
from selenium.webdriver.support.ui import WebDriverWait
|
||||||
|
from urllib3.exceptions import ProtocolError, ReadTimeoutError
|
||||||
from webdriver_manager.chrome import ChromeDriverManager
|
from webdriver_manager.chrome import ChromeDriverManager
|
||||||
|
|
||||||
import curse_api as cf
|
import curse_api as cf
|
||||||
|
|
@ -212,35 +213,45 @@ class SlowProvider(MgmtApiLogger):
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
tries, msg = 1, ""
|
||||||
response = requests.post(
|
while tries <= 5:
|
||||||
"https://api.modrinth.com/v2/version",
|
try:
|
||||||
timeout=30,
|
response = requests.post(
|
||||||
headers={"Authorization": self._job.github_pat},
|
"https://api.modrinth.com/v2/version",
|
||||||
files=[
|
timeout=30,
|
||||||
("data", (None, payload, None)),
|
headers={"Authorization": self._job.github_pat},
|
||||||
("files", (fpath, jar_data, "application/octet-stream")),
|
files=[
|
||||||
],
|
("data", (None, payload, None)),
|
||||||
)
|
("files", (fpath, jar_data, "application/octet-stream")),
|
||||||
if response.status_code == 200:
|
],
|
||||||
statuses.append(Status.SUCCESS)
|
|
||||||
self.logmsg(f"✅ {display_nm}")
|
|
||||||
else:
|
|
||||||
statuses.append(Status.FAIL)
|
|
||||||
self.logmsg(
|
|
||||||
dedent(
|
|
||||||
f"""----- 🔥 {display_nm} -----
|
|
||||||
API Response from Modrinth FAIL for {display_nm}:
|
|
||||||
{self.decode_modrinth_resp(response)}
|
|
||||||
"""
|
|
||||||
).strip("\n")
|
|
||||||
)
|
)
|
||||||
|
if response.status_code == 200:
|
||||||
|
statuses.append(Status.SUCCESS)
|
||||||
|
self.logmsg(f"✅ {display_nm}")
|
||||||
|
else:
|
||||||
|
statuses.append(Status.FAIL)
|
||||||
|
self.logmsg(
|
||||||
|
dedent(
|
||||||
|
f"""----- 🔥 {display_nm} -----
|
||||||
|
API Response from Modrinth FAIL for {display_nm}:
|
||||||
|
{self.decode_modrinth_resp(response)}
|
||||||
|
"""
|
||||||
|
).strip("\n")
|
||||||
|
)
|
||||||
|
|
||||||
rm(f"./out/{self._job.curseforge_slug}/{fpath}")
|
rm(f"./out/{self._job.curseforge_slug}/{fpath}")
|
||||||
except TimeoutError:
|
break
|
||||||
self.logmsg(f"🕜 Timed out uploading {fpath}. Manual upload required")
|
except (ReadTimeoutError, TimeoutError):
|
||||||
|
tries += 1
|
||||||
|
msg = f"🕜 Timed out uploading {fpath}. Manual upload required"
|
||||||
|
continue
|
||||||
|
except (ProtocolError, requests.exceptions.ChunkedEncodingError):
|
||||||
|
tries += 1
|
||||||
|
msg = f"🔥 Uploading {display_nm} to Modrinth failed, skipping.."
|
||||||
|
continue
|
||||||
|
if tries == 5:
|
||||||
|
self.logmsg(msg)
|
||||||
statuses.append(Status.FAIL)
|
statuses.append(Status.FAIL)
|
||||||
|
|
||||||
# endregion UPLOAD THE MOD
|
# endregion UPLOAD THE MOD
|
||||||
|
|
||||||
any_succ = len(list(filter(lambda x: x == Status.SUCCESS, statuses))) > 0
|
any_succ = len(list(filter(lambda x: x == Status.SUCCESS, statuses))) > 0
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue