Fix error check

This commit is contained in:
Kumi 2022-09-12 16:55:01 +00:00
parent d680c4efb1
commit 4dd3cb0f54
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -19,11 +19,10 @@ courses = dict()
mbzre = re.compile(r"course_(?P<courseid>\d+)_(?P<categoryid>\d+)_(?P<timestamp>\d+).mbz")
def call_php(courseid: int, categoryid: int, timestamp: int):
try:
subprocess.run(["php", config["IMPORTER"]["PHPScript"], f"--courseid={courseid}", f"--categoryid={categoryid}", f"--timestamp={timestamp}"], cwd=Path(config["IMPORTER"]["PHPScript"]).parent, check=True)
return True
except subprocess.CalledProcessError:
return False
response = subprocess.run(["php", config["IMPORTER"]["PHPScript"], f"--courseid={courseid}", f"--categoryid={categoryid}", f"--timestamp={timestamp}"], cwd=Path(config["IMPORTER"]["PHPScript"]).parent, capture_output=True, encoding="utf8")
print(response.stdout)
print(response.stderr)
return (not response.stderr) and (not "!!!" in response.stdout)
for mbz in source.glob("course_*_*_*.mbz"):