Skip to content

Commit fb13b6f

Browse files
committed
catch missing library errors
1 parent 31b11b4 commit fb13b6f

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

Diff for: config.py

+15-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
from configparser import ConfigParser
2+
from shutil import copyfile
23
import logging
3-
import os
44
import math
5-
from shutil import copyfile
5+
import sys
6+
import os
67

78
import utils
89

@@ -117,15 +118,22 @@ def create_config(config_file=None):
117118
BLACK = 0
118119
PAPIRUSROT = 0
119120
if "papirus" in conf["atm"]["display"]:
120-
from papirus import Papirus
121+
try:
122+
from papirus import Papirus
123+
PAPIRUS = Papirus(rotation=PAPIRUSROT)
124+
except ImportError:
125+
logger.warning("Papirus display library not installed.")
126+
sys.exit("Exiting...")
121127

122-
PAPIRUS = Papirus(rotation=PAPIRUSROT)
123128

124129
# Display - Waveshare 2.13 is 250 * 122 pixels
125130
if "waveshare" in conf["atm"]["display"]:
126-
from waveshare_epd import epd2in13_V2
127-
128-
WAVESHARE = epd2in13_V2.EPD()
131+
try:
132+
from waveshare_epd import epd2in13_V2
133+
WAVESHARE = epd2in13_V2.EPD()
134+
except ImportError:
135+
logger.warning("Waveshare display library not installed.")
136+
sys.exit("Exiting...")
129137

130138
# API URL for coingecko
131139
COINGECKO_URL_BASE = "https://api.coingecko.com/api/v3/"

0 commit comments

Comments
 (0)