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
No related branches found
No related tags found
No related merge requests found
# HOWTO Install and Configure ECCS-2
* `sudo apt install python3-pip chromium chromium-l10n git`
* `pip3 install certifi selenium urllib3 flask flask-jsonpify flask-restful`
* `cd /opt ; git clone https://github.com/malavolti/eccs2.git`
* `cd /opt/eccs2 ; ./eccs2.py`
# Create and configure the ECCS-2 database (not used now)
* `sudo mysql`
* `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;`
* `sudo apt install python3 python3-pip chromium chromium-l10n git`
* `python3 -m pip install --user --upgrade pip virtualenv`
* `python3 -m venv eccs2venv`
* `source eccs2venv/bin/activate` (`deactivate` di exit Virtualenv)
* `python3 -m pip install --upgrade wheel setuptools certifi selenium urllib3 flask flask-jsonpify flask-restful`
* `cd ~ ; git clone https://github.com/malavolti/eccs2.git`
* `cd eccs2 ; ./eccs2.py`
# API
......@@ -29,4 +24,4 @@
# API Development Server
* `cd /opt/eccs2 ; ./api.py`
* `cd ~/eccs2 ; ./api.py`
......@@ -9,6 +9,7 @@ import logging
from logging.handlers import RotatingFileHandler
import re
app = Flask(__name__)
api = Api(app)
......@@ -39,33 +40,51 @@ def getLogger(filename,log_level="DEBUG",path="./"):
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):
def get(self):
app.logger.info("Test Superato!")
app.logger.info("Test Passed!")
return {'test':'It Works!'}
class Checks(Resource):
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]
pretty = 0
status = None
idp = None
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"
date = request.args['date']
if 'pretty' in request.args:
app.logger.info("Parametro 'pretty' inserito")
app.logger.info("'pretty' parameter inserted")
pretty = request.args['pretty']
if 'status' in request.args:
app.logger.info("Parametro 'status' inserito")
app.logger.info("'status' parameter inserted")
status = request.args['status']
if 'idp' in request.args:
app.logger.info("Parametro 'idp' inserito")
app.logger.info("'idp' parameter inserted")
idp = request.args['idp']
app.logger.info(idp)
......@@ -81,6 +100,7 @@ class Checks(Resource):
check_status = check[2].rstrip("\n\r")
if (idp and status):
app.logger.info("Checks for 'idp' and 'status'.")
if (idp == check_idp and status == check_status):
result.append( { 'sp' : check_sp,
'idp' : check_idp,
......@@ -90,6 +110,7 @@ class Checks(Resource):
elif (idp):
#app.logger.info(re.search(".*."+idp+".*.", check_idp, re.IGNORECASE))
#app.logger.info(check_idp))
app.logger.info("Checks for Idp '%s'." % idp)
if (re.search(".*."+idp+".*.", check_idp, re.IGNORECASE)):
result.append( { 'sp' : check_sp,
'idp' : check_idp,
......@@ -97,6 +118,7 @@ class Checks(Resource):
'date': date
} )
elif (status):
app.logger.info("Check for the status '%s'." % status)
if (status == check_status):
result.append( { 'sp' : check_sp,
'idp' : check_idp,
......@@ -104,6 +126,7 @@ class Checks(Resource):
'date': date
} )
else:
app.logger.info("All checks.")
result.append( { 'sp' : check_sp,
'idp' : check_idp,
'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