fmu-settings-cli 1.3.0__tar.gz → 1.4.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/.github/workflows/ci.yml +2 -2
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/.github/workflows/codeql.yml +2 -2
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/.github/workflows/publish.yml +2 -2
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/PKG-INFO +4 -3
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/pyproject.toml +5 -3
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/src/fmu_settings_cli/_version.py +3 -3
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/src/fmu_settings_cli/settings/_utils.py +30 -17
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/src/fmu_settings_cli/settings/cli.py +11 -2
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/src/fmu_settings_cli/settings/constants.py +1 -1
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/src/fmu_settings_cli/settings/main.py +8 -6
- fmu_settings_cli-1.4.1/src/fmu_settings_cli/settings/restart.py +123 -0
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/src/fmu_settings_cli.egg-info/PKG-INFO +4 -3
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/src/fmu_settings_cli.egg-info/SOURCES.txt +2 -0
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/src/fmu_settings_cli.egg-info/requires.txt +1 -1
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/src/fmu_settings_cli.egg-info/scm_file_list.json +2 -0
- fmu_settings_cli-1.4.1/src/fmu_settings_cli.egg-info/scm_version.json +8 -0
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/tests/conftest.py +9 -3
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/tests/test_init/test_init_main.py +2 -2
- fmu_settings_cli-1.4.1/tests/test_settings/test_restart.py +286 -0
- fmu_settings_cli-1.4.1/tests/test_settings/test_settings_cli.py +424 -0
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/tests/test_settings/test_settings_main.py +22 -2
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/tests/test_settings/test_utils.py +55 -12
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/tests/test_sync/test_sync_cli.py +1 -1
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/uv.lock +667 -730
- fmu_settings_cli-1.3.0/src/fmu_settings_cli.egg-info/scm_version.json +0 -8
- fmu_settings_cli-1.3.0/tests/test_settings/test_settings_cli.py +0 -223
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/.github/dependabot.yml +0 -0
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/.github/pull_request_template.md +0 -0
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/.gitignore +0 -0
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/CONTRIBUTING.md +0 -0
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/LICENSE +0 -0
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/README.md +0 -0
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/SECURITY.md +0 -0
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/setup.cfg +0 -0
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/src/fmu_settings_cli/__init__.py +0 -0
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/src/fmu_settings_cli/__main__.py +0 -0
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/src/fmu_settings_cli/copy/__init__.py +0 -0
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/src/fmu_settings_cli/copy/cli.py +0 -0
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/src/fmu_settings_cli/copy/copy.py +0 -0
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/src/fmu_settings_cli/init/__init__.py +0 -0
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/src/fmu_settings_cli/init/cli.py +0 -0
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/src/fmu_settings_cli/prints.py +0 -0
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/src/fmu_settings_cli/py.typed +0 -0
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/src/fmu_settings_cli/settings/__init__.py +0 -0
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/src/fmu_settings_cli/settings/api_server.py +0 -0
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/src/fmu_settings_cli/sync/__init__.py +0 -0
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/src/fmu_settings_cli/sync/cli.py +0 -0
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/src/fmu_settings_cli/sync/model_diff.py +0 -0
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/src/fmu_settings_cli/types.py +0 -0
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/src/fmu_settings_cli.egg-info/dependency_links.txt +0 -0
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/src/fmu_settings_cli.egg-info/entry_points.txt +0 -0
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/src/fmu_settings_cli.egg-info/top_level.txt +0 -0
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/tests/test_copy/test_copy.py +0 -0
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/tests/test_main.py +0 -0
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/tests/test_prints.py +0 -0
- {fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/tests/test_settings/test_start_api_server.py +0 -0
|
@@ -23,7 +23,7 @@ jobs:
|
|
|
23
23
|
runs-on: ubuntu-latest
|
|
24
24
|
strategy:
|
|
25
25
|
matrix:
|
|
26
|
-
python-version: ["3.11", "3.12", "3.13", "3.14"]
|
|
26
|
+
python-version: ["3.11", "3.12", "3.13", "3.14", "3.15"]
|
|
27
27
|
|
|
28
28
|
steps:
|
|
29
29
|
- name: Checkout commit locally
|
|
@@ -32,7 +32,7 @@ jobs:
|
|
|
32
32
|
fetch-depth: 0
|
|
33
33
|
|
|
34
34
|
- name: Install uv
|
|
35
|
-
uses: astral-sh/setup-uv@
|
|
35
|
+
uses: astral-sh/setup-uv@1db35dd8eee11c5894872e0b383ae6c406cf738d # v10.4.0
|
|
36
36
|
|
|
37
37
|
- name: Set up Python
|
|
38
38
|
run: uv python install ${{ matrix.python-version }}
|
|
@@ -32,12 +32,12 @@ jobs:
|
|
|
32
32
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
33
33
|
|
|
34
34
|
- name: Initialize CodeQL
|
|
35
|
-
uses: github/codeql-action/init@
|
|
35
|
+
uses: github/codeql-action/init@1bd86f2fdb4b86187fa4059f16f31a3202acc9ea # v4.39.4
|
|
36
36
|
with:
|
|
37
37
|
languages: ${{ matrix.language }}
|
|
38
38
|
build-mode: ${{ matrix.build-mode }}
|
|
39
39
|
|
|
40
40
|
- name: Perform CodeQL Analysis
|
|
41
|
-
uses: github/codeql-action/analyze@
|
|
41
|
+
uses: github/codeql-action/analyze@1bd86f2fdb4b86187fa4059f16f31a3202acc9ea # v4.39.4
|
|
42
42
|
with:
|
|
43
43
|
category: "/language:${{matrix.language}}"
|
|
@@ -25,7 +25,7 @@ jobs:
|
|
|
25
25
|
fetch-depth: 0
|
|
26
26
|
|
|
27
27
|
- name: Set up Python 3.12
|
|
28
|
-
uses: actions/setup-python@
|
|
28
|
+
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
|
|
29
29
|
with:
|
|
30
30
|
python-version: 3.12
|
|
31
31
|
|
|
@@ -38,4 +38,4 @@ jobs:
|
|
|
38
38
|
run: python -m build
|
|
39
39
|
|
|
40
40
|
- name: Publish package distributions to PyPI
|
|
41
|
-
uses: pypa/gh-action-pypi-publish@
|
|
41
|
+
uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fmu-settings-cli
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4.1
|
|
4
4
|
Summary: The cli for fmu-settings
|
|
5
5
|
Author-email: Equinor <fg-fmu_atlas@equinor.com>
|
|
6
|
-
License: GPL-3.0
|
|
6
|
+
License-Expression: GPL-3.0-only
|
|
7
7
|
Project-URL: Homepage, https://github.com/equinor/fmu-settings-cli
|
|
8
8
|
Project-URL: Repository, https://github.com/equinor/fmu-settings-cli
|
|
9
9
|
Project-URL: Documentation, https://github.com/equinor/fmu-settings-cli
|
|
@@ -15,13 +15,14 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
15
15
|
Classifier: Programming Language :: Python :: 3.12
|
|
16
16
|
Classifier: Programming Language :: Python :: 3.13
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.14
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
18
19
|
Classifier: Natural Language :: English
|
|
19
20
|
Requires-Python: >=3.11
|
|
20
21
|
Description-Content-Type: text/markdown
|
|
21
22
|
License-File: LICENSE
|
|
22
23
|
Requires-Dist: fmu-datamodels
|
|
23
24
|
Requires-Dist: fmu-settings>=1.6.0
|
|
24
|
-
Requires-Dist: fmu-settings-api>=1.
|
|
25
|
+
Requires-Dist: fmu-settings-api>=1.7.0
|
|
25
26
|
Requires-Dist: fmu-settings-gui>=1.3.0
|
|
26
27
|
Requires-Dist: rich
|
|
27
28
|
Requires-Dist: typer
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
[build-system]
|
|
2
|
-
requires = ["setuptools>=
|
|
2
|
+
requires = ["setuptools>=77.0.0", "setuptools_scm[toml]>=6.2"]
|
|
3
3
|
build-backend = "setuptools.build_meta"
|
|
4
4
|
|
|
5
5
|
[tool.setuptools_scm]
|
|
@@ -10,7 +10,8 @@ name = "fmu-settings-cli"
|
|
|
10
10
|
description = "The cli for fmu-settings"
|
|
11
11
|
readme = "README.md"
|
|
12
12
|
requires-python = ">=3.11"
|
|
13
|
-
license =
|
|
13
|
+
license = "GPL-3.0-only"
|
|
14
|
+
license-files = ["LICENSE"]
|
|
14
15
|
authors = [{ name = "Equinor", email = "fg-fmu_atlas@equinor.com" }]
|
|
15
16
|
classifiers = [
|
|
16
17
|
"Development Status :: 3 - Alpha",
|
|
@@ -21,13 +22,14 @@ classifiers = [
|
|
|
21
22
|
"Programming Language :: Python :: 3.12",
|
|
22
23
|
"Programming Language :: Python :: 3.13",
|
|
23
24
|
"Programming Language :: Python :: 3.14",
|
|
25
|
+
"Programming Language :: Python :: 3.15",
|
|
24
26
|
"Natural Language :: English",
|
|
25
27
|
]
|
|
26
28
|
dynamic = ["version"]
|
|
27
29
|
dependencies = [
|
|
28
30
|
"fmu-datamodels",
|
|
29
31
|
"fmu-settings>=1.6.0", # for Komodo 2026.11
|
|
30
|
-
"fmu-settings-api>=1.
|
|
32
|
+
"fmu-settings-api>=1.7.0", # /health application identifier for restart checks
|
|
31
33
|
"fmu-settings-gui>=1.3.0", # for Komodo 2026.11
|
|
32
34
|
"rich",
|
|
33
35
|
"typer",
|
|
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
|
|
|
18
18
|
commit_id: str | None
|
|
19
19
|
__commit_id__: str | None
|
|
20
20
|
|
|
21
|
-
__version__ = version = '1.
|
|
22
|
-
__version_tuple__ = version_tuple = (1,
|
|
21
|
+
__version__ = version = '1.4.1'
|
|
22
|
+
__version_tuple__ = version_tuple = (1, 4, 1)
|
|
23
23
|
|
|
24
|
-
__commit_id__ = commit_id = '
|
|
24
|
+
__commit_id__ = commit_id = 'gff1c98ce1'
|
|
@@ -8,7 +8,7 @@ import typer
|
|
|
8
8
|
|
|
9
9
|
from fmu_settings_cli.prints import error
|
|
10
10
|
|
|
11
|
-
from .constants import
|
|
11
|
+
from .constants import NO_PROCESS_PID
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
def generate_auth_token() -> str:
|
|
@@ -29,40 +29,53 @@ def create_authorized_url(token: str, host: str, gui_port: int) -> str:
|
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
def get_process_on_port(port: int) -> tuple[int, str]:
|
|
32
|
-
"""
|
|
32
|
+
"""Get the process listening on a TCP port.
|
|
33
33
|
|
|
34
34
|
Returns:
|
|
35
35
|
int, str tuple with the pid and command used to launch the process. Returns
|
|
36
|
-
|
|
37
|
-
running on the port.
|
|
36
|
+
NO_PROCESS_PID (-1), "Error" if no listener was found.
|
|
38
37
|
"""
|
|
39
38
|
try:
|
|
40
39
|
result = subprocess.run(
|
|
41
|
-
["lsof", "-
|
|
40
|
+
["lsof", "-nP", f"-iTCP:{port}", "-sTCP:LISTEN", "-t"],
|
|
42
41
|
capture_output=True,
|
|
43
42
|
text=True,
|
|
44
43
|
check=True,
|
|
45
44
|
)
|
|
46
45
|
pids = result.stdout.strip().split("\n")
|
|
47
46
|
if pids and pids[0]:
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
47
|
+
pid = int(pids[0])
|
|
48
|
+
try:
|
|
49
|
+
ps_result = subprocess.run(
|
|
50
|
+
["ps", "-p", str(pid), "-o", "comm="],
|
|
51
|
+
capture_output=True,
|
|
52
|
+
text=True,
|
|
53
|
+
check=True,
|
|
54
|
+
)
|
|
55
|
+
except (OSError, subprocess.CalledProcessError):
|
|
56
|
+
return pid, "unknown"
|
|
57
|
+
return pid, ps_result.stdout.strip()
|
|
58
|
+
except subprocess.CalledProcessError as exc:
|
|
59
|
+
# lsof uses status 1 for both no matches and errors.
|
|
60
|
+
if exc.returncode != 1 or exc.stdout or exc.stderr:
|
|
61
|
+
error(
|
|
62
|
+
"Could not check whether FMU Settings is running.",
|
|
63
|
+
suggestion="Please try again.",
|
|
54
64
|
)
|
|
55
|
-
|
|
56
|
-
except
|
|
57
|
-
|
|
58
|
-
|
|
65
|
+
raise typer.Abort from exc
|
|
66
|
+
except OSError as exc:
|
|
67
|
+
error(
|
|
68
|
+
"Could not check whether FMU Settings is running.",
|
|
69
|
+
suggestion="Please try again.",
|
|
70
|
+
)
|
|
71
|
+
raise typer.Abort from exc
|
|
72
|
+
return (NO_PROCESS_PID, "Error")
|
|
59
73
|
|
|
60
74
|
|
|
61
75
|
def ensure_port(port: int) -> None:
|
|
62
76
|
"""Checks if a required port is open and fails gracefully if not."""
|
|
63
77
|
pid, process = get_process_on_port(port)
|
|
64
|
-
|
|
65
|
-
if pid == INVALID_PID:
|
|
78
|
+
if pid == NO_PROCESS_PID:
|
|
66
79
|
return
|
|
67
80
|
|
|
68
81
|
error(
|
|
@@ -12,10 +12,12 @@ from ._utils import (
|
|
|
12
12
|
create_authorized_url,
|
|
13
13
|
ensure_port,
|
|
14
14
|
generate_auth_token,
|
|
15
|
+
get_process_on_port,
|
|
15
16
|
)
|
|
16
17
|
from .api_server import start_api_server
|
|
17
|
-
from .constants import APP_PORT, HOST, AppPort, GuiPort, LogLevel
|
|
18
|
+
from .constants import APP_PORT, HOST, NO_PROCESS_PID, AppPort, GuiPort, LogLevel
|
|
18
19
|
from .main import start_app
|
|
20
|
+
from .restart import confirm_restart, ensure_fmu_settings, stop_process
|
|
19
21
|
|
|
20
22
|
|
|
21
23
|
def _get_static_directory() -> Path:
|
|
@@ -153,7 +155,14 @@ def settings(
|
|
|
153
155
|
if ctx.invoked_subcommand is not None:
|
|
154
156
|
return
|
|
155
157
|
|
|
156
|
-
|
|
158
|
+
pid, _ = get_process_on_port(port)
|
|
159
|
+
if pid != NO_PROCESS_PID:
|
|
160
|
+
ensure_fmu_settings(port, host)
|
|
161
|
+
if confirm_restart():
|
|
162
|
+
stop_process(port, host)
|
|
163
|
+
else:
|
|
164
|
+
info("Restart cancelled.")
|
|
165
|
+
return
|
|
157
166
|
|
|
158
167
|
token = generate_auth_token()
|
|
159
168
|
start_app(
|
|
@@ -68,13 +68,15 @@ def start_app( # noqa: PLR0913
|
|
|
68
68
|
while True:
|
|
69
69
|
try:
|
|
70
70
|
# Check once a half second if the application server has
|
|
71
|
-
# completed.
|
|
72
|
-
# failed.
|
|
71
|
+
# completed. A clean return after startup is normal shutdown.
|
|
73
72
|
server_future.result(timeout=0.5)
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
73
|
+
if is_start_up:
|
|
74
|
+
error(
|
|
75
|
+
"Application server unexpectedly exited. Please report "
|
|
76
|
+
"this as a bug",
|
|
77
|
+
)
|
|
78
|
+
else:
|
|
79
|
+
info("FMU Settings has stopped.")
|
|
78
80
|
break
|
|
79
81
|
except TimeoutError:
|
|
80
82
|
# This is the valid case, where the server future did not complete
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"""Confirm and stop an existing application before starting its replacement."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import os
|
|
5
|
+
import signal
|
|
6
|
+
import time
|
|
7
|
+
import urllib.request
|
|
8
|
+
from contextlib import suppress
|
|
9
|
+
from http.client import HTTPException
|
|
10
|
+
|
|
11
|
+
import typer
|
|
12
|
+
|
|
13
|
+
from fmu_settings_cli.prints import error, info, warning
|
|
14
|
+
|
|
15
|
+
from ._utils import get_process_on_port
|
|
16
|
+
from .constants import HOST, NO_PROCESS_PID
|
|
17
|
+
|
|
18
|
+
SHUTDOWN_TIMEOUT_SECONDS = 30
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def ensure_fmu_settings(port: int, host: str = HOST) -> None:
|
|
22
|
+
"""Require the FMU Settings identifier from the health route."""
|
|
23
|
+
try:
|
|
24
|
+
with urllib.request.urlopen(
|
|
25
|
+
f"http://{host}:{port}/health", timeout=2
|
|
26
|
+
) as response:
|
|
27
|
+
payload: object = json.load(response)
|
|
28
|
+
identified = (
|
|
29
|
+
response.status == 200
|
|
30
|
+
and isinstance(payload, dict)
|
|
31
|
+
and payload.get("application") == "fmu-settings"
|
|
32
|
+
)
|
|
33
|
+
except (OSError, ValueError, HTTPException):
|
|
34
|
+
identified = False
|
|
35
|
+
|
|
36
|
+
if not identified:
|
|
37
|
+
error(
|
|
38
|
+
"Could not start FMU Settings.",
|
|
39
|
+
reason=(
|
|
40
|
+
"Another application may be running, "
|
|
41
|
+
"or FMU Settings did not respond as expected."
|
|
42
|
+
),
|
|
43
|
+
suggestion=(
|
|
44
|
+
"If FMU Settings is already open, press Ctrl+C in the terminal "
|
|
45
|
+
"where you started it. Then run 'fmu settings' again."
|
|
46
|
+
),
|
|
47
|
+
)
|
|
48
|
+
raise typer.Abort
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def confirm_restart() -> bool:
|
|
52
|
+
"""Explain the restart and require confirmation, defaulting to No."""
|
|
53
|
+
warning(
|
|
54
|
+
"FMU Settings is already running.\n\n"
|
|
55
|
+
"Open the FMU Settings tab in your browser to continue.\n"
|
|
56
|
+
"If you cannot find the tab, you can restart the app.\n"
|
|
57
|
+
"Any unsaved changes may be lost when you restart."
|
|
58
|
+
)
|
|
59
|
+
typer.echo()
|
|
60
|
+
info("Press Enter or type n to keep the current app running. Type y to restart.")
|
|
61
|
+
try:
|
|
62
|
+
return typer.confirm("Restart FMU Settings?", default=False)
|
|
63
|
+
except typer.Abort:
|
|
64
|
+
return False
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def stop_process(port: int, host: str = HOST) -> None:
|
|
68
|
+
"""Stop the current FMU Settings listener before a replacement starts.
|
|
69
|
+
|
|
70
|
+
Look up the listener again because it can change during confirmation.
|
|
71
|
+
Return if no listener remains. Otherwise, verify the application identifier
|
|
72
|
+
before sending SIGTERM. If the process has already stopped, check that
|
|
73
|
+
the port is free.
|
|
74
|
+
|
|
75
|
+
Wait up to 30 seconds for process exit, then check that the port is free.
|
|
76
|
+
Abort if a lookup or identity check fails, a signal is denied, shutdown
|
|
77
|
+
times out, or another listener takes the port. Never send SIGKILL.
|
|
78
|
+
"""
|
|
79
|
+
info("Restarting FMU Settings ...")
|
|
80
|
+
# The listener can change while the confirmation waits for the user.
|
|
81
|
+
pid, _ = get_process_on_port(port)
|
|
82
|
+
if pid == NO_PROCESS_PID:
|
|
83
|
+
return
|
|
84
|
+
|
|
85
|
+
ensure_fmu_settings(port, host)
|
|
86
|
+
|
|
87
|
+
try:
|
|
88
|
+
with suppress(ProcessLookupError):
|
|
89
|
+
os.kill(pid, signal.SIGTERM)
|
|
90
|
+
|
|
91
|
+
deadline = time.monotonic() + SHUTDOWN_TIMEOUT_SECONDS
|
|
92
|
+
while True:
|
|
93
|
+
try:
|
|
94
|
+
os.kill(pid, 0)
|
|
95
|
+
except ProcessLookupError:
|
|
96
|
+
break
|
|
97
|
+
if time.monotonic() >= deadline:
|
|
98
|
+
error(
|
|
99
|
+
"FMU Settings has not finished shutting down.",
|
|
100
|
+
reason=f"Shutdown exceeded {SHUTDOWN_TIMEOUT_SECONDS} seconds.",
|
|
101
|
+
suggestion="Wait a moment, then run 'fmu settings' again.",
|
|
102
|
+
)
|
|
103
|
+
raise typer.Abort
|
|
104
|
+
time.sleep(0.2)
|
|
105
|
+
except OSError as exc:
|
|
106
|
+
error(
|
|
107
|
+
"Could not restart FMU Settings.",
|
|
108
|
+
reason="The running app could not be stopped.",
|
|
109
|
+
suggestion=(
|
|
110
|
+
"Press Ctrl+C in the terminal where you started the app, "
|
|
111
|
+
"then run 'fmu settings' again."
|
|
112
|
+
),
|
|
113
|
+
)
|
|
114
|
+
raise typer.Abort from exc
|
|
115
|
+
|
|
116
|
+
listener_pid, _ = get_process_on_port(port)
|
|
117
|
+
if listener_pid != NO_PROCESS_PID:
|
|
118
|
+
error(
|
|
119
|
+
"Could not start FMU Settings.",
|
|
120
|
+
reason="Another app is still using the connection that FMU Settings needs.",
|
|
121
|
+
suggestion="Please try again.",
|
|
122
|
+
)
|
|
123
|
+
raise typer.Abort
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fmu-settings-cli
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4.1
|
|
4
4
|
Summary: The cli for fmu-settings
|
|
5
5
|
Author-email: Equinor <fg-fmu_atlas@equinor.com>
|
|
6
|
-
License: GPL-3.0
|
|
6
|
+
License-Expression: GPL-3.0-only
|
|
7
7
|
Project-URL: Homepage, https://github.com/equinor/fmu-settings-cli
|
|
8
8
|
Project-URL: Repository, https://github.com/equinor/fmu-settings-cli
|
|
9
9
|
Project-URL: Documentation, https://github.com/equinor/fmu-settings-cli
|
|
@@ -15,13 +15,14 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
15
15
|
Classifier: Programming Language :: Python :: 3.12
|
|
16
16
|
Classifier: Programming Language :: Python :: 3.13
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.14
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
18
19
|
Classifier: Natural Language :: English
|
|
19
20
|
Requires-Python: >=3.11
|
|
20
21
|
Description-Content-Type: text/markdown
|
|
21
22
|
License-File: LICENSE
|
|
22
23
|
Requires-Dist: fmu-datamodels
|
|
23
24
|
Requires-Dist: fmu-settings>=1.6.0
|
|
24
|
-
Requires-Dist: fmu-settings-api>=1.
|
|
25
|
+
Requires-Dist: fmu-settings-api>=1.7.0
|
|
25
26
|
Requires-Dist: fmu-settings-gui>=1.3.0
|
|
26
27
|
Requires-Dist: rich
|
|
27
28
|
Requires-Dist: typer
|
|
@@ -35,6 +35,7 @@ src/fmu_settings_cli/settings/api_server.py
|
|
|
35
35
|
src/fmu_settings_cli/settings/cli.py
|
|
36
36
|
src/fmu_settings_cli/settings/constants.py
|
|
37
37
|
src/fmu_settings_cli/settings/main.py
|
|
38
|
+
src/fmu_settings_cli/settings/restart.py
|
|
38
39
|
src/fmu_settings_cli/sync/__init__.py
|
|
39
40
|
src/fmu_settings_cli/sync/cli.py
|
|
40
41
|
src/fmu_settings_cli/sync/model_diff.py
|
|
@@ -43,6 +44,7 @@ tests/test_main.py
|
|
|
43
44
|
tests/test_prints.py
|
|
44
45
|
tests/test_copy/test_copy.py
|
|
45
46
|
tests/test_init/test_init_main.py
|
|
47
|
+
tests/test_settings/test_restart.py
|
|
46
48
|
tests/test_settings/test_settings_cli.py
|
|
47
49
|
tests/test_settings/test_settings_main.py
|
|
48
50
|
tests/test_settings/test_start_api_server.py
|
{fmu_settings_cli-1.3.0 → fmu_settings_cli-1.4.1}/src/fmu_settings_cli.egg-info/scm_file_list.json
RENAMED
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"src/fmu_settings_cli/settings/cli.py",
|
|
27
27
|
"src/fmu_settings_cli/settings/constants.py",
|
|
28
28
|
"src/fmu_settings_cli/settings/main.py",
|
|
29
|
+
"src/fmu_settings_cli/settings/restart.py",
|
|
29
30
|
"src/fmu_settings_cli/sync/__init__.py",
|
|
30
31
|
"src/fmu_settings_cli/sync/cli.py",
|
|
31
32
|
"src/fmu_settings_cli/sync/model_diff.py",
|
|
@@ -35,6 +36,7 @@
|
|
|
35
36
|
"tests/test_init/test_init_main.py",
|
|
36
37
|
"tests/test_main.py",
|
|
37
38
|
"tests/test_prints.py",
|
|
39
|
+
"tests/test_settings/test_restart.py",
|
|
38
40
|
"tests/test_settings/test_settings_cli.py",
|
|
39
41
|
"tests/test_settings/test_settings_main.py",
|
|
40
42
|
"tests/test_settings/test_start_api_server.py",
|
|
@@ -60,9 +60,15 @@ def default_settings_args() -> Generator[dict[str, Any]]:
|
|
|
60
60
|
|
|
61
61
|
|
|
62
62
|
@pytest.fixture
|
|
63
|
-
def
|
|
64
|
-
"""
|
|
65
|
-
with
|
|
63
|
+
def mock_available_port() -> Generator[None]:
|
|
64
|
+
"""Mock both port checks so tests do not depend on running applications."""
|
|
65
|
+
with (
|
|
66
|
+
patch("fmu_settings_cli.settings.cli.ensure_port"),
|
|
67
|
+
patch(
|
|
68
|
+
"fmu_settings_cli.settings.cli.get_process_on_port",
|
|
69
|
+
return_value=(constants.NO_PROCESS_PID, "Error"),
|
|
70
|
+
),
|
|
71
|
+
):
|
|
66
72
|
yield
|
|
67
73
|
|
|
68
74
|
|
|
@@ -263,7 +263,7 @@ def test_init_fmu_dir_exists_error(in_fmu_project: Path) -> None:
|
|
|
263
263
|
result = runner.invoke(app, ["init"])
|
|
264
264
|
assert result.exit_code == 1
|
|
265
265
|
assert "Error: Unable to create .fmu directory" in result.stderr
|
|
266
|
-
assert "
|
|
266
|
+
assert "already exists" in result.stderr
|
|
267
267
|
assert "You do not need to initialize a .fmu in this directory." in result.stderr
|
|
268
268
|
assert "Aborted." in result.stderr
|
|
269
269
|
|
|
@@ -302,7 +302,7 @@ def test_init_fmu_dir_exists_skips_global_config_messages(
|
|
|
302
302
|
assert result.exit_code == 1
|
|
303
303
|
assert "Successfully imported" not in result.stdout
|
|
304
304
|
assert "Unable to import masterdata" not in result.stderr
|
|
305
|
-
assert "
|
|
305
|
+
assert "already exists" in result.stderr
|
|
306
306
|
|
|
307
307
|
|
|
308
308
|
def test_init_fmu_dir_no_permissions_error(in_fmu_project: Path) -> None:
|