improvements and QR cards

This commit is contained in:
tilman
2016-12-31 00:42:33 +01:00
parent 09b739621d
commit 5f837d478d
7 changed files with 261 additions and 7 deletions
+6 -6
View File
@@ -17,7 +17,7 @@ SOUND_PLAYBACK_ERROR = "/home/pi/piplayer2/sounds/error.mp3"
QR_SCANNER_TIMEOUT = 3
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s.%(msecs)d %(levelname)s - %(message)s')
logging.basicConfig(level=logging.INFO, format='%(asctime)s.%(msecs)d %(levelname)s - %(message)s')
logging.info('Initializing')
GPIO.setmode(GPIO.BCM)
@@ -101,7 +101,7 @@ try:
try:
qr_code = zbarcam.stdout.readline().rstrip()
qr_code = qr_code.decode("utf-8") # python3
logging.debug("QR Code: {}".format(qr_code))
logging.info("QR Code: {}".format(qr_code))
if (not qr_code.startswith("http://")):
# create full path
@@ -149,15 +149,15 @@ try:
subprocess.check_call(["mocp", "-p"])
except subprocess.CalledProcessError as e:
logging.debug("Error starting playback, mocp returned {}".format(e.returncode))
logging.debug(e.output)
logging.error("Error starting playback, mocp returned {}".format(e.returncode))
logging.error(e.output)
subprocess.call(["mocp", "-l", SOUND_PLAYBACK_ERROR])
except FileNotFoundError as e:
logging.debug("Could not open directory {}".format(directory))
logging.error("Could not open directory {}".format(directory))
subprocess.call(["mocp", "-l", SOUND_PLAYBACK_ERROR])
else:
logging.debug('Timeout on zbarcam')
logging.warning('Timeout on zbarcam')
subprocess.call(["mocp", "-l", SOUND_SCAN_FAIL])
zbarcam.terminate()