make discid a non required dependency

This commit is contained in:
Dirk Alders 2024-10-10 23:31:27 +02:00
parent 402e837551
commit a9b16a8a72
3 changed files with 20 additions and 2 deletions

View File

@ -18,7 +18,7 @@ version = 2.0
if 'EMAIL' in os.environ:
(default_user, hostname) = os.environ['EMAIL'].split('@')
else:
default_user = os.environ['USER'] or os.geteuid() or 'user'
default_user = os.environ.get('USER') or os.geteuid() or 'user'
hostname = socket.gethostname() or 'host'
proto = 6

View File

@ -1,5 +1,19 @@
import os
import logging
try:
from config import APP_NAME as ROOT_LOGGER_NAME
except ImportError:
ROOT_LOGGER_NAME = 'root'
logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
# make module usable without discid dependency
try:
import discid
except ModuleNotFoundError:
logger.warning("Python module discid not installed")
except OSError:
logger.exception("You might install python3-libdiscid")
KEY_ALBUM = 'album'
KEY_APERTURE = 'aperture'

View File

@ -14,8 +14,12 @@ try:
except ImportError:
ROOT_LOGGER_NAME = 'root'
logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
# make module usable without discid dependency
try:
import discid
except ModuleNotFoundError:
logger.warning("Python module discid not installed")
except OSError:
logger.exception("You might install python3-libdiscid")