Skip to content

Commit 051062b

Browse files
committed
fix: remove comments, update messages, lint
1 parent b5958a2 commit 051062b

File tree

1 file changed

+3
-31
lines changed

1 file changed

+3
-31
lines changed

src/server.py

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,16 @@
11
import subprocess
2-
# import time
32
from wsgiref.simple_server import make_server
43

54
import falcon
65

7-
# import psutil
8-
9-
# def wait_for_beet_processes(parent_pid: int, timeout: int = 3600) -> None:
10-
# start_time = time.time()
11-
#
12-
# while time.time() - start_time < timeout:
13-
# beet_processes = []
14-
# for proc in psutil.process_iter(["pid", "name", "cmdline"]):
15-
# try:
16-
# cmdline = proc.info.get("cmdline")
17-
# if cmdline and "beet" in " ".join(cmdline):
18-
# beet_processes.append(proc.info["pid"])
19-
# except (psutil.NoSuchProcess, psutil.AccessDenied):
20-
# continue
21-
#
22-
# if not beet_processes:
23-
# break
24-
#
25-
# time.sleep(0.5)
26-
#
27-
# if time.time() - start_time >= timeout:
28-
# raise TimeoutError(f"Beet processes did not complete within {timeout} seconds")
29-
#
30-
316

327
class BeetImportResource:
338
def on_post(self, req: falcon.Request, resp: falcon.Response) -> None:
349
data = req.get_media()
3510
print(f"Received import request for directory: {data['localDirectoryName']}")
3611
try:
3712
print(
38-
f"beet --config=config/config.yaml import --quiet {data['localDirectoryName']}"
13+
f"beet -v --config=config/config.yaml import --quiet {data['localDirectoryName']}"
3914
)
4015
result = subprocess.Popen(
4116
[
@@ -47,12 +22,9 @@ def on_post(self, req: falcon.Request, resp: falcon.Response) -> None:
4722
data["localDirectoryName"],
4823
]
4924
)
50-
# print("Main beet process completed, waiting for background imports...")
51-
# wait_for_beet_processes(result.pid)
52-
# print("All import processes completed successfully.")
5325
resp.status = falcon.HTTP_200
5426
resp.media = {
55-
"message": "Imported complete.",
27+
"message": "Import triggered.",
5628
"output": f"Beet import process triggered for directory: {data['localDirectoryName']}",
5729
}
5830
except Exception as e:
@@ -70,5 +42,5 @@ def on_post(self, req: falcon.Request, resp: falcon.Response) -> None:
7042
with make_server("", 8074, app) as httpd:
7143
print("Serving on port 8074...")
7244

73-
# Serve until process is killed
45+
# mood
7446
httpd.serve_forever()

0 commit comments

Comments
 (0)