-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
global: migration from GitLab to GitHub
Signed-off-by: Javier Delgado <JavierDelgado@outlook.com>
- Loading branch information
1 parent
3ec218f
commit 20412ad
Showing
18 changed files
with
1,265 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# IDEA files. [0/90] | ||
.idea/ | ||
|
||
# KDevelop files. | ||
.kdev4/ | ||
*.kdev4 | ||
.directory | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
.cache/ | ||
.coverage | ||
|
||
# Databases | ||
*.db | ||
|
||
# Distribution / packaging | ||
.Python | ||
env/ | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
|
||
npm-debug.log |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
language: python | ||
python: | ||
- "3.5" | ||
- "3.5-dev" # 3.5 development branch | ||
- "3.6" | ||
- "3.6-dev" # 3.6 development branch | ||
- "3.7-dev" # 3.7 development branch | ||
- "nightly" # currently points to 3.7-dev | ||
install: "pip install -e .[tests]" | ||
script: "./run-tests.sh" |
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 +1,5 @@ | ||
# selenol-platform | ||
# selenol-platform | ||
|
||
Base system to orchestrate selenol services. | ||
|
||
[![Travis](https://img.shields.io/travis/selenol/selenol-platform.svg)](https://travis-ci.org/selenol/selenol-platform/builds) [![PyPI](https://img.shields.io/pypi/dm/selenol-platform.svg)](https://pypi.python.org/pypi?name=selenol-platform) [![GitHub release](https://img.shields.io/github/release/selenol/selenol-platform.svg)](https://github.com/selenol/selenol-platform) |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
[pytest] | ||
addopts = --pep8 --ignore=docs --cov=selenol_platform --cov-report=term-missing |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env sh | ||
# -*- coding: utf-8 -*- | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
pydocstyle selenol_platform && \ | ||
isort -rc -c -df **/*.py && \ | ||
python setup.py pytest |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
"""Base system to orchestrate selenol services.""" |
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 |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
"""Application module to manage the services.""" | ||
|
||
import click | ||
import pkg_resources | ||
|
||
from selenol_python.persistences import Base, get_engine, session_creator | ||
|
||
from .pool import SelenolPool | ||
|
||
|
||
def load_service_entrypoints(group): | ||
"""Apply the given function to all the service entripoints.""" | ||
return [item.load() for item in | ||
pkg_resources.iter_entry_points(group=group)] | ||
|
||
|
||
@click.group() | ||
def cli_group(): | ||
"""CLI tool.""" | ||
|
||
|
||
@cli_group.group(name='db') | ||
def db_group(): | ||
"""DB related methods.""" | ||
|
||
|
||
@cli_group.group(name='fixtures') | ||
def fixtures_group(): | ||
"""Fixture related methods.""" | ||
|
||
|
||
@fixtures_group.command('create') | ||
@click.option('-c', '--connection', default=None) | ||
def create_fixtures(connection): | ||
"""Create all the fixtures used by the application.""" | ||
session = session_creator(connection) | ||
|
||
for fixture in load_service_entrypoints('selenol.fixtures'): | ||
fixture(session) | ||
|
||
|
||
@db_group.command(name='create') | ||
@click.option('-c', '--connection', default=None) | ||
def create_db(connection): | ||
"""Create all the database base.""" | ||
engine = get_engine(connection) | ||
|
||
load_service_entrypoints('selenol.services') | ||
|
||
Base.metadata.create_all(engine) | ||
|
||
|
||
@cli_group.command() | ||
def run(): | ||
"""Run the service.""" | ||
services = load_service_entrypoints('selenol.services') | ||
pool = SelenolPool(services) | ||
pool.serve() |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
"""Configuration variables.""" | ||
|
||
SELENOL_DEFAULT_DATABASE_CONNECTION = 'sqlite:///database.db' |
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
"""Pool implementation to manage multiple services at the same time.""" | ||
|
||
import logging | ||
from threading import Thread | ||
|
||
|
||
def service_manager(service, connection=None, session=None): | ||
"""Run a service in an infinitive loop until an exception occurs. | ||
:param service: Selenol service to be executed. | ||
:param connection: Selenol backend connection. | ||
:param session: Database session for the service. | ||
""" | ||
try: | ||
process = service(connection, session) | ||
process.run() | ||
except Exception as ex: | ||
logging.exception(ex) | ||
|
||
|
||
class SelenolPool(object): | ||
"""Pool of thread to process services.""" | ||
|
||
def __init__(self, services): | ||
"""Constructor. | ||
:param services: List of services that the pool will manage. | ||
""" | ||
self.services = services | ||
self.processess = [] | ||
|
||
def serve(self): | ||
"""Create all the services and run them in parallel.""" | ||
self.processess = [Thread(target=service_manager, args=[service]) for | ||
service in self.services] | ||
for process in self.processess: | ||
process.start() |
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
"""Setup module.""" | ||
|
||
from setuptools import setup | ||
|
||
setup( | ||
name='selenol-platform', | ||
version='0.1.0', | ||
description='Base system to orchestrate selenol services.', | ||
url='https://github.com/selenol/selenol-platform', | ||
author='Javier Delgado', | ||
author_email='JavierDelgado@outlook.com', | ||
license='GPLv3', | ||
test_suite='tests', | ||
entry_points={ | ||
'console_scripts': [ | ||
'selenol=selenol_platform.cli:cli_group', | ||
], | ||
}, | ||
install_requires=[ | ||
'Click>=6.7', | ||
'selenol-python>=0.1', | ||
'sqlalchemy>=1.1.9', | ||
], | ||
packages=['selenol_platform'], | ||
extras_require={ | ||
'tests': [ | ||
'coverage>=4.0', | ||
'isort>=4.2.5', | ||
'pytest>=3.0.7', | ||
'pydocstyle>=1.1.1', | ||
'pytest-cache>=1.0', | ||
'pytest-cov>=2.4.0', | ||
'pytest-pep8>=1.0.6', | ||
'pytest-runner>=2.11.1', | ||
], | ||
}, | ||
) |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
"""Conftest module.""" |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
"""Demo service implementation.""" |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
"""Demo fixture.""" | ||
|
||
from .models import TestTable | ||
|
||
|
||
def create_test(session): | ||
"""Demo fixture.""" | ||
session.add(TestTable(test="ThisIsATest")) | ||
session.commit() |
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
"""Demo service model declaration.""" | ||
|
||
from sqlalchemy import Column, Integer, Text | ||
|
||
from selenol_python.persistences import Base | ||
|
||
|
||
class TestTable(Base): | ||
"""Test table.""" | ||
__tablename__ = 'test_table' | ||
|
||
id = Column(Integer, primary_key=True) | ||
|
||
test = Column(Text) |
Oops, something went wrong.