This repository has been archived by the owner on Dec 31, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
web.py -> falcon; progress on python3
- Loading branch information
Showing
25 changed files
with
552 additions
and
557 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
[report] | ||
omit = setup.py | ||
omit = */conftest.py | ||
omit = */suplemon/* | ||
*/conftest.py | ||
*/suplemon/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
.cache | ||
.coverage | ||
.DS_Store | ||
.pytest_cache | ||
.vent | ||
/build/ | ||
dist | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
docker==3.3.0 | ||
elasticsearch==6.2.0 | ||
falcon==1.4.1 | ||
falcon-cors==1.1.7 | ||
npyscreen==4.10.5 | ||
paste==2.0.3 | ||
pika==0.11.2 | ||
pytest==3.6.0 | ||
pytest-cov==2.5.1 | ||
python-magic==0.4.15 | ||
redis==2.10.6 | ||
rq==0.10.0 | ||
sphinx==1.7.5 | ||
urllib3==1.22 | ||
watchdog==0.8.3 | ||
web.py==0.39 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,16 @@ | ||
#!/usr/bin/env python | ||
import docker | ||
import logging | ||
import sys | ||
import web | ||
import falcon | ||
|
||
from rest.create import CreateR | ||
from rest.delete import DeleteR | ||
from rest.nics import NICsR | ||
from rest.nlist import ListR | ||
from rest.start import StartR | ||
from rest.stop import StopR | ||
from rest.update import UpdateR | ||
from falcon_cors import CORS | ||
from .routes import routes | ||
|
||
|
||
module_logger = logging.getLogger(__name__) | ||
cors = CORS(allow_all_origins=True) | ||
api = application = falcon.API(middleware=[cors.middleware]) | ||
|
||
r = routes() | ||
for route in r: | ||
api.add_route(route, r[route]) | ||
|
||
class NControlServer(object): | ||
""" | ||
This class is responsible for initializing the urls and web server. | ||
""" | ||
# need __new__ for tests, but fails to call __init__ when actually running | ||
def __new__(*args, **kw): | ||
if hasattr(sys, '_called_from_test'): | ||
module_logger.info("don't call __init__") | ||
else: # pragma: no cover | ||
return object.__new__(*args, **kw) | ||
|
||
def __init__(self, port=8080, host='0.0.0.0'): # pragma: no cover | ||
d_client = docker.from_env() | ||
d_client.images.pull('cyberreboot/vent-ncapture', tag='master') | ||
nf_inst = NControl() | ||
urls = nf_inst.urls() | ||
app = web.application(urls, globals()) | ||
web.httpserver.runsimple(app.wsgifunc(), (host, port)) | ||
|
||
|
||
class NControl: | ||
""" | ||
This class is for defining things needed to start up. | ||
""" | ||
|
||
@staticmethod | ||
def urls(): | ||
urls = ( | ||
'/create', CreateR, | ||
'/delete', DeleteR, | ||
'/list', ListR, | ||
'/nics', NICsR, | ||
'/start', StartR, | ||
'/stop', StopR, | ||
'/update', UpdateR | ||
) | ||
return urls | ||
|
||
if __name__ == '__main__': | ||
NControlServer().app.run() | ||
d_client = docker.from_env() | ||
d_client.images.pull('cyberreboot/vent-ncapture', tag='master') |
Oops, something went wrong.