Update Python tools

This commit is contained in:
ajp_anton
2026-08-09 02:31:54 +00:00
parent b0c707d624
commit 6d28257b54
10 changed files with 362 additions and 12 deletions
+45
View File
@@ -18,6 +18,31 @@ if (output) {
window.setInterval(refresh, 2000);
}
const refreshArtifacts = async (container) => {
const response = await fetch(container.dataset.artifactsUrl, { cache: "no-store" });
if (!response.ok) {
return [];
}
const artifacts = (await response.json()).artifacts;
const list = container.querySelector("ul");
list.replaceChildren();
for (const artifact of artifacts) {
const item = document.createElement("li");
const link = document.createElement("a");
link.href = artifact.url;
link.textContent = artifact.name;
item.append(link);
list.append(item);
}
container.hidden = artifacts.length === 0;
return artifacts;
};
for (const container of document.querySelectorAll("#run-artifacts")) {
refreshArtifacts(container);
window.setInterval(() => refreshArtifacts(container), 2000);
}
for (const form of document.querySelectorAll("form[data-wait-for-result]")) {
const result = form.querySelector(".task-result");
const controls = [...form.querySelectorAll("input, select, button")];
@@ -53,6 +78,23 @@ for (const form of document.querySelectorAll("form[data-wait-for-result]")) {
}
};
const downloadArtifacts = async (run) => {
const response = await fetch(run.artifacts_url, { cache: "no-store" });
if (!response.ok) {
return;
}
const artifacts = (await response.json()).artifacts;
if (!artifacts.length) {
return;
}
const link = document.createElement("a");
link.href = artifacts[0].url;
link.download = "";
document.body.append(link);
link.click();
link.remove();
};
const waitForRun = async (run) => {
while (true) {
const response = await fetch(run.state_url, { cache: "no-store" });
@@ -63,6 +105,9 @@ for (const form of document.querySelectorAll("form[data-wait-for-result]")) {
if (state.status !== "queued" && state.status !== "running") {
if (state.status === "succeeded") {
showResult("Completed successfully.", "succeeded", run.detail_url);
if (form.dataset.downloadArtifacts !== undefined) {
await downloadArtifacts(run);
}
} else {
showResult(`Finished with status: ${state.status}.`, "failed", run.detail_url);
}