diff options
| author | Terry Truong <terry06890@gmail.com> | 2023-02-05 13:55:00 +1100 |
|---|---|---|
| committer | Terry Truong <terry06890@gmail.com> | 2023-02-05 13:55:00 +1100 |
| commit | ff638e269d439c853b5182b68ff10777f12597f1 (patch) | |
| tree | 2cc62068a501884821969b6ebeba3686df8f4044 /backend/chrona.py | |
| parent | cc79c17fbc05bddc8b08f2734e721bc241123a4e (diff) | |
Use relative imports between data generation scriptspackage-imports
Avoids the need for code that modifies sys.path, but requires
running of the scripts using 'python -m' with backend/ as cwd.
Also expects constants like DB_FILE to be non-relative, due to
running from backend/.
Diffstat (limited to 'backend/chrona.py')
| -rwxr-xr-x | backend/chrona.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/backend/chrona.py b/backend/chrona.py index e107d1c..c327693 100755 --- a/backend/chrona.py +++ b/backend/chrona.py @@ -24,6 +24,7 @@ Expected HTTP query parameters: from typing import Iterable, cast import sys +import os import re import urllib.parse import sqlite3 @@ -32,7 +33,8 @@ import jsonpickle from hist_data.cal import HistDate, dbDateToHistDate, dateToUnit -DB_FILE = 'hist_data/data.db' +DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'hist_data') +DB_FILE = os.path.join(DATA_DIR, 'data.db') MAX_REQ_EVENTS = 2000 MAX_REQ_UNIT_COUNTS = MAX_REQ_EVENTS DEFAULT_REQ_EVENTS = 20 |
