Remove central config file as it's more trouble than it's worth

Simpler and easier for testing to stick to configuration via CLI args.
We'll worry about deployment later.
pull/10/head
Mike Lang 6 years ago committed by Mike Lang
parent 031dd60897
commit 75c9793eac

@ -18,10 +18,3 @@ but a brief overview of the components:
All components are built as docker images. All components are built as docker images.
Components which access the disk expect a shared directory mounted at `/mnt`. Components which access the disk expect a shared directory mounted at `/mnt`.
#### Configuration
Configuration is built into the docker images, and set during build by specifying a
YAML file `config.yaml` in the repository root directory.
See the provided example file for documentation of options.

@ -5,37 +5,16 @@
import datetime import datetime
import dateutil.parser import dateutil.parser
import yaml
class Config(object): def dt_to_bustime(start, dt):
def load(self, """Convert a datetime to bus time. Bus time is seconds since the given start point."""
run_start_time, return (dt - start).total_seconds()
):
# PyYAML tries to...ugh...be clever, and parse timestamps if it can work out how.
# So we should only try to parse if it's not datetime already.
if not isinstance(run_start_time, datetime.datetime):
run_start_time = dateutil.parser.parse(run_start_time)
self.run_start_time = run_start_time
CONF = Config() def bustime_to_dt(start, bustime):
def load_config(path="/etc/wubloader.yaml"):
with open(path) as f:
CONF.load(**yaml.safe_load(f))
def dt_to_bustime(dt):
"""Convert a datetime to bus time. Bus time is seconds since the start of the run
as defined in the config file."""
return (dt - CONF.run_start_time).total_seconds()
def bustime_to_dt(bustime):
"""Convert from bus time to a datetime""" """Convert from bus time to a datetime"""
return CONF.run_start_time + datetime.timedelta(seconds=bustime) return start + datetime.timedelta(seconds=bustime)
def format_bustime(bustime, round="millisecond"): def format_bustime(bustime, round="millisecond"):

@ -1,6 +0,0 @@
# The timestamp of the beginning of the run.
# This defines 00:00 bustime.
# Should be in format YYYY-MM-DD hh:mm:ss.
# Example: 2018-11-09 18:00:00
run_start_time: 1970-01-01 00:00:00

@ -9,7 +9,4 @@ RUN pip install /tmp/common && rm -r /tmp/common
COPY downloader /tmp/downloader COPY downloader /tmp/downloader
RUN pip install /tmp/downloader && rm -r /tmp/downloader RUN pip install /tmp/downloader && rm -r /tmp/downloader
# Add config file last as it changes most ENTRYPOINT python2 -m downloader --base-dir /mnt
COPY config.yaml /etc/wubloader.yaml
CMD python2 -m downloader

Loading…
Cancel
Save