Skip to content
Snippets Groups Projects
Commit 1b1648a7 authored by Marco Malavolti's avatar Marco Malavolti
Browse files

Moved ECCS-2 into Virtualenv

parent 14d38a88
Branches
Tags
No related merge requests found
# HOWTO Install and Configure ECCS-2 # HOWTO Install and Configure ECCS-2
* `sudo apt install python3-pip chromium chromium-l10n git` * `sudo apt install python3 python3-pip chromium chromium-l10n git`
* `pip3 install certifi selenium urllib3 flask flask-jsonpify flask-restful` * `python3 -m pip install --user --upgrade pip virtualenv`
* `cd /opt ; git clone https://github.com/malavolti/eccs2.git` * `python3 -m venv eccs2venv`
* `cd /opt/eccs2 ; ./eccs2.py` * `source eccs2venv/bin/activate` (`deactivate` di exit Virtualenv)
* `python3 -m pip install --upgrade wheel setuptools certifi selenium urllib3 flask flask-jsonpify flask-restful`
# Create and configure the ECCS-2 database (not used now) * `cd ~ ; git clone https://github.com/malavolti/eccs2.git`
* `sudo mysql` * `cd eccs2 ; ./eccs2.py`
* `CREATE DATABASE eccs2db;`
* `CREATE USER 'eccs2user'@'localhost' IDENTIFIED BY '<password>';`
* `GRANT ALL PRIVILEGES ON eccs2db.* TO 'eccs2user'@'localhost'`
* `SHOW GRANTS FOR 'eccs2user'@'localhost';`
* `FLUSH PRIVILEGES;`
# API # API
...@@ -29,4 +24,4 @@ ...@@ -29,4 +24,4 @@
# API Development Server # API Development Server
* `cd /opt/eccs2 ; ./api.py` * `cd ~/eccs2 ; ./api.py`
...@@ -9,6 +9,7 @@ import logging ...@@ -9,6 +9,7 @@ import logging
from logging.handlers import RotatingFileHandler from logging.handlers import RotatingFileHandler
import re import re
app = Flask(__name__) app = Flask(__name__)
api = Api(app) api = Api(app)
...@@ -39,33 +40,51 @@ def getLogger(filename,log_level="DEBUG",path="./"): ...@@ -39,33 +40,51 @@ def getLogger(filename,log_level="DEBUG",path="./"):
return logger return logger
# Setup Chromium Webdriver
def setup():
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
driver = webdriver.Chrome('chromedriver', chrome_options=chrome_options)
# Configure timeouts
driver.set_page_load_timeout(45)
driver.set_script_timeout(45)
return driver
# /eccs2/test
class Test(Resource): class Test(Resource):
def get(self): def get(self):
app.logger.info("Test Superato!") app.logger.info("Test Passed!")
return {'test':'It Works!'} return {'test':'It Works!'}
class Checks(Resource): class Checks(Resource):
def get(self): def get(self):
app.logger.info("Richiesta 'Checks'") app.logger.info("Request 'Checks'")
file_path = "logs/eccs2checks_2020-02-19.log" file_path = "logs/eccs2checks_2020-02-22.log"
date = PurePath(file_path).parts[-1].split('_')[1].split('.')[0] date = PurePath(file_path).parts[-1].split('_')[1].split('.')[0]
pretty = 0 pretty = 0
status = None status = None
idp = None idp = None
if 'date' in request.args: if 'date' in request.args:
app.logger.info("Parametro 'date' inserito") app.logger.info("'date' parameter inserted")
file_path = "logs/eccs2checks_"+request.args['date']+".log" file_path = "logs/eccs2checks_"+request.args['date']+".log"
date = request.args['date'] date = request.args['date']
if 'pretty' in request.args: if 'pretty' in request.args:
app.logger.info("Parametro 'pretty' inserito") app.logger.info("'pretty' parameter inserted")
pretty = request.args['pretty'] pretty = request.args['pretty']
if 'status' in request.args: if 'status' in request.args:
app.logger.info("Parametro 'status' inserito") app.logger.info("'status' parameter inserted")
status = request.args['status'] status = request.args['status']
if 'idp' in request.args: if 'idp' in request.args:
app.logger.info("Parametro 'idp' inserito") app.logger.info("'idp' parameter inserted")
idp = request.args['idp'] idp = request.args['idp']
app.logger.info(idp) app.logger.info(idp)
...@@ -81,6 +100,7 @@ class Checks(Resource): ...@@ -81,6 +100,7 @@ class Checks(Resource):
check_status = check[2].rstrip("\n\r") check_status = check[2].rstrip("\n\r")
if (idp and status): if (idp and status):
app.logger.info("Checks for 'idp' and 'status'.")
if (idp == check_idp and status == check_status): if (idp == check_idp and status == check_status):
result.append( { 'sp' : check_sp, result.append( { 'sp' : check_sp,
'idp' : check_idp, 'idp' : check_idp,
...@@ -90,6 +110,7 @@ class Checks(Resource): ...@@ -90,6 +110,7 @@ class Checks(Resource):
elif (idp): elif (idp):
#app.logger.info(re.search(".*."+idp+".*.", check_idp, re.IGNORECASE)) #app.logger.info(re.search(".*."+idp+".*.", check_idp, re.IGNORECASE))
#app.logger.info(check_idp)) #app.logger.info(check_idp))
app.logger.info("Checks for Idp '%s'." % idp)
if (re.search(".*."+idp+".*.", check_idp, re.IGNORECASE)): if (re.search(".*."+idp+".*.", check_idp, re.IGNORECASE)):
result.append( { 'sp' : check_sp, result.append( { 'sp' : check_sp,
'idp' : check_idp, 'idp' : check_idp,
...@@ -97,6 +118,7 @@ class Checks(Resource): ...@@ -97,6 +118,7 @@ class Checks(Resource):
'date': date 'date': date
} ) } )
elif (status): elif (status):
app.logger.info("Check for the status '%s'." % status)
if (status == check_status): if (status == check_status):
result.append( { 'sp' : check_sp, result.append( { 'sp' : check_sp,
'idp' : check_idp, 'idp' : check_idp,
...@@ -104,6 +126,7 @@ class Checks(Resource): ...@@ -104,6 +126,7 @@ class Checks(Resource):
'date': date 'date': date
} ) } )
else: else:
app.logger.info("All checks.")
result.append( { 'sp' : check_sp, result.append( { 'sp' : check_sp,
'idp' : check_idp, 'idp' : check_idp,
'status' : check_status, 'status' : check_status,
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment