Skip to content

Commit

Permalink
Merge pull request #59 from Alexander-Wilms/develop
Browse files Browse the repository at this point in the history
Improve output of validate_json.py and validate_mod_json.py
  • Loading branch information
dydzio0614 authored Jul 17, 2024
2 parents 8416af0 + 1f9a075 commit fb23c6a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
13 changes: 9 additions & 4 deletions .github/validate_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@

try:
json.loads(filecontent)
print(f"✅ JSON valid")
except Exception as err:
print("Error: " + str(err))
sys.exit(os.EX_SOFTWARE)
error = True
print(f"❌ JSON invalid:")
print(str(err))

print("Everything is ok!")
sys.exit(os.EX_OK)
if error:
sys.exit(os.EX_SOFTWARE)
else:
print("Everything is ok!")
sys.exit(os.EX_OK)
9 changes: 6 additions & 3 deletions .github/validate_mod_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,23 @@
modlist = json.loads(filecontent)
for mod, data in modlist.items():
url = data["mod"].replace(" ", "%20")
print(f"Download {mod}: {url}")
print(f"{mod}: {url}")
try:
response = urllib.request.urlopen(url)
print(f"✅ Download successful")
except:
error = True
print("Error: download failed!")
print("❌ Download failed")
continue
filecontent = response.read()

try:
json.loads(filecontent)
print(f"✅ JSON valid")
except Exception as err:
error = True
print("Error: " + str(err))
print(f"❌ JSON invalid:")
print(str(err))
continue
if error:
sys.exit(os.EX_SOFTWARE)
Expand Down

0 comments on commit fb23c6a

Please sign in to comment.