Compare commits
2 Commits
nilmrun-1.
...
nilmrun-1.
Author | SHA1 | Date | |
---|---|---|---|
18d3cff772 | |||
a7b9656916 |
@@ -21,13 +21,13 @@ arbitrary commands.
|
||||
SSLEngine On
|
||||
|
||||
WSGIScriptAlias /nilmrun /home/nilm/nilmrun.wsgi
|
||||
WSGIApplicationGroup nilmrun-appgroup
|
||||
WSGIProcessGroup nilmrun-procgroup
|
||||
WSGIDaemonProcess nilmrun-procgroup threads=32 user=nilm group=nilm
|
||||
<Location /nilmrun>
|
||||
WSGIApplicationGroup nilmrun-appgroup
|
||||
SSLRequireSSL
|
||||
|
||||
# Access control example:
|
||||
<Location /nilmrun>
|
||||
SSLRequireSSL
|
||||
Order deny,allow
|
||||
Deny from all
|
||||
Allow from 1.2.3.4
|
||||
|
@@ -40,7 +40,6 @@ class LogReceiver(object):
|
||||
class Process(object):
|
||||
"""Spawn and manage a process that calls a Python function"""
|
||||
def __init__(self, name, function, parameters):
|
||||
self.parameters = parameters
|
||||
self.start_time = None
|
||||
self.name = name
|
||||
|
||||
|
@@ -68,7 +68,6 @@ class AppProcess(object):
|
||||
"exitcode": self.manager[pid].exitcode,
|
||||
"name": self.manager[pid].name,
|
||||
"start_time": self.manager[pid].start_time,
|
||||
"parameters": self.manager[pid].parameters,
|
||||
"log": self.manager[pid].log,
|
||||
}
|
||||
|
||||
|
@@ -104,8 +104,7 @@ class TestClient(object):
|
||||
|
||||
# Verify that status looks OK
|
||||
status = client.get("/process/status", { "pid": pid, "clear": True })
|
||||
for x in [ "pid", "alive", "exitcode", "name",
|
||||
"start_time", "parameters", "log" ]:
|
||||
for x in [ "pid", "alive", "exitcode", "name", "start_time", "log" ]:
|
||||
in_(x, status)
|
||||
in_("dummy 0\ndummy 1\ndummy 2\ndummy 3\n", status["log"])
|
||||
eq_(status["alive"], True)
|
||||
@@ -165,19 +164,11 @@ class TestClient(object):
|
||||
eq_(status["alive"], False)
|
||||
ne_(status["exitcode"], 0)
|
||||
|
||||
@unittest.skip("trainola moving to nilmtools")
|
||||
def test_client_05_trainola_simple(self):
|
||||
client = HTTPClient(baseurl = testurl, post_json = True)
|
||||
pid = client.post("/run/trainola", { "data": {} })
|
||||
status = self.wait_end(client, pid, remove = False)
|
||||
ne_(status["exitcode"], 0)
|
||||
status = client.post("/process/remove", { "pid": pid })
|
||||
|
||||
@unittest.skip("needs a running nilmdb; trainola moved to nilmtools")
|
||||
def test_client_06_trainola(self):
|
||||
def test_client_05_trainola(self):
|
||||
client = HTTPClient(baseurl = testurl, post_json = True)
|
||||
|
||||
data = { "url": "http://bucket.mit.edu/nilmdb",
|
||||
"dest_stream": "/sharon/prep-a-matches",
|
||||
"stream": "/sharon/prep-a",
|
||||
"start": 1366111383280463,
|
||||
"end": 1366126163457797,
|
||||
@@ -190,6 +181,7 @@ class TestClient(object):
|
||||
"stream": "/sharon/prep-a",
|
||||
"start": 1366260494269078,
|
||||
"end": 1366260608185031,
|
||||
"dest_column": 0,
|
||||
"columns": [ { "name": "P1", "index": 0 },
|
||||
{ "name": "Q1", "index": 1 }
|
||||
]
|
||||
@@ -199,37 +191,26 @@ class TestClient(object):
|
||||
"stream": "/sharon/prep-a",
|
||||
"start": 1366260864215764,
|
||||
"end": 1366260870882998,
|
||||
"dest_column": 1,
|
||||
"columns": [ { "name": "P1", "index": 0 },
|
||||
{ "name": "Q1", "index": 1 }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
# start trainola
|
||||
pid = client.post("/run/trainola", { "data": data })
|
||||
|
||||
# wait for it to finish
|
||||
for i in range(60):
|
||||
time.sleep(1)
|
||||
if i == 2:
|
||||
status = client.get("/process/status", { "pid": pid,
|
||||
"clear": True })
|
||||
in_("Loading stream data", status['log'])
|
||||
elif i == 3:
|
||||
status = client.get("/process/status", { "pid": pid })
|
||||
nin_("Loading stream data", status['log'])
|
||||
else:
|
||||
status = client.get("/process/status", { "pid": pid })
|
||||
pid = client.post("/run/code", { "code": "import nilmtools.trainola\n" +
|
||||
"nilmtools.trainola.main()",
|
||||
"args": [ data ] })
|
||||
while True:
|
||||
status = client.get("/process/status", { "pid": pid, "clear": 1 })
|
||||
sys.stdout.write(status["log"])
|
||||
sys.stdout.flush()
|
||||
if status["alive"] == False:
|
||||
break
|
||||
else:
|
||||
client.post("/process/remove", {"pid": pid })
|
||||
raise AssertionError("took too long")
|
||||
if i < 3:
|
||||
raise AssertionError("too fast?")
|
||||
status = client.post("/process/remove", { "pid": pid })
|
||||
os._exit(int(status["exitcode"]))
|
||||
|
||||
def test_client_07_run_command(self):
|
||||
def test_client_06_run_command(self):
|
||||
client = HTTPClient(baseurl = testurl, post_json = True)
|
||||
eq_(client.get("/process/list"), [])
|
||||
|
||||
@@ -258,7 +239,7 @@ class TestClient(object):
|
||||
status = do(["sleep", "60"], True)
|
||||
ne_(status["exitcode"], 0)
|
||||
|
||||
def test_client_08_run_code(self):
|
||||
def test_client_07_run_code(self):
|
||||
client = HTTPClient(baseurl = testurl, post_json = True)
|
||||
eq_(client.get("/process/list"), [])
|
||||
|
||||
|
Reference in New Issue
Block a user