diff --git a/calcure/__main__.py b/calcure/__main__.py index 1027803..1ce1f3b 100644 --- a/calcure/__main__.py +++ b/calcure/__main__.py @@ -39,7 +39,7 @@ from calcure.translations.en import * -__version__ = "2.8.2" +__version__ = "2.8.3" def read_items_from_user_arguments(screen, user_tasks, user_events, task_saver_csv, event_saver_csv): diff --git a/calcure/configuration.py b/calcure/configuration.py index 44b1614..c37407d 100644 --- a/calcure/configuration.py +++ b/calcure/configuration.py @@ -337,8 +337,8 @@ def read_parameters_from_user_arguments(self): print ('Calcure - version 2.8.2') elif opt in ('-i'): self.USE_PERSIAN_CALENDAR = True - except getopt.GetoptError: - logging.error("Invalid user arguments") + except getopt.GetoptError as e_message: + logging.error("Invalid user arguments. %s", e_message) pass diff --git a/calcure/loaders.py b/calcure/loaders.py index d5b044a..f46a76a 100644 --- a/calcure/loaders.py +++ b/calcure/loaders.py @@ -23,8 +23,8 @@ def create_file(self, filename): with open(filename, "w+", encoding="utf-8") as file: pass return [] - except (FileNotFoundError, NameError): - logging.error("Problem occured trying to create %s.", filename) + except (FileNotFoundError, NameError) as e_message: + logging.error("Problem occured trying to create %s. %s", filename, e_message) return [] def read_file(self, filename): @@ -177,10 +177,10 @@ def load(self): self.holidays.add_item(holiday) except ModuleNotFoundError: - logging.error("Couldn't load holidays. Module holydays is not installed.") + logging.error("Couldn't load holidays. Module holydays is not installed. Try 'pip install holydays'") pass - except (SyntaxError, AttributeError): - logging.error("Couldn't load holidays. Country might be incorrect.") + except (SyntaxError, AttributeError) as e_message: + logging.error("Couldn't load holidays. Country might be incorrect. %s", e_message) pass return self.holidays @@ -198,6 +198,7 @@ def load(self): # Quit if file does not exists: if not os.path.exists(self.abook_file): + logging.warning("Couldn't load birthdays. File. %s does not exist.", self.abook_file) return self.birthdays abook = configparser.ConfigParser() @@ -250,11 +251,11 @@ def read_url(self, path): with urllib.request.urlopen(path) as response: file = io.TextIOWrapper(response, 'utf-8') return self.read_lines(file) - except urllib.error.HTTPError: - logging.error("Failed to load from %s. Probably url is wrong.", path) + except urllib.error.HTTPError as e_message: + logging.error("Failed to load from %s. Probably url is wrong. %s", path, e_message) return "" - except urllib.error.URLError: - logging.error("Failed to load from %s. Probably no internet connection.", path) + except urllib.error.URLError as e_message: + logging.error("Failed to load from %s. Probably no internet connection. %s", path, e_message) return "" def read_resource(self, path): @@ -339,8 +340,9 @@ def load(self): year, month, day, calendar_number) self.user_ics_tasks.add_item(new_task) - except Exception: - logging.error("Failed to parse %s.", filename) + except Exception as e_message: + logging.error("Failed to parse %s. %s", filename, e_message) + return self.user_ics_tasks @@ -400,7 +402,7 @@ def load(self): frequency, status, is_private, calendar_number) self.user_ics_events.add_item(new_event) - except Exception: - logging.error("Failed to parse %s.", filename) + except Exception as e_message: + logging.error("Failed to parse %s. %s", filename, e_message) return self.user_ics_events