diff --git a/nilmrun/server.py b/nilmrun/server.py index daa5004..5a492ec 100644 --- a/nilmrun/server.py +++ b/nilmrun/server.py @@ -109,7 +109,11 @@ class AppProcess(object): self.manager.remove(pid) return status - # /process/command +class AppRun(object): + def __init__(self, manager): + self.manager = manager + + # /run/command @cherrypy.expose @cherrypy.tools.json_in() @cherrypy.tools.json_out() @@ -120,12 +124,7 @@ class AppProcess(object): 'args[2]', etc as arguments.""" return self.manager.run_command("command", args) -class AppFilter(object): - - def __init__(self, manager): - self.manager = manager - - # /filter/trainola + # /run/trainola @cherrypy.expose @cherrypy.tools.json_in() @cherrypy.tools.json_out() @@ -135,7 +134,7 @@ class AppFilter(object): return self.manager.run_function( "trainola", nilmrun.filters.trainola.filterfunc, data) - # /filter/dummy + # /run/dummy @cherrypy.expose @cherrypy.tools.json_in() @cherrypy.tools.json_out() @@ -198,7 +197,7 @@ class Server(object): manager = nilmrun.processmanager.ProcessManager() root = App() root.process = AppProcess(manager) - root.filter = AppFilter(manager) + root.run = AppRun(manager) cherrypy.tree.apps = {} cherrypy.tree.mount(root, basepath, config = { "/" : app_config }) diff --git a/tests/test_client.py b/tests/test_client.py index 50bad68..0450b4c 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -83,7 +83,7 @@ class TestClient(object): client = HTTPClient(baseurl = testurl, post_json = True) # start dummy filter - pid = client.post("/filter/dummy", { "data": 30 }) + pid = client.post("/run/dummy", { "data": 30 }) eq_(client.get("/process/list"), [pid]) time.sleep(1) @@ -117,7 +117,7 @@ class TestClient(object): client = HTTPClient(baseurl = testurl, post_json = True) # Trigger exception in filter - pid = client.post("/filter/dummy", { "data": -1 }) + pid = client.post("/run/dummy", { "data": -1 }) time.sleep(0.5) status = client.get("/process/status", { "pid": pid }) eq_(status["alive"], False) @@ -126,7 +126,7 @@ class TestClient(object): client.post("/process/remove", { "pid": pid }) # Kill a running filter by removing it early - newpid = client.post("/filter/dummy", { "data": 50 }) + newpid = client.post("/run/dummy", { "data": 50 }) ne_(newpid, pid) time.sleep(0.5) start = time.time() @@ -141,7 +141,7 @@ class TestClient(object): eq_(client.get("/process/list"), []) # Try to remove a running filter that ignored SIGTERM - pid = client.post("/filter/dummy", { "data": 0 }) + pid = client.post("/run/dummy", { "data": 0 }) start = time.time() status = client.post("/process/remove", { "pid": pid }) elapsed = time.time() - start @@ -152,7 +152,7 @@ class TestClient(object): def test_client_05_trainola_simple(self): client = HTTPClient(baseurl = testurl, post_json = True) - pid = client.post("/filter/trainola", { "data": {} }) + pid = client.post("/run/trainola", { "data": {} }) status = self.wait_end(client, pid) ne_(status["exitcode"], 0) status = client.post("/process/remove", { "pid": pid }) @@ -191,7 +191,7 @@ class TestClient(object): } # start trainola - pid = client.post("/filter/trainola", { "data": data }) + pid = client.post("/run/trainola", { "data": data }) # wait for it to finish for i in range(60): @@ -218,7 +218,7 @@ class TestClient(object): eq_(client.get("/process/list"), []) def do(args, kill): - pid = client.post("/process/command", { "args": args } ) + pid = client.post("/run/command", { "args": args } ) eq_(client.get("/process/list"), [pid]) if kill: time.sleep(1)