Add scrobble log option and CLI tool
This commit is contained in:
34
vrobbler/cli.py
Normal file
34
vrobbler/cli.py
Normal file
@ -0,0 +1,34 @@
|
||||
# cli.py
|
||||
import logging
|
||||
import sys
|
||||
from os import environ as env
|
||||
|
||||
|
||||
if not 'DJANGO_SETTINGS_MODULE' in env:
|
||||
from vrobbler import settings
|
||||
env.setdefault('DJANGO_SETTINGS_MODULE', settings.__name__)
|
||||
|
||||
|
||||
import django
|
||||
django.setup()
|
||||
|
||||
# this line must be after django.setup() for logging configure
|
||||
logger = logging.getLogger('vrobbler')
|
||||
|
||||
def main():
|
||||
# to get configured settings
|
||||
from django.conf import settings
|
||||
|
||||
try:
|
||||
from django.core.management import execute_from_command_line
|
||||
except ImportError as exc:
|
||||
raise ImportError(
|
||||
"Couldn't import Django. Are you sure it's installed and "
|
||||
"available on your PYTHONPATH environment variable? Did you "
|
||||
"forget to activate a virtual environment?"
|
||||
) from exc
|
||||
execute_from_command_line(sys.argv)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@ -32,6 +32,12 @@ DEBUG = os.getenv("VROBBLER_DEBUG", False)
|
||||
|
||||
TESTING = len(sys.argv) > 1 and sys.argv[1] == "test"
|
||||
|
||||
KEEP_DETAILED_SCROBBLE_LOGS = os.getenv(
|
||||
"VROBBLER_KEEP_DETAILED_SCROBBLE_LOGS", False
|
||||
)
|
||||
|
||||
DELETE_STALE_SCROBBLES = os.getenv("VROBBLER_DELETE_STALE_SCROBBLES", True)
|
||||
|
||||
TMDB_API_KEY = os.getenv("VROBBLER_TMDB_API_KEY", "")
|
||||
|
||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||
@ -61,7 +67,6 @@ INSTALLED_APPS = [
|
||||
"django_filters",
|
||||
"django_extensions",
|
||||
'rest_framework.authtoken',
|
||||
"vrobbler",
|
||||
"scrobbles",
|
||||
"videos",
|
||||
"rest_framework",
|
||||
|
||||
Reference in New Issue
Block a user