From 23e30bf72a0615817d881bcfd3b2ab7b8bd0a6a8 Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Mon, 30 Jan 2012 16:29:22 -0800 Subject: [PATCH] CLI error when log file can't be opened (#326) --- beets/ui/commands.py | 6 +++++- docs/changelog.rst | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/beets/ui/commands.py b/beets/ui/commands.py index 2263db281..41ce671ca 100644 --- a/beets/ui/commands.py +++ b/beets/ui/commands.py @@ -580,7 +580,11 @@ def import_files(lib, paths, copy, write, autot, logpath, art, threaded, # Open the log. if logpath: logpath = normpath(logpath) - logfile = open(syspath(logpath), 'a') + try: + logfile = open(syspath(logpath), 'a') + except IOError: + raise ui.UserError(u"could not open log file for writing: %s" % + displayable_path(logpath)) print >>logfile, 'import started', time.asctime() else: logfile = None diff --git a/docs/changelog.rst b/docs/changelog.rst index 8562391cb..36555bfc9 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -17,6 +17,8 @@ Changelog to "Various Artists". * The ``inline`` plugin now prints a more comprehensible error when exceptions occur in Python snippets. +* A reasonable error message is now shown when the import log file cannot be + opened. * Fix a bug in the ``rewrite`` plugin that broke the use of multiple rules for a single field. * Fix a crash with non-ASCII characters in bytestring metadata fields (e.g., @@ -26,7 +28,6 @@ Changelog * Fix a crash in the ``chroma`` plugin when the Acoustid database had no recording associated with a fingerprint. - 1.0b12 (January 16, 2012) -------------------------