Skip to content

Commit

Permalink
fix(data directory): added base path to data folder
Browse files Browse the repository at this point in the history
  • Loading branch information
timreibe committed Jun 2, 2021
1 parent d1443a9 commit 4a9be58
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 28 deletions.
2 changes: 1 addition & 1 deletion gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def __init__(self, pfad_fenster_layout: str = os.path.join(PATH, "tools/gui/main

super().__init__()

create_missing_dirs()
create_missing_dirs(PATH)

# Laden der .ui Datei und Anpassungen
uic.loadUi(pfad_fenster_layout, self)
Expand Down
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ def validate_args(args):


def main():
create_missing_dirs()
create_missing_dirs(PATH)

parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers(help="commands", dest="command")
Expand Down
55 changes: 29 additions & 26 deletions tools/utils.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import os
import time
import traceback
import requests
from json import JSONDecodeError
from pathlib import Path

from threading import Thread

import requests
from plyer import notification
from tools.exceptions import DesktopNotificationError
from json import JSONDecodeError
from requests.exceptions import ReadTimeout, ConnectionError, ConnectTimeout

from tools.exceptions import DesktopNotificationError


def retry_on_failure(retries=10):
"""Decorator zum Errorhandling beim Ausführen einer Methode im Loop.
Expand Down Expand Up @@ -85,33 +87,34 @@ def remove_prefix(text, prefix):
return text


def desktop_notification(operating_system:str, title: str, message: str):
"""
Starts a thread and creates a desktop notification using plyer.notification
"""

if 'windows' not in operating_system:
return

try:
Thread(target=notification.notify(
app_name="Impfterminservice",
title=title,
message=message)
).start()
except Exception as exc:
raise DesktopNotificationError(
"Error in _desktop_notification: " + str(exc.__class__.__name__)
+ traceback.format_exc()
) from exc

def create_missing_dirs():
def desktop_notification(operating_system: str, title: str, message: str):
"""
Starts a thread and creates a desktop notification using plyer.notification
"""

if 'windows' not in operating_system:
return

try:
Thread(target=notification.notify(
app_name="Impfterminservice",
title=title,
message=message)
).start()
except Exception as exc:
raise DesktopNotificationError(
"Error in _desktop_notification: " + str(exc.__class__.__name__)
+ traceback.format_exc()
) from exc


def create_missing_dirs(base_path):
"""
Erstellt benötigte Ordner, falls sie fehlen:
- ./data
"""
Path("./data").mkdir(parents=True, exist_ok=True)
Path(os.path.join(base_path, "data")).mkdir(parents=True, exist_ok=True)


def get_grouped_impfzentren() -> dict:
Expand Down

0 comments on commit 4a9be58

Please sign in to comment.