Skip to content
Snippets Groups Projects
Commit d522cf59 authored by David-Leon Pohl's avatar David-Leon Pohl
Browse files

Merge branch 'fix_db' into 'development'

Fix #423

Closes #423

See merge request !395
parents b52aafe6 6d2d94f3
No related branches found
No related tags found
2 merge requests!418Release v1.5.0,!395Fix #423
......@@ -16,7 +16,8 @@ import os
import time
from datetime import datetime
import yaml
import urllib.error, urllib.request
import urllib.request
import urllib.error
import sqlite3
from lxml import html
......@@ -83,10 +84,10 @@ def _cache_rd53a_db(outfile=None, **_):
try:
urllib.request.urlretrieve(uri, outfile)
except urllib.error.HTTPError:
except (urllib.error.HTTPError, urllib.error.URLError):
raise DBUnreachableError('Cannot connect to RD53A database. Are you offline?')
log.info('RD53 database has been cached to {0} in {1:1.3f}s'.format(outfile, time.time() - start_timer))
log.debug('RD53 database has been cached to {0} in {1:1.3f}s'.format(outfile, time.time() - start_timer))
def _get_chip_from_rd53a_db_cache(wafer_no, col, row, infile=None, **_):
......@@ -126,13 +127,13 @@ def _get_chip_from_rd53a_db_cache(wafer_no, col, row, infile=None, **_):
log.error('Cannot find cached version of RD53A database!')
raise DBCacheNotFoundError("No such file: '{0}'".format(infile))
log.info('Reading data from cache file {}'.format(infile))
log.debug('Reading data from cache file {}'.format(infile))
creation_date = os.path.getmtime(infile)
if time.time() - creation_date > (24 * 60 * 60):
log.warning('Cached data is older than 24h, consider creating a new cache. Creation date {}'.format(datetime.fromtimestamp(creation_date)))
elif time.time() - creation_date > 1:
log.info('Cache file was created {}'.format(datetime.fromtimestamp(creation_date)))
log.debug('Cache file was created {}'.format(datetime.fromtimestamp(creation_date)))
cache = sqlite3.connect(infile)
cache.row_factory = dict_factory
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment