Skip to content

Commit 9e9216d

Browse files
committed
Remove duplication and run linting
1 parent 376eb2b commit 9e9216d

File tree

10 files changed

+30
-97
lines changed

10 files changed

+30
-97
lines changed

.github/workflows/test_cli_macos.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,3 @@ jobs:
3535
SIMVUE_TOKEN: ${{ secrets.SIMVUE_TOKEN }}
3636
run: |
3737
python -m pytest -x --cov=simvue_cli --cov-report=term --cov-report=xml -c /dev/null -p no:warnings -v
38-

.github/workflows/test_cli_ubuntu.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,3 @@ jobs:
3535
SIMVUE_TOKEN: ${{ secrets.SIMVUE_TOKEN }}
3636
run: |
3737
python -m pytest -x --cov=simvue_cli --cov-report=term --cov-report=xml -c /dev/null -p no:warnings -v
38-

.github/workflows/test_cli_windows.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,3 @@ jobs:
3535
SIMVUE_TOKEN: ${{ secrets.SIMVUE_TOKEN }}
3636
run: |
3737
python -m pytest -x --cov=simvue_cli --cov-report=term --cov-report=xml -c /dev/null -p no:warnings -v
38-

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ simvue run json <run-id> | jq
8080
The `json` command is also designed to support piping, we can retrieve the latest run and query it:
8181

8282
```sh
83-
simvue run list --count 1 | simvue run json | jq
83+
simvue run list --count 1 | simvue run json | jq
8484
```
8585

8686
### Creating runs
@@ -195,4 +195,3 @@ Server response can be check using the `ping` command:
195195
```sh
196196
simvue ping
197197
```
198-

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ dependencies = [
2424
simvue = "simvue_cli.cli:simvue"
2525

2626
[tool.ruff]
27-
lint.extend-select = ["C901", "T201"]
27+
lint.extend-select = ["C901"]
2828
lint.mccabe.max-complexity = 11
2929
extend-exclude = ["tests"]
3030

src/simvue_cli/cli/__init__.py

Lines changed: 7 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
import contextlib
2323
import importlib.metadata
2424

25-
26-
from pandas import show_versions
2725
import tabulate
2826
import requests
2927
import simvue as simvue_client
@@ -472,7 +470,7 @@ def get_run_json(run_id: str) -> None:
472470
try:
473471
run: Run = simvue_cli.actions.get_run(run_id)
474472
run_info = run.to_dict()
475-
click.echo(json.dumps({k: v for k, v in run_info.items()}, indent=2))
473+
click.echo(json.dumps(dict(run_info.items()), indent=2))
476474
except ObjectNotFoundError as e:
477475
error_msg = f"Failed to retrieve run '{run_id}': {e.args[0]}"
478476
click.echo(error_msg, fg="red", bold=True)
@@ -699,7 +697,7 @@ def get_alert_json(alert_id: str) -> None:
699697
try:
700698
alert: Alert = simvue_cli.actions.get_alert(alert_id)
701699
alert_info = alert.to_dict()
702-
click.echo(json.dumps({k: v for k, v in alert_info.items()}, indent=2))
700+
click.echo(json.dumps(dict(alert_info.items()), indent=2))
703701
except ObjectNotFoundError as e:
704702
error_msg = f"Failed to retrieve alert '{alert_id}': {e.args[0]}"
705703
click.echo(error_msg, fg="red", bold=True)
@@ -876,7 +874,7 @@ def get_folder_json(folder_id: str) -> None:
876874
try:
877875
folder: Folder = simvue_cli.actions.get_folder(folder_id)
878876
folder_info = folder.to_dict()
879-
click.echo(json.dumps({k: v for k, v in folder_info.items()}, indent=2))
877+
click.echo(json.dumps(dict(folder_info.items()), indent=2))
880878
except ObjectNotFoundError as e:
881879
error_msg = f"Failed to retrieve folder '{folder_id}': {e.args[0]}"
882880
click.echo(error_msg, fg="red", bold=True)
@@ -972,7 +970,7 @@ def get_tag_json(tag_id: str) -> None:
972970
try:
973971
tag: Tag = simvue_cli.actions.get_tag(tag_id)
974972
tag_info = tag.to_dict()
975-
click.echo(json.dumps({k: v for k, v in tag_info.items()}, indent=2))
973+
click.echo(json.dumps(dict(tag_info.items()), indent=2))
976974
except ObjectNotFoundError as e:
977975
error_msg = f"Failed to retrieve tag '{tag_id}': {e.args[0]}"
978976
click.echo(error_msg, fg="red", bold=True)
@@ -1004,7 +1002,7 @@ def get_tenant_json(tenant_id: str) -> None:
10041002
try:
10051003
tenant: Tenant = simvue_cli.actions.get_tenant(tenant_id)
10061004
tenant_info = tenant.to_dict()
1007-
click.echo(json.dumps({k: v for k, v in tenant_info.items()}, indent=2))
1005+
click.echo(json.dumps(dict(tenant_info.items()), indent=2))
10081006
except ObjectNotFoundError as e:
10091007
error_msg = f"Failed to retrieve tenant '{tenant_id}': {e.args[0]}"
10101008
click.echo(error_msg, fg="red", bold=True)
@@ -1169,25 +1167,6 @@ def tenant_list(
11691167
click.echo(table)
11701168

11711169

1172-
@simvue_tenant.command("json")
1173-
@click.argument("tenant_id", required=False)
1174-
def get_tenant_json(tenant_id: str) -> None:
1175-
"""Retrieve tenant information from Simvue server
1176-
1177-
If no tenant_ID is provided the input is read from stdin
1178-
"""
1179-
if not tenant_id:
1180-
tenant_id = input()
1181-
1182-
try:
1183-
tenant: Tenant = simvue_cli.actions.get_tenant(tenant_id)
1184-
tenant_info = tenant.to_dict()
1185-
click.echo(json.dumps({k: v for k, v in tenant_info.items()}, indent=2))
1186-
except ObjectNotFoundError as e:
1187-
error_msg = f"Failed to retrieve tenant '{tenant_id}': {e.args[0]}"
1188-
click.echo(error_msg, fg="red", bold=True)
1189-
1190-
11911170
@admin.group("user")
11921171
@click.pass_context
11931172
def user(ctx) -> None:
@@ -1293,7 +1272,7 @@ def get_user_json(user_id: str) -> None:
12931272
try:
12941273
user: User = simvue_cli.actions.get_user(user_id)
12951274
user_info = user.to_dict()
1296-
click.echo(json.dumps({k: v for k, v in user_info.items()}, indent=2))
1275+
click.echo(json.dumps(dict(user_info.items()), indent=2))
12971276
except ObjectNotFoundError as e:
12981277
error_msg = f"Failed to retrieve user '{user_id}': {e.args[0]}"
12991278
click.echo(error_msg, fg="red", bold=True)
@@ -1394,25 +1373,6 @@ def delete_user(ctx, user_ids: list[str] | None, interactive: bool) -> None:
13941373
click.secho(response_message, bold=True, fg="green")
13951374

13961375

1397-
@user.command("json")
1398-
@click.argument("user_id", required=False)
1399-
def get_user_json(user_id: str) -> None:
1400-
"""Retrieve user information from Simvue server
1401-
1402-
If no user_ID is provided the input is read from stdin
1403-
"""
1404-
if not user_id:
1405-
user_id = input()
1406-
1407-
try:
1408-
user: User = simvue_cli.actions.get_user(user_id)
1409-
user_info = user.to_dict()
1410-
click.echo(json.dumps({k: v for k, v in user_info.items()}, indent=2))
1411-
except ObjectNotFoundError as e:
1412-
error_msg = f"Failed to retrieve user '{user_id}': {e.args[0]}"
1413-
click.echo(error_msg, fg="red", bold=True)
1414-
1415-
14161376
@simvue.group("storage")
14171377
@click.pass_context
14181378
def simvue_storage(ctx):
@@ -1495,7 +1455,7 @@ def get_storage_json(ctx, storage_id: str) -> None:
14951455
try:
14961456
storage: Storage = simvue_cli.actions.get_storage(storage_id)
14971457
storage_info = storage.to_dict()
1498-
click.echo(json.dumps({k: v for k, v in storage_info.items()}, indent=2))
1458+
click.echo(json.dumps(dict(storage_info.items()), indent=2))
14991459
except ObjectNotFoundError as e:
15001460
error_msg = f"Failed to retrieve storage '{storage_id}': {e.args[0]}"
15011461
click.echo(error_msg, fg="red", bold=True)

src/simvue_cli/cli/display.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@
1414
import pydantic
1515

1616
SIMVUE_LOGO: str = """
17-
18-
*****
19-
******
20-
***** ****
21-
*************
22-
*** ****** *** ************ ***** ************** ********* ** ** ** ** *******
23-
*** * * ** ************* ***** *************************** ** * ** ** ** **
24-
** ** *** ** ***** ***** ****** ******* ****** ** ** ** ** ** **
25-
** ** ** * *** ********** ***** ***** ****** ***** ** ** ** ** * **
26-
* ** ** **** *** ************ ***** ***** ***** ***** ** ** ** ** ***************
27-
** * * ** *** ******* ***** ***** ***** ***** ** ** ** ** **
28-
* *** *** ** *** *** ***** ***** ***** ***** ***** * ** ** *** **
29-
** **** **** *** ************** ***** ***** ***** ***** **** ** **** *** ***
30-
*** ***** ********* ***** ***** ***** ***** ** ****** ** ******
31-
***********
17+
18+
*****
19+
******
20+
***** ****
21+
*************
22+
*** ****** *** ************ ***** ************** ********* ** ** ** ** *******
23+
*** * * ** ************* ***** *************************** ** * ** ** ** **
24+
** ** *** ** ***** ***** ****** ******* ****** ** ** ** ** ** **
25+
** ** ** * *** ********** ***** ***** ****** ***** ** ** ** ** * **
26+
* ** ** **** *** ************ ***** ***** ***** ***** ** ** ** ** ***************
27+
** * * ** *** ******* ***** ***** ***** ***** ** ** ** ** **
28+
* *** *** ** *** *** ***** ***** ***** ***** ***** * ** ** *** **
29+
** **** **** *** ************** ***** ***** ***** ***** **** ** **** *** ***
30+
*** ***** ********* ***** ***** ***** ***** ** ****** ** ******
31+
***********
3232
"""
3333

3434
STATUS_FORMAT: dict[str, str] = {

src/simvue_cli/config.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
55
Functionality for updating configuration of Simvue API via the CLI
66
"""
7+
78
__author__ = "Kristian Zarebski"
89
__date__ = "2024-09-09"
910

@@ -16,7 +17,9 @@
1617
SIMVUE_CONFIG_INI_FILENAME: str = "simvue.ini"
1718

1819

19-
def set_configuration_option(section: str, key: str, value: str | int | float, local: bool) -> pathlib.Path:
20+
def set_configuration_option(
21+
section: str, key: str, value: str | int | float, local: bool
22+
) -> pathlib.Path:
2023
"""Set a configuation value for Simvue
2124
2225
Parameters
@@ -61,4 +64,3 @@ def get_url_and_headers() -> tuple[str, dict[str, str]]:
6164
"Authorization": f"Bearer {_config.server.token.get_secret_value()}"
6265
}
6366
return _config.server.url, _headers
64-

src/simvue_cli/server.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
Functions which retrieve additional information on the Simvue
66
server not provided by the RestAPI
77
"""
8+
89
__author__ = "Kristian Zarebski"
910
__date__ = "2024-09-09"
1011

1112
import socket
1213
import urllib.parse as urllib_parser
1314

15+
1416
def get_ip_of_url(url: str) -> str:
1517
"""Retrieves the IP address for the given URL as a string"""
1618
try:
@@ -21,4 +23,3 @@ def get_ip_of_url(url: str) -> str:
2123

2224
except (socket.gaierror, RuntimeError):
2325
return "Unknown IP"
24-

src/simvue_cli/tree.py

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)