diff --git a/worker.py b/worker.py index ca47c33..341ddc4 100755 --- a/worker.py +++ b/worker.py @@ -14,9 +14,12 @@ logger = Logger() def trigger_export(courseid, categoryid): global MOODLE_PATH, OUTPUT_PATH - output_name = f"course_{courseid}_{categoryid}_{datetime.now().timestamp()}" - subprocess.run([MOOSH_PATH, "-p", MOODLE_PATH, "course-backup", - "-p", OUTPUT_PATH, "-f", output_name, "--template", courseid]) + output_name = f"course_{courseid}_{categoryid}_{int(datetime.now().timestamp())}.mbz" + result = subprocess.run([MOOSH_PATH, "-p", MOODLE_PATH, "course-backup", + "-p", OUTPUT_PATH, "-f", output_name, "--template", courseid], + capture_output=True) + for line in str(result.stdout).splitlines(): + logger.debug(line) return output_name @@ -48,7 +51,7 @@ def main(): size = Path(OUTPUT_PATH / output_name).stat().st_size f.unlink() logger.debug( - f"Created file {output_name} ({size} bytes) in {dur.seconds}") + f"Created file {output_name} ({size} bytes) in {dur.seconds} seconds") except Exception as e: logger.error( f"Export of course {f.name.split('.')[0].split('-')[0]} failed: {e}") @@ -57,4 +60,4 @@ def main(): if __name__ == "__main__": - main() \ No newline at end of file + main()