Przeglądaj źródła

make discid a non required dependency

master
Dirk Alders 1 miesiąc temu
rodzic
commit
a9b16a8a72
3 zmienionych plików z 20 dodań i 2 usunięć
  1. 1
    1
      CDDB.py
  2. 15
    1
      common.py
  3. 4
    0
      metadata.py

+ 1
- 1
CDDB.py Wyświetl plik

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

+ 15
- 1
common.py Wyświetl plik

@@ -1,5 +1,19 @@
1 1
 import os
2
-import discid
2
+import logging
3
+
4
+try:
5
+    from config import APP_NAME as ROOT_LOGGER_NAME
6
+except ImportError:
7
+    ROOT_LOGGER_NAME = 'root'
8
+logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
9
+
10
+# make module usable without discid dependency
11
+try:
12
+    import discid
13
+except ModuleNotFoundError:
14
+    logger.warning("Python module discid not installed")
15
+except OSError:
16
+    logger.exception("You might install python3-libdiscid")
3 17
 
4 18
 KEY_ALBUM = 'album'
5 19
 KEY_APERTURE = 'aperture'

+ 4
- 0
metadata.py Wyświetl plik

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

Ładowanie…
Anuluj
Zapisz