mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
config.json is now settings.json, closes #1104
This commit is contained in:
parent
2a3d5b720b
commit
33eadb8782
5 changed files with 30 additions and 9 deletions
|
|
@ -45,6 +45,7 @@ from .database import Database, QueryInterrupted
|
|||
|
||||
from .utils import (
|
||||
PrefixedUrlString,
|
||||
StartupError,
|
||||
async_call_with_supported_arguments,
|
||||
await_me_maybe,
|
||||
call_with_supported_arguments,
|
||||
|
|
@ -265,8 +266,10 @@ class Datasette:
|
|||
if config_dir and (config_dir / "static").is_dir() and not static_mounts:
|
||||
static_mounts = [("static", str((config_dir / "static").resolve()))]
|
||||
self.static_mounts = static_mounts or []
|
||||
if config_dir and (config_dir / "config.json").exists() and not config:
|
||||
config = json.load((config_dir / "config.json").open())
|
||||
if config_dir and (config_dir / "config.json").exists():
|
||||
raise StartupError("config.json should be renamed to settings.json")
|
||||
if config_dir and (config_dir / "settings.json").exists() and not config:
|
||||
config = json.load((config_dir / "settings.json").open())
|
||||
self._config = dict(DEFAULT_CONFIG, **(config or {}))
|
||||
self.renderers = {} # File extension -> (renderer, can_render) functions
|
||||
self.version_note = version_note
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ from runpy import run_module
|
|||
import webbrowser
|
||||
from .app import Datasette, DEFAULT_CONFIG, CONFIG_OPTIONS, pm
|
||||
from .utils import (
|
||||
StartupError,
|
||||
check_connection,
|
||||
parse_metadata,
|
||||
ConnectionProblem,
|
||||
|
|
@ -488,6 +489,8 @@ def serve(
|
|||
ds = Datasette(files, **kwargs)
|
||||
except SpatialiteNotFound:
|
||||
raise click.ClickException("Could not find SpatiaLite extension")
|
||||
except StartupError as e:
|
||||
raise click.ClickException(e.args[0])
|
||||
|
||||
if return_instance:
|
||||
# Private utility mechanism for writing unit tests
|
||||
|
|
|
|||
|
|
@ -1027,3 +1027,7 @@ class PrefixedUrlString(str):
|
|||
return method.__get__(self)
|
||||
else:
|
||||
return super().__getattribute__(name)
|
||||
|
||||
|
||||
class StartupError(Exception):
|
||||
pass
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue