From: Juergen Spitzmueller Date: Sat, 28 Oct 2017 09:24:48 +0000 (+0200) Subject: configure.py: Be more explicit why file could not be removed. X-Git-Tag: lyx-2.4.0dev-acb2ca7b~4420 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=5383b67f8d077230897640feab8fc94864dab9db;p=lyx.git configure.py: Be more explicit why file could not be removed. --- diff --git a/lib/configure.py b/lib/configure.py index 2d9189888e..f13dcbe711 100644 --- a/lib/configure.py +++ b/lib/configure.py @@ -9,7 +9,7 @@ # Full author contact details are available in file CREDITS. from __future__ import print_function -import glob, logging, os, re, shutil, subprocess, sys, stat +import glob, logging, os, errno, re, shutil, subprocess, sys, stat # set up logging logging.basicConfig(level = logging.DEBUG, @@ -52,8 +52,13 @@ def removeFiles(filenames): try: os.remove(file) logger.debug('Removing file %s' % file) - except: - logger.debug('Failed to remove file %s' % file) + except OSError as e: + if e.errno == errno.ENOENT: # no such file or directory + logger.debug('No need to remove file %s (it does not exists)' % file) + elif e.errno == errno.EISDIR: # is a directory + logger.debug('Failed to remove file %s (it is a directory)' % file) + else: + logger.debug('Failed to remove file %s' % file) pass