diff --git a/bin/read.py b/bin/read.py index fcc56dd..3775bdd 100644 --- a/bin/read.py +++ b/bin/read.py @@ -12,7 +12,7 @@ @click.option('--template', required=True, help='template file to parse data with') @click.option('--metadata', required=True, - help='configuration file to annotate data with') + help='metadata file to annotate data with') @click.option('--var', required=False, default="", help='Extra variables for URI generation') @click.option('--drop', required=False, default='no', @@ -35,11 +35,5 @@ def cli(input_file, template, metadata, var, drop): resolver.store_timeseries() -def run(): - app.jinja_env.auto_reload = True - app.config['TEMPLATES_AUTO_RELOAD'] = True - app.run(host=SERVER['host'], port=SERVER['port'], debug=SERVER['debug']) - - if __name__ == '__main__': cli() diff --git a/bin/viewer.py b/bin/viewer.py index 0aeadcc..c91d168 100644 --- a/bin/viewer.py +++ b/bin/viewer.py @@ -1,5 +1,9 @@ +from edam.reader.models.database import recreate_database + from edam import SERVER from edam.viewer.app.views import app +from edam import database_url +import os def run(): @@ -8,5 +12,12 @@ def run(): app.run(host=SERVER['host'], port=SERVER['port'], debug=SERVER['debug']) +def verify_database(): + if database_url.drivername == 'sqlite': + if not os.path.isfile(database_url.database): + recreate_database() + + if __name__ == "__main__": + verify_database() run() diff --git a/edam/viewer/app/views.py b/edam/viewer/app/views.py index 846a2da..566be2a 100755 --- a/edam/viewer/app/views.py +++ b/edam/viewer/app/views.py @@ -155,7 +155,11 @@ def about(): @app.route('/graphs') def graphs(): all_stations = stations() # type: [Station] - metrics = all_stations[0].observable_ids + try: + metrics = all_stations[0].observable_ids + except IndexError: + logger.exception("Exception:") + metrics = [] return render_template('graphs.html', stations=all_stations, metrics=metrics) diff --git a/requirements-dev.txt b/requirements-dev.txt index 7e232e5..93dffc3 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,5 +1,5 @@ pytest==7.1.2 -coverage==6.3.2 +coverage==6.4 pytest-bdd==5.0.0 -pylint==2.13.8 +pylint==2.13.9 vcrpy==4.1.1 \ No newline at end of file