2022-04-11 21:18:21 +02:00
|
|
|
# THIS SOFTWARE IS A PART OF FREE COMPETITOR PROJECT
|
|
|
|
# THE FOLLOWING SOURCE CODE I UNDER THE GNU
|
|
|
|
# AGPL LICENSE V3 OR ANY LATER VERSION.
|
|
|
|
|
|
|
|
# This project is not for simple users, but for
|
|
|
|
# web-masters and a like, so we are counting on
|
|
|
|
# your ability to set it up and running.
|
|
|
|
|
|
|
|
import os
|
2022-04-14 18:42:41 +02:00
|
|
|
import sys
|
2022-04-11 21:18:21 +02:00
|
|
|
import json
|
|
|
|
|
2022-04-14 18:42:41 +02:00
|
|
|
from modules import missing
|
|
|
|
|
|
|
|
args = sys.argv
|
|
|
|
|
2022-04-14 19:06:34 +02:00
|
|
|
if "--help" in args or "-h" in args:
|
|
|
|
print("""You can use the next commands after check.py
|
|
|
|
|
|
|
|
-links | Will skip checking the links
|
|
|
|
|
|
|
|
--help | Displays this help menu""")
|
2022-04-14 18:42:41 +02:00
|
|
|
exit()
|
|
|
|
|
2022-04-11 21:18:21 +02:00
|
|
|
# TODO: Make a pull-request before starting
|
|
|
|
|
|
|
|
print("* Checking...")
|
|
|
|
|
|
|
|
# Check number one, list all missing software
|
|
|
|
|
|
|
|
try:
|
|
|
|
with open("data/missing.json") as json_file:
|
2022-04-14 18:42:41 +02:00
|
|
|
miss = json.load(json_file)
|
2022-04-11 21:18:21 +02:00
|
|
|
except:
|
2022-04-14 18:42:41 +02:00
|
|
|
miss = {}
|
2022-04-11 21:18:21 +02:00
|
|
|
|
2022-04-14 18:42:41 +02:00
|
|
|
if miss:
|
2022-04-11 21:18:21 +02:00
|
|
|
print()
|
|
|
|
print("* Missing Software found! Please copy-paste the next")
|
|
|
|
print(" section into our Missing Software Mega-Thread at: ")
|
|
|
|
print(" https://notabug.org/jyamihud/FreeCompetitors/issues/25")
|
|
|
|
print("===========================================================")
|
|
|
|
print()
|
|
|
|
|
2022-04-14 18:42:41 +02:00
|
|
|
missing.List()
|
2022-04-11 21:18:21 +02:00
|
|
|
|
2022-04-14 18:42:41 +02:00
|
|
|
if miss:
|
2022-04-11 21:18:21 +02:00
|
|
|
print()
|
|
|
|
print("===========================================================")
|
|
|
|
print()
|
|
|
|
|
|
|
|
# Part two. Checking for healthy links
|
|
|
|
|
|
|
|
import urllib.request
|
|
|
|
import urllib.error
|
|
|
|
|
|
|
|
error = False
|
|
|
|
def iferror():
|
|
|
|
if not error:
|
|
|
|
print()
|
|
|
|
print(" * Some files in 'apps' folder have problems! Please")
|
|
|
|
print(" copy-paste the next section into our Problems with")
|
|
|
|
print(" Software Mega-Thread at: ")
|
|
|
|
print(" https://notabug.org/jyamihud/FreeCompetitors/issues/24")
|
|
|
|
print("===========================================================")
|
|
|
|
print()
|
|
|
|
return True
|
|
|
|
|
|
|
|
for f in os.listdir("apps"):
|
|
|
|
if f.endswith(".json"):
|
|
|
|
# Trying to read the file
|
|
|
|
try:
|
|
|
|
with open("apps/"+f) as json_file:
|
|
|
|
app = json.load(json_file)
|
|
|
|
except Exception as e:
|
|
|
|
error = iferror()
|
|
|
|
print(" - [ ] `apps/"+f+"` fails to load. Says: `"+str(e)+"`")
|
|
|
|
continue
|
|
|
|
|
|
|
|
# Links
|
2022-04-14 18:42:41 +02:00
|
|
|
if not "-links" in args:
|
|
|
|
for link in app.get("links",[]):
|
2022-04-11 21:18:21 +02:00
|
|
|
|
2022-04-14 18:42:41 +02:00
|
|
|
# TODO: Make the tester of the links closer to the kind
|
|
|
|
# of response that you will get in the web-browser.
|
2022-04-11 21:18:21 +02:00
|
|
|
|
2022-04-14 18:42:41 +02:00
|
|
|
try:
|
|
|
|
urllib.request.urlopen(app.get("links",[])[link])
|
|
|
|
except Exception as e:
|
|
|
|
if "403" not in str(e):
|
|
|
|
error = iferror()
|
|
|
|
print(" - [ ] `apps/"+f+"` "+link+" link doesn't seem to work.")
|
2022-04-11 21:18:21 +02:00
|
|
|
|
|
|
|
# Licenses
|
|
|
|
lices = app.get("licenses", [])
|
|
|
|
try:
|
|
|
|
with open("data/licenses.json") as json_file:
|
|
|
|
ll = json.load(json_file)["licenses"]
|
|
|
|
except:
|
|
|
|
ll = {}
|
|
|
|
|
|
|
|
for lic in lices:
|
|
|
|
|
|
|
|
found = False
|
|
|
|
for l in ll:
|
|
|
|
if lic in [l.get("licenseId",""),l.get("name","")]:
|
|
|
|
found = True
|
|
|
|
if not found:
|
|
|
|
error = iferror()
|
|
|
|
print(" - [ ] `apps/"+f+"` License '"+lic+"' is unknown.")
|
|
|
|
|
2022-04-14 18:42:41 +02:00
|
|
|
print()
|
2022-04-11 21:18:21 +02:00
|
|
|
print("===========================================================")
|
|
|
|
print()
|
|
|
|
print("* Check is finished!")
|
|
|
|
print()
|