From 15d74fb50f32d3dcf10c4d48bb04247dceb7a48d Mon Sep 17 00:00:00 2001 From: Michael Madsen Date: Sat, 11 Oct 2014 19:49:00 +0200 Subject: [PATCH] Ignore IOErrors when checking for already installed files --- core/helpers.py | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/core/helpers.py b/core/helpers.py index 3f52545..77358d4 100644 --- a/core/helpers.py +++ b/core/helpers.py @@ -42,21 +42,30 @@ def get_text_files(directory): def detect_installed_file(current_file, test_files): """Returns the file in which is contained in , or "Unknown".""" - current = open(current_file).read() - for f in test_files: - tested = open(f).read() - if tested in current: - return f + try: + current = open(current_file).read() + for f in test_files: + tested = open(f).read() + if tested in current: + return f + except IOError: + pass return "Unknown" def detect_installed_files(current_file, test_files): """Returns a list of files in that are contained in .""" - current = open(current_file).read() installed = [] - for f in test_files: - tested = open(f).read() - if tested in current: - installed.append(f) + try: + current = open(current_file).read() + for f in test_files: + try: + tested = open(f).read() + if tested in current: + installed.append(f) + except IOError: + pass + except IOError: + pass return installed