Changed when we download a fresh copy of the ROAR scenario index.

master
Pacman Ghost 5 years ago
parent 5d34c52b66
commit 5f3a89345a
  1. 10
      vasl_templates/webapp/__init__.py
  2. 8
      vasl_templates/webapp/roar.py

@ -37,10 +37,6 @@ def _on_startup():
from vasl_templates.webapp.main import startup_msg_store #pylint: disable=cyclic-import
load_vo_notes( startup_msg_store )
# initialize ROAR integration
from vasl_templates.webapp.roar import init_roar #pylint: disable=cyclic-import
init_roar( startup_msg_store )
# ---------------------------------------------------------------------
def _load_config( fname, section ):
@ -108,5 +104,11 @@ if app.config.get( "ENABLE_REMOTE_TEST_CONTROL" ):
# install our signal handler (must be done in the main thread)
signal.signal( signal.SIGINT, _on_sigint )
# initialize ROAR integration
# NOTE: We do this here, rather in _on_startup(), so that we can start downloading the latest scenario index file
# without having to wait for the first request (e.g. if we are running as a standalone server, not the desktop app).
from vasl_templates.webapp.roar import init_roar
init_roar()
# register startup initialization
app.before_first_request( _on_startup )

@ -24,9 +24,13 @@ CACHE_TTL = 6 * 60*60
# ---------------------------------------------------------------------
def init_roar( msg_store ):
def init_roar():
"""Initialize ROAR integration."""
# initialize
from vasl_templates.webapp.main import startup_msg_store
msg_store = startup_msg_store
# initialize
download = True
cache_fname = os.path.join( tempfile.gettempdir(), "vasl-templates.roar-scenario-index.json" )
@ -45,7 +49,7 @@ def init_roar( msg_store ):
age = int( time.time() - mtime )
_logger.debug( "Cached scenario index age: %s (ttl=%s) (mtime=%s)",
datetime.timedelta(seconds=age), datetime.timedelta(seconds=CACHE_TTL),
time.strftime( "%Y-%m-%d %H:%M:%S", time.gmtime(mtime) )
time.strftime( "%Y-%m-%d %H:%M:%S", time.localtime(mtime) )
)
if age < CACHE_TTL:
download = False

Loading…
Cancel
Save