Commit 9515580434f7fff75a847453637f40396e695e2c

Authored by hitier
1 parent 846ddeb5
Exists in rhitier-dev

Reformat code

Showing 1 changed file with 10 additions and 9 deletions   Show diff stats
web/run.py
... ... @@ -29,13 +29,13 @@ from flask import url_for, send_from_directory, abort as abort_flask
29 29 from jinja2 import Environment, FileSystemLoader
30 30 from jinja2.utils import markupsafe
31 31 from yaml import load as yaml_load, dump
  32 +
32 33 try:
33 34 from yaml import CLoader as Loader
34 35 except ImportError:
35 36 from yaml import Loader
36 37 from netCDF4 import Dataset, date2num
37 38  
38   -
39 39 # PATH RELATIVITY #############################################################
40 40  
41 41 THIS_DIRECTORY = dirname(abspath(__file__))
... ... @@ -242,6 +242,7 @@ def escapejs_filter(value):
242 242  
243 243 return markupsafe.Markup("".join(escaped))
244 244  
  245 +
245 246 tpl_engine = Environment(loader=FileSystemLoader([get_path('view')]),
246 247 trim_blocks=True,
247 248 lstrip_blocks=True)
... ... @@ -339,6 +340,7 @@ def datetime_from_list(time_list):
339 340 "%Y%j%H%M%S%f"
340 341 )
341 342  
  343 +
342 344 # Override these using the model configuration in config.yml
343 345 default_nc_keys = {
344 346 'hee': 'HEE',
... ... @@ -350,6 +352,7 @@ default_nc_keys = {
350 352 'atse': 'Delta_angle',
351 353 }
352 354  
  355 +
353 356 def _sta_sto(_cnf, _sta, _sto):
354 357 if 'started_at' in _cnf:
355 358 _s0 = datetime.datetime.strptime(_cnf['started_at'], FILE_DATE_FMT)
... ... @@ -493,11 +496,11 @@ ORDER BY time_min, granule_gid
493 496 jday_start=timestamp_to_jday(t_started_at),
494 497 jday_stop=timestamp_to_jday(t_stopped_at)
495 498 )
496   -# AND processing_level = 4
  499 + # AND processing_level = 4
497 500  
498   -# query = """
499   -# SELECT DISTINCT target_name FROM apis.epn_core
500   -# """
  501 + # query = """
  502 + # SELECT DISTINCT target_name FROM apis.epn_core
  503 + # """
501 504  
502 505 try:
503 506 response = requests.post(api_url, {
... ... @@ -523,7 +526,6 @@ ORDER BY time_min, granule_gid
523 526 'external_link': row[3].text,
524 527 })
525 528  
526   -
527 529 return rows
528 530 except Exception as e:
529 531 print("Failed to retrieve auroral emissions :")
... ... @@ -690,7 +692,6 @@ def get_data_for_target(target_config, input_slug,
690 692 # abort(500, "Invalid orbit configuration for '%s' : %s"
691 693 # % (target_config['slug'], str(e)))
692 694  
693   -
694 695 precision = "%Y-%m-%dT%H" # model and orbits times are only equal-ish
695 696 orbit_data = {} # keys are datetime as str, values arrays of XY
696 697  
... ... @@ -1642,7 +1643,7 @@ def cache_clear():
1642 1643 removed_files = remove_all_files(CACHE_DIR)
1643 1644 count = len(removed_files)
1644 1645 return "Cache cleared! Removed %d file%s." \
1645   - % (count, 's' if count != 1 else '')
  1646 + % (count, 's' if count != 1 else '')
1646 1647  
1647 1648  
1648 1649 @app.route("/cache/cleanup")
... ... @@ -1655,7 +1656,7 @@ def cache_cleanup():
1655 1656 removed_files = remove_files_created_before(a_month_ago, CACHE_DIR)
1656 1657 count = len(removed_files)
1657 1658 return "Cache cleaned! Removed %d old file%s." \
1658   - % (count, 's' if count != 1 else '')
  1659 + % (count, 's' if count != 1 else '')
1659 1660  
1660 1661  
1661 1662 @app.route("/cache/warmup")
... ...