comparison weather_server/locations.py @ 9:f1ea183d28ba

Give a 404 rather than a 500 on missing locations.
author Paul Fisher <paul@pfish.zone>
date Sun, 29 Sep 2019 20:34:38 -0400
parents f66df122f18d
children beb42c835c52
comparison
equal deleted inserted replaced
8:d54155a199d8 9:f1ea183d28ba
45 return tuple(sorted(f.name for f in self._path.iterdir())) 45 return tuple(sorted(f.name for f in self._path.iterdir()))
46 46
47 def get(self, name) -> t.Tuple[LocationInfo, logfile.Logger]: 47 def get(self, name) -> t.Tuple[LocationInfo, logfile.Logger]:
48 try: 48 try:
49 directory = self._path / name 49 directory = self._path / name
50 return ( 50 logger = logfile.Logger.create(str(directory / LOG))
51 LocationInfo.load(directory / CONFIG_FILE), 51 return (LocationInfo.load(directory / CONFIG_FILE), logger)
52 logfile.Logger.create(str(directory / LOG)))
53 except OSError: 52 except OSError:
54 raise KeyError(name) 53 raise KeyError(name)