diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000000000000000000000000000000000000..a5040abd159bdd7db4b7be8b9954163e2ca7a1f1 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,3 @@ +[run] +source = CLMCservice +omit = CLMCservice/tests.py diff --git a/.gitignore b/.gitignore index 03f004a3b864ac817f2befe33248e8a69d763227..6f782808f63b730ddefab742fbd0c1235e9eb44e 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,7 @@ *egg-info* *git-commit-ref* ubuntu-xenial-16.04-cloudimg-console.log +.idea/ +*.egg +*.pyc +*$py.class diff --git a/CLMCservice/__init__.py b/CLMCservice/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..b87c12fad105695f7dedd72ba0a99b241e80f33c --- /dev/null +++ b/CLMCservice/__init__.py @@ -0,0 +1,10 @@ +from pyramid.config import Configurator + + +def main(global_config, **settings): + """ This function returns a Pyramid WSGI application.""" + + config = Configurator(settings=settings) + config.add_route('home', '/') + config.scan() + return config.make_wsgi_app() diff --git a/CLMCservice/tests.py b/CLMCservice/tests.py new file mode 100644 index 0000000000000000000000000000000000000000..54f2941f7deb62865f5fbbfb939f603d41649e05 --- /dev/null +++ b/CLMCservice/tests.py @@ -0,0 +1 @@ +# Specific tests related to the CLMC service \ No newline at end of file diff --git a/CLMCservice/views.py b/CLMCservice/views.py new file mode 100644 index 0000000000000000000000000000000000000000..10a8d112c7e854dd6031148efdb2345b9f27b10e --- /dev/null +++ b/CLMCservice/views.py @@ -0,0 +1,7 @@ +from pyramid.view import view_config +from pyramid.response import Response + + +@view_config(route_name='home') +def my_view(request): + return Response("Hello world") diff --git a/README.md b/README.md index 0d9dbc763b314984cbd9a9e975e27427f6293b0c..8560bdd01bd1d4ca2aeb4d1d3a70b2efcad68fc5 100644 --- a/README.md +++ b/README.md @@ -119,4 +119,43 @@ If pytest is not installed, an easy solution is to use the Python Package Index `sudo apt-get install python3-pip` -`pip3 install pytest` \ No newline at end of file +`pip3 install pytest` + + +#### CLMC Service + +The CLMC service is implemented using the Pyramid framework. (currently under development) + +Before installing the CLMC service and its dependencies, it is recommended to use a virtual environment. To manage virtual +environments, **virtualenvwrapper** can be used. + +``` +pip install virtualenvwrapper +``` + +To create a virtual environment use the **mkvirtualenv** command: + +``` +mkvirtualenv CLMC +``` + +When created, you should already be set to use the new virtual environment, but to make sure of this use the **workon** command: + +``` +workon CLMC +``` + +Now, any installed libraries will be specificly installed in this environment only. To install and use the CLMC service +locally, the easiest thing to do is to use **pip** (make sure you are in the root folder of the project - ***flame-clmc***): + +``` +pip install -e . +``` + +Finally, start the service on localhost by using pyramid's **pserve**: + +``` +pserve development.ini --reload +``` + +You should now be able to see the 'Hello world' message when visiting **http://localhost:8080** in your browser. \ No newline at end of file diff --git a/development.ini b/development.ini new file mode 100644 index 0000000000000000000000000000000000000000..0d37eed41f6e4abf6db45b22dc6d186af0d77355 --- /dev/null +++ b/development.ini @@ -0,0 +1,59 @@ +### +# app configuration +# https://docs.pylonsproject.org/projects/pyramid/en/latest/narr/environment.html +### + +[app:main] +use = egg:CLMCservice + +pyramid.reload_templates = true +pyramid.debug_authorization = false +pyramid.debug_notfound = false +pyramid.debug_routematch = false +pyramid.default_locale_name = en +pyramid.includes = pyramid_debugtoolbar +aggregator_running = false + +# By default, the toolbar only appears for clients from IP addresses +# '127.0.0.1' and '::1'. +# debugtoolbar.hosts = 127.0.0.1 ::1 + +### +# wsgi server configuration +### + +[server:main] +use = egg:waitress#main +listen = localhost:8080 + +### +# logging configuration +# https://docs.pylonsproject.org/projects/pyramid/en/latest/narr/logging.html +### + +[loggers] +keys = root, CLMCservice + +[handlers] +keys = console + +[formatters] +keys = generic + +[logger_root] +level = INFO +handlers = console + +[logger_CLMCservice] +level = DEBUG +handlers = +qualname = CLMCservice + +[handler_console] +class = StreamHandler +args = (sys.stderr,) +level = NOTSET +formatter = generic + +[formatter_generic] +format = %(asctime)s %(levelname)-5.5s [%(name)s:%(lineno)s][%(threadName)s] %(message)s diff --git a/production.ini b/production.ini new file mode 100644 index 0000000000000000000000000000000000000000..1331c1b6e983ac05d9af3ddd81d3f5918169dd81 --- /dev/null +++ b/production.ini @@ -0,0 +1,53 @@ +### +# app configuration +# https://docs.pylonsproject.org/projects/pyramid/en/latest/narr/environment.html +### + +[app:main] +use = egg:CLMCservice + +pyramid.reload_templates = false +pyramid.debug_authorization = false +pyramid.debug_notfound = false +pyramid.debug_routematch = false +pyramid.default_locale_name = en + +### +# wsgi server configuration +### + +[server:main] +use = egg:waitress#main +listen = *:8080 + +### +# logging configuration +# https://docs.pylonsproject.org/projects/pyramid/en/latest/narr/logging.html +### + +[loggers] +keys = root, CLMCservice + +[handlers] +keys = console + +[formatters] +keys = generic + +[logger_root] +level = WARN +handlers = console + +[logger_CLMCservice] +level = WARN +handlers = +qualname = CLMCservice + +[handler_console] +class = StreamHandler +args = (sys.stderr,) +level = NOTSET +formatter = generic + +[formatter_generic] +format = %(asctime)s %(levelname)-5.5s [%(name)s:%(lineno)s][%(threadName)s] %(message)s diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000000000000000000000000000000000000..d30f667ec5a99c0f58df21f2c653592982fa731c --- /dev/null +++ b/pytest.ini @@ -0,0 +1,3 @@ +[pytest] +testpaths = CLMCservice +python_files = *.py diff --git a/setup.py b/setup.py index f015c18db76b0d92b579006a2d5242beb13b62a6..d715b33d30dfd35c7e4235a263202185398c83d3 100644 --- a/setup.py +++ b/setup.py @@ -21,27 +21,46 @@ // Created for Project : FLAME """ -import os from setuptools import setup, find_packages -def read(fname): - return open(os.path.join(os.path.dirname(__file__), fname)).read() +requires = [ + 'plaster_pastedeploy', + 'pyramid', + 'pyramid_debugtoolbar', + 'waitress', + 'influxdb', +] + +tests_require = [ + 'WebTest >= 1.3.1', # py3 compat + 'pytest', + 'pytest-cov', +] setup( - name = "clmctest", + name = "CLMCservice", version = "SNAPSHOT", author = "Michael Boniface", author_email = "mjb@it-innovation.soton.ac.uk", description = "FLAME CLMC Testing Module", + long_description="long description", license = "license", - keywords = "FLAME CLMC test", + keywords = "FLAME CLMC service test", packages=find_packages(exclude=["services"]), include_package_data=True, - package_data={'': ['git-commit-ref', '*.yml', '*.sh', '*.json', '*.conf']}, - long_description="long description", + install_requires=requires, + extras_require={ + 'testing': tests_require, + }, + package_data={'': ['git-commit-ref', '*.yml', '*.sh', '*.json', '*.conf']}, classifiers=[ "Development Status :: Alpha", "Topic :: FLAME Tests", "License :: ", ], + entry_points={ + 'paste.app_factory': [ + 'main = CLMCservice:main', + ], + }, ) \ No newline at end of file