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