Skip to content

Commit

Permalink
Adding more detailed logging
Browse files Browse the repository at this point in the history
  • Loading branch information
anufrievroman committed Mar 9, 2023
1 parent 83b81c0 commit 3197e10
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion calcure/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions calcure/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
28 changes: 15 additions & 13 deletions calcure/loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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

Expand All @@ -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()
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -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

0 comments on commit 3197e10

Please sign in to comment.