Skip to content

Commit

Permalink
Merge pull request #408 from whipper-team/bugfix/issue-354-eliminate-…
Browse files Browse the repository at this point in the history
…eject-warning

Report eject's failures as logger warnings
  • Loading branch information
JoeLametta authored Oct 21, 2019
2 parents 3b2b732 + e5961ae commit 14fb96e
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 14fb96e

Please sign in to comment.