diff options
| author | Arslaan Pathan <[email protected]> | 2026-10-06 08:38:02 +1300 |
|---|---|---|
| committer | Arslaan Pathan <[email protected]> | 2026-10-06 08:38:02 +1300 |
| commit | 8af43f9f3c1f5e9b52a4ea77a50817d577f14851 (patch) | |
| tree | 2c7d93b279ecdeb7ff9cc50ee629c299b6defe57 /backend.py | |
| parent | c03f2c4d645a1b36e4038cec933ded31546729af (diff) | |
| download | remote-automation-8af43f9f3c1f5e9b52a4ea77a50817d577f14851.tar.xz remote-automation-8af43f9f3c1f5e9b52a4ea77a50817d577f14851.zip | |
release lock
Diffstat (limited to 'backend.py')
| -rw-r--r-- | backend.py | 21 |
1 files changed, 13 insertions, 8 deletions
@@ -21,16 +21,21 @@ def print_queue(): if not print_lock.acquire(blocking=False): print("print queue is already running") return "print queue busy", 400 - print("printing file(s) in /srv/shares/public/printing") - path = Path("/srv/shares/public/printing") - files = [f for f in path.iterdir() if f.is_file()] + try: + print("printing file(s) in /srv/shares/public/printing") + path = Path("/srv/shares/public/printing") + files = [f for f in path.iterdir() if f.is_file()] - for file in files: - subprocess.run(["lp", "-d", "Canon_G3060", str(file)], check=True) - subprocess.run(["mv", str(file), "/srv/shares/public/printed"], check=True) + for file in files: + subprocess.run(["lp", "-d", "Canon_G3060", str(file)], check=True) + subprocess.run(["mv", str(file), "/srv/shares/public/printed"], check=True) - print(f"printed {len(files)} file(s)") - return f"printed {len(files)} file(s)" + print(f"printed {len(files)} file(s)") + return f"printed {len(files)} file(s)" + except Exception as e: + return f"exception: {(str(e))}", 500 + finally: + print_lock.release() if __name__ == "__main__": app.run(host="0.0.0.0", port=6732) |
