Skip to content

Commit

Permalink
fix: fix behaviour when server already running
Browse files Browse the repository at this point in the history
Signed-off-by: Sylvain Leclerc <[email protected]>
  • Loading branch information
sylvlecl committed Oct 1, 2024
1 parent a0e1268 commit 92c76ce
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
24 changes: 14 additions & 10 deletions antarest/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,17 +137,18 @@ def wait_for_server_start() -> None:
time.sleep(1)


def notification_popup(message: str) -> None:
def notification_popup(message: str, threaded: bool = True) -> None:
if platform.system() == "Windows":
# noinspection PyPackageRequirements
from windows_toasts import Toast, ToastDisplayImage, WindowsToaster # type: ignore

toaster = WindowsToaster("AntaresWebServer")
toast = Toast()
toast.text_fields = [message]
icon = ToastDisplayImage.fromPath(str(RESOURCE_PATH / "webapp" / "favicon.ico"))
toast.AddImage(icon)
toaster.show_toast(toast)
from win10toast import ToastNotifier # type: ignore

toaster = ToastNotifier()
toaster.show_toast(
"AntaresWebServer",
message,
icon_path=RESOURCE_PATH / "webapp" / "favicon.ico",
threaded=threaded,
)
else:
from plyer import notification # type: ignore

Expand All @@ -165,7 +166,10 @@ def main() -> None:

arguments = parse_arguments()
if check_server_started():
notification_popup("Antares Web Server already started, you can manage the application within the system tray.")
notification_popup(
"Antares Web Server already running, you can manage the application within the system tray.", threaded=False
)
return
notification_popup("Starting Antares Web Server...")
systray_app = create_systray_app()
server = start_server(arguments.config_file)
Expand Down
2 changes: 1 addition & 1 deletion requirements-windows.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
windows-toasts
win10toast

0 comments on commit 92c76ce

Please sign in to comment.