Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report eject's failures as logger warnings #408

Merged
merged 1 commit into from
Oct 21, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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