Skip to content

Commit

Permalink
Report eject's failures as logger warnings
Browse files Browse the repository at this point in the history
If the eject command exits with an error, the output is logged as a WARNING. I don't think it's a good idea to mask those errors.

Closes #354.

Signed-off-by: JoeLametta <[email protected]>
  • Loading branch information
JoeLametta committed Jul 7, 2019
1 parent 57d386e commit e5961ae
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions whipper/program/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import subprocess

import logging
logger = logging.getLogger(__name__)
Expand All @@ -9,15 +10,26 @@ def eject_device(device):
Eject the given device.
"""
logger.debug("ejecting device %s", device)
os.system('eject %s' % device)
try:
# `eject device` prints nothing to stdout
subprocess.check_output(['eject', device], stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
logger.warning(e.cmd, 'returned with exit code: ', e.returncode,
e.output)


def load_device(device):
"""
Load the given device.
"""
logger.debug("loading (eject -t) device %s", device)
os.system('eject -t %s' % device)
try:
# `eject -t device` prints nothing to stdout
subprocess.check_output(['eject', '-t', device],
stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
logger.warning(e.cmd, 'returned with exit code: ', e.returncode,
e.output)


def unmount_device(device):
Expand Down

0 comments on commit e5961ae

Please sign in to comment.