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