fixing test env

This commit is contained in:
evilchili
2022-12-21 22:27:30 -08:00
parent 41a21671ca
commit 6b53b11f0e
6 changed files with 42 additions and 61 deletions
+32 -28
View File
@@ -19,6 +19,36 @@ from groove.webserver import webserver
from groove.exceptions import ConfigurationError
from groove.console import Console
SETUP_HELP = """
Please make sure you set MEDIA_ROOT and SECRET_KEY in your environment.
By default, Groove on Demand will attempt to load these variables from
~/.groove, which may contain the following variables as well. See also
the --env paramter.
# Set this one. The path containing your media files
MEDIA_ROOT=
# the kinds of files to import
# MEDIA_GLOB=*.mp3,*.flac,*.m4a
# where to store the groove_on_demand.db sqlite database.
# DATABASE_PATH=~
# Try 'groove themes' to see a list of available themes.
# DEFAULT_THEME=blue_train
# Web interface configuration
# HOST=127.0.0.1
# PORT=2323
# Set this to a suitably random string.
SECRET_KEY=much secret very private
# Console configuration
# EDITOR=
# CONSOLE_WIDTH=auto
"""
app = typer.Typer()
@@ -47,7 +77,7 @@ def main(
groove.path.themes_root()
groove.path.database()
except ConfigurationError as e:
sys.stderr.write(f'{e}\n')
sys.stderr.write(f'{e}\n\n{SETUP_HELP}')
sys.exit(1)
@@ -60,33 +90,7 @@ def setup(context: typer.Context):
"""
Interactive setup is not yet available. Sorry!
In the mean time, please make sure you set MEDIA_ROOT and SECRET_KEY
in your environment. By default, Groove on Demand will attempt to load
these variables from ~/.groove, which may contain the following
variables as well. See also the --env paramter.
# Set this one. The path containing your media files
MEDIA_ROOT=
# the kinds of files to import
# MEDIA_GLOB=*.mp3,*.flac,*.m4a
# where to store the groove_on_demand.db sqlite database.
# DATABASE_PATH=~
# Try 'groove themes' to see a list of available themes.
# DEFAULT_THEME=blue_train
# Web interface configuration
# HOST=127.0.0.1
# PORT=2323
# Set this to a suitably random string.
SECRET_KEY=much secret very private
# Console configuration
# EDITOR=
# CONSOLE_WIDTH=auto
{SETUP_HELP}
"""
))
+2 -10
View File
@@ -9,15 +9,7 @@ _reinstall_hint = "You might need to reinstall Groove On Demand to fix this erro
def root():
path = os.environ.get('GROOVE_ON_DEMAND_ROOT', None)
if not path:
raise ConfigurationError(f"GROOVE_ON_DEMAND_ROOT is not defined in your environment.\n{_setup_hint}")
path = Path(path).expanduser()
if not path.exists() or not path.is_dir():
raise ConfigurationError(
"The Groove on Demand root directory (GROOVE_ON_DEMAND_ROOT) "
f"does not exist or isn't a directory.\n\n{_reinstall_hint}"
)
path = Path(__file__).parent.parent
logging.debug(f"Root is {path}")
return Path(path)
@@ -43,12 +35,12 @@ def media(relpath):
def static_root():
dirname = os.environ.get('STATIC_PATH', 'static')
path = root() / Path(dirname)
logging.debug(f"Static root is {path}")
if not path.exists() or not path.is_dir():
raise ConfigurationError( # pragma: no cover
f"The static assets directory {dirname} (STATIC_PATH) "
f"doesn't exist, or isn't a directory.\n\n{_reinstall_hint}"
)
logging.debug(f"Static root is {path}")
return path