Skip to content

Commit

Permalink
fix(app): correct imports of Python modules and reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
laurent-laporte-pro committed May 7, 2024
1 parent c3bf6fa commit b696ad7
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 19 deletions.
4 changes: 3 additions & 1 deletion src/antares_web_installer/__main__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
"""
Main entrypoint for the CLI application.
"""

import sys
from cli import install_cli

from antares_web_installer.cli import install_cli


def main():
Expand Down
2 changes: 1 addition & 1 deletion src/antares_web_installer/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def server_running_handler(self) -> None:
Check whether antares service is up.
In case it is, terminate the process
"""
for proc in psutil.process_iter(['pid', 'name']):
for proc in psutil.process_iter(["pid", "name"]):
if self.app_name in proc.name():
print("Cannot upgrade since the application is running.")

Expand Down
26 changes: 15 additions & 11 deletions src/antares_web_installer/cli.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import os
from pathlib import Path

import click
import psutil
from antares_web_installer import DEBUG
from pathlib import Path
from installer import install

from antares_web_installer import DEBUG
from antares_web_installer.installer import install

# SETTINGS WHEN DEBUGGING
if DEBUG:
Expand Down Expand Up @@ -35,12 +36,15 @@ def cli() -> None:


@click.command()
@click.option("-t", "--target-dir",
default=TARGET_DIR,
show_default=True,
type=click.Path(),
help="where to install your application")
def install_cli(target_dir: Path) -> None:
@click.option(
"-t",
"--target-dir",
default=TARGET_DIR,
show_default=True,
type=click.Path(),
help="where to install your application",
)
def install_cli(target_dir: str) -> None:
"""
Install Antares Web at the right file locations.
"""
Expand All @@ -65,8 +69,8 @@ def server_running_handler() -> None:
Check whether antares service is up.
In case it is, terminate the process
"""
for proc in psutil.process_iter(['pid', 'name', 'username']):
if 'antares' in proc.name().lower():
for proc in psutil.process_iter(["pid", "name", "username"]):
if "antares" in proc.name().lower():
print("Cannot upgrade since the application is running.")

running_app = psutil.Process(pid=proc.pid)
Expand Down
1 change: 1 addition & 0 deletions src/antares_web_installer/config/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Module to update configuration files
"""

from pathlib import Path

import yaml
Expand Down
14 changes: 8 additions & 6 deletions src/antares_web_installer/installer.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import os
import subprocess
import textwrap
import os
from pathlib import Path
from shutil import copy2, copytree, rmtree

from antares_web_installer import DEBUG
from shutil import copytree, copy2, rmtree
from config import update_config

from antares_web_installer.config import update_config

# List of files and directories to exclude during installation
COMMON_EXCLUDED_FILES = {"config.prod.yaml", "config.yaml", "examples", "logs", "matrices", "tmp", }
COMMON_EXCLUDED_FILES = {"config.prod.yaml", "config.yaml", "examples", "logs", "matrices", "tmp"}
POSIX_EXCLUDED_FILES = COMMON_EXCLUDED_FILES | {"AntaresWebWorker"}
WINDOWS_EXCLUDED_FILES = COMMON_EXCLUDED_FILES | {"AntaresWebWorker.exe"}
EXCLUDED_FILES = POSIX_EXCLUDED_FILES if os.name == "posix" else WINDOWS_EXCLUDED_FILES
Expand All @@ -17,12 +19,12 @@ class InstallError(Exception):
"""
Exception that handles installation error
"""

pass


def install(src_dir: Path, target_dir: Path) -> None:
"""
"""
""" """
# if "AntaresWeb/" directory already exists
if target_dir.joinpath("AntaresWeb").is_dir():
# check app version
Expand Down

0 comments on commit b696ad7

Please sign in to comment.