Skip to content

Commit

Permalink
fix(config): update production dependencies, update build command and…
Browse files Browse the repository at this point in the history
… reformat code
  • Loading branch information
maugde committed Jun 24, 2024
1 parent c8c09c3 commit d27ebd4
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 25 deletions.
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ dependencies = [
'psutil<5.10',
'pyyaml<6.1',
'pywin32<=306; sys_platform == "win32"',
'httpx<0.28',
]

[project.urls]
Expand Down Expand Up @@ -90,7 +91,7 @@ gh-deploy = "mkdocs gh-deploy -f mkdocs.yml {args}"
dependencies = ["pyinstaller"]

[tool.hatch.envs.pyinstaller.scripts]
build = 'pyinstaller --onefile src/antares_web_installer/__main__.py --hidden-import antares_web_installer.shortcuts._linux_shell --hidden-import antares_web_installer.shortcuts._win32_shell --hidden-import httpx --name {args:AntaresWebInstaller}'
build = 'pyinstaller --onefile src/antares_web_installer/__main__.py --hidden-import antares_web_installer.shortcuts._linux_shell --hidden-import antares_web_installer.shortcuts._win32_shell --name {args:AntaresWebInstaller}'

[tool.mypy]
mypy_path = 'src'
Expand Down
1 change: 1 addition & 0 deletions src/antares_web_installer/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

import sys

from antares_web_installer.cli import install_cli


Expand Down
36 changes: 19 additions & 17 deletions src/antares_web_installer/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
import textwrap
import time
import webbrowser
from difflib import SequenceMatcher
from pathlib import Path
from shutil import copy2, copytree

import httpx
import psutil

from pathlib import Path
from shutil import copy2, copytree
from difflib import SequenceMatcher

from antares_web_installer.config import update_config
from antares_web_installer.shortcuts import create_shortcut, get_desktop

Expand Down Expand Up @@ -77,8 +76,9 @@ def kill_running_server(self) -> None:
try:
running_app.wait(5)
except psutil.TimeoutExpired as e:
raise InstallError("Impossible to kill the server. Please kill it manually before relaunching the "
"installer.")
raise InstallError(
"Impossible to kill the server. Please kill it manually before relaunching the installer."
) from e
else:
logger.info("The application was successfully stopped.")
logger.info("No other processes found.")
Expand All @@ -96,8 +96,8 @@ def install_files(self):

# update config file
logger.info("Update configuration file...")
# config_path = self.target_dir.joinpath("config.yaml")
# update_config(config_path, config_path, version)
config_path = self.target_dir.joinpath("config.yaml")
update_config(config_path, config_path, version)
logger.info("Configuration file updated.")

# copy binaries
Expand Down Expand Up @@ -197,13 +197,15 @@ def start_server(self):
Launch the local server as a background task
"""
logger.info("Attempt to start the newly installed server...")
args = [str(self.server_path),]
server_process = subprocess.Popen(args=args,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
shell=True,
cwd=self.target_dir)
args = [str(self.server_path)]
server_process = subprocess.Popen(
args=args,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
shell=True,
cwd=self.target_dir,
)

if not server_process.poll():
logger.info("Server is starting up ...")
Expand All @@ -223,7 +225,7 @@ def start_server(self):
logger.info(attempt_info + "The server cannot retrieve a response yet. Retry ...")
else:
if res.status_code:
logger.info(f"Server is now available ({res.status_code}).")
logger.info(f"Server is now available.")
break
finally:
nb_attempts += 1
Expand All @@ -241,4 +243,4 @@ def open_browser(self):
except webbrowser.Error as e:
raise InstallError(f"Could not open browser at '{url}': {e}") from e
else:
logger.info(f"Browser was successfully opened at '{url}'.")
logger.info(f"Browser was successfully opened.")
2 changes: 1 addition & 1 deletion src/antares_web_installer/cli.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import logging
import os
import sys
from pathlib import Path
import typing as t
from pathlib import Path

import click

Expand Down
5 changes: 0 additions & 5 deletions src/antares_web_installer/config/config_2_15.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ def update_to_2_15(config: t.MutableMapping[str, t.Any]) -> None:
nb_cores_max = os.cpu_count() or nb_cores_min
nb_cores_default = max(nb_cores_min, nb_cores_max - 2)

# WIP
if not config:
config = {}
# end of WIP

config.setdefault("launcher", {})

if "local" in config["launcher"]:
Expand Down
1 change: 0 additions & 1 deletion src/antares_web_installer/shortcuts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import sys
import typing as t


_PKG = "antares_web_installer.shortcuts"

# https://stackoverflow.com/a/13874620/1513933
Expand Down
1 change: 1 addition & 0 deletions src/antares_web_installer/shortcuts/_win32_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

_WSHELL = win32com.client.Dispatch("Wscript.Shell")


# Windows Special Folders
# see: https://docs.microsoft.com/en-us/windows/win32/shell/csidl

Expand Down

0 comments on commit d27ebd4

Please sign in to comment.