rename generate.py -> action.py
This commit is contained in:
parent
7291b1ddfc
commit
4acbe7d976
1 changed files with 19 additions and 11 deletions
|
|
@ -1,15 +1,14 @@
|
|||
# /// script
|
||||
# requires-python = ">=3.12"
|
||||
# requires-python = ">=3.14"
|
||||
# dependencies = ["requests<3"]
|
||||
# ///
|
||||
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
import requests
|
||||
|
||||
API_ENDPOINT_URL = os.getenv("CONTEST_HOST") + os.getenv("CONTEST_ENDPOINT")
|
||||
|
||||
|
||||
def download_image(url, payload, filepath):
|
||||
try:
|
||||
|
|
@ -36,18 +35,27 @@ def download_image(url, payload, filepath):
|
|||
|
||||
|
||||
def main():
|
||||
host = os.getenv("CONTEST_HOST")
|
||||
endpoint = os.getenv("CONTEST_API")
|
||||
|
||||
if host is None or endpoint is None:
|
||||
print("env variable is not set")
|
||||
return -1
|
||||
|
||||
API_ENDPOINT_URL = host + endpoint
|
||||
|
||||
with open("answer.json", "r") as file:
|
||||
manifest_data = json.load(file)
|
||||
answers = json.load(file)
|
||||
|
||||
if not manifest_data:
|
||||
return
|
||||
if not answers:
|
||||
return -1
|
||||
|
||||
for test_case in manifest_data.get("tests", []):
|
||||
filename = test_case.get("name")
|
||||
request_payload = test_case.get("request")
|
||||
for test in answers.get("tests", []):
|
||||
filename = test.get("name")
|
||||
request_payload = test.get("request")
|
||||
|
||||
if not filename or not request_payload:
|
||||
print(f"Skipping invalid test case: {test_case}")
|
||||
print(f"Skipping invalid test case: {test}")
|
||||
continue
|
||||
|
||||
print(f"Requesting '{filename}'...")
|
||||
|
|
@ -55,4 +63,4 @@ def main():
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
sys.exit(main())
|
||||
Loading…
Add table
Add a link
Reference in a new issue