pyegeria 0.3.3__py3-none-any.whl → 0.3.5__py3-none-any.whl
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.
- pyegeria/__init__.py +3 -1
- pyegeria/automated_curation_omvs.py +15 -10
- pyegeria/collection_manager_omvs.py +2428 -0
- pyegeria/core_omag_server_config.py +15 -22
- pyegeria/full_omag_server_config.py +0 -1
- pyegeria/glossary_omvs.py +14 -2
- pyegeria/gov_engine.py +1 -8
- pyegeria/governance_author.py +2 -0
- pyegeria/my_profile_omvs.py +1 -1
- pyegeria/platform_services.py +2 -39
- pyegeria/project_manager_omvs.py +1689 -0
- pyegeria/registered_info.py +3 -1
- pyegeria/server_operations.py +2 -2
- pyegeria/valid_metadata_omvs.py +779 -0
- pyegeria-0.3.5.data/scripts/engine_action_status.py +145 -0
- pyegeria-0.3.5.data/scripts/find_todos.py +152 -0
- pyegeria-0.3.5.data/scripts/glossary_view.py +135 -0
- pyegeria-0.3.5.data/scripts/gov_engine_status.py +120 -0
- pyegeria-0.3.5.data/scripts/integration_daemon_status.py +130 -0
- pyegeria-0.3.5.data/scripts/list_asset_types.py +114 -0
- pyegeria-0.3.5.data/scripts/multi-server_status.py +120 -0
- pyegeria-0.3.5.data/scripts/my_todos.py +162 -0
- pyegeria-0.3.5.data/scripts/open_todos.py +140 -0
- pyegeria-0.3.5.data/scripts/server_status.py +105 -0
- pyegeria-0.3.5.data/scripts/server_status_widget.py +93 -0
- pyegeria-0.3.5.data/scripts/view_my_profile.py +140 -0
- {pyegeria-0.3.3.dist-info → pyegeria-0.3.5.dist-info}/METADATA +1 -1
- pyegeria-0.3.5.dist-info/RECORD +36 -0
- pyegeria/exceptions.py +0 -382
- pyegeria-0.3.3.dist-info/RECORD +0 -22
- {pyegeria-0.3.3.dist-info → pyegeria-0.3.5.dist-info}/LICENSE +0 -0
- {pyegeria-0.3.3.dist-info → pyegeria-0.3.5.dist-info}/WHEEL +0 -0
- {pyegeria-0.3.3.dist-info → pyegeria-0.3.5.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,114 @@
|
|
1
|
+
#!python
|
2
|
+
"""
|
3
|
+
SPDX-License-Identifier: Apache-2.0
|
4
|
+
Copyright Contributors to the ODPi Egeria project.
|
5
|
+
|
6
|
+
Unit tests for the Utils helper functions using the Pytest framework.
|
7
|
+
|
8
|
+
|
9
|
+
A simple display for my profile
|
10
|
+
"""
|
11
|
+
|
12
|
+
import argparse
|
13
|
+
import time
|
14
|
+
|
15
|
+
from rich import box
|
16
|
+
from rich.console import Console
|
17
|
+
from rich.table import Table
|
18
|
+
|
19
|
+
from pyegeria import (
|
20
|
+
InvalidParameterException,
|
21
|
+
PropertyServerException,
|
22
|
+
UserNotAuthorizedException,
|
23
|
+
print_exception_response,
|
24
|
+
RegisteredInfo
|
25
|
+
)
|
26
|
+
|
27
|
+
disable_ssl_warnings = True
|
28
|
+
|
29
|
+
good_platform1_url = "https://127.0.0.1:9443"
|
30
|
+
good_platform2_url = "https://egeria.pdr-associates.com:7443"
|
31
|
+
bad_platform1_url = "https://localhost:9443"
|
32
|
+
|
33
|
+
# good_platform1_url = "https://127.0.0.1:30080"
|
34
|
+
# good_platform2_url = "https://127.0.0.1:30081"
|
35
|
+
# bad_platform1_url = "https://localhost:9443"
|
36
|
+
|
37
|
+
good_user_1 = "garygeeke"
|
38
|
+
good_user_2 = "erinoverview"
|
39
|
+
bad_user_1 = "eviledna"
|
40
|
+
bad_user_2 = ""
|
41
|
+
|
42
|
+
good_server_1 = "active-metadata-store"
|
43
|
+
good_server_2 = "simple-metadata-store"
|
44
|
+
good_server_3 = "view-server"
|
45
|
+
good_server_4 = "engine-host"
|
46
|
+
bad_server_1 = "coco"
|
47
|
+
bad_server_2 = ""
|
48
|
+
|
49
|
+
|
50
|
+
def display_asset_types(server: str = good_server_3, url: str = good_platform1_url, username: str = good_user_2):
|
51
|
+
r_client = RegisteredInfo(good_platform1_url, good_user_2, "secret",
|
52
|
+
server_name=good_server_3, )
|
53
|
+
token = r_client.create_egeria_bearer_token(good_user_2, "secret")
|
54
|
+
asset_types = r_client.list_asset_types()
|
55
|
+
|
56
|
+
def generate_table() -> Table:
|
57
|
+
"""Make a new table."""
|
58
|
+
table = Table(
|
59
|
+
title=f"Asset Types for: {good_platform1_url} @ {time.asctime()}",
|
60
|
+
# style = "black on grey66",
|
61
|
+
header_style="white on dark_blue",
|
62
|
+
show_lines=True,
|
63
|
+
box=box.ROUNDED,
|
64
|
+
caption=f"Asset Types from Server '{server}' @ Platform - {url}",
|
65
|
+
expand=True
|
66
|
+
)
|
67
|
+
|
68
|
+
table.add_column("Name")
|
69
|
+
table.add_column("Description")
|
70
|
+
table.add_column("SuperType")
|
71
|
+
table.add_column("Version")
|
72
|
+
|
73
|
+
name = " "
|
74
|
+
description = " "
|
75
|
+
version = " "
|
76
|
+
super_type = " "
|
77
|
+
if len(asset_types) > 0:
|
78
|
+
for a_type in asset_types:
|
79
|
+
name = a_type.get("name", "none")
|
80
|
+
description = a_type.get("description", "none")
|
81
|
+
version = a_type.get("version", " ")
|
82
|
+
super_type = a_type.get("superType", "none")
|
83
|
+
table.add_row(
|
84
|
+
name, description, str(version), super_type
|
85
|
+
)
|
86
|
+
return table
|
87
|
+
|
88
|
+
try:
|
89
|
+
console = Console()
|
90
|
+
with console.pager():
|
91
|
+
console.print(generate_table())
|
92
|
+
|
93
|
+
except (InvalidParameterException, PropertyServerException, UserNotAuthorizedException) as e:
|
94
|
+
print_exception_response(e)
|
95
|
+
assert e.related_http_code != "200", "Invalid parameters"
|
96
|
+
finally:
|
97
|
+
r_client.close_session()
|
98
|
+
|
99
|
+
|
100
|
+
if __name__ == "__main__":
|
101
|
+
parser = argparse.ArgumentParser()
|
102
|
+
parser.add_argument("--server", help="Name of the server to display status for")
|
103
|
+
parser.add_argument("--url", help="URL Platform to connect to")
|
104
|
+
parser.add_argument("--userid", help="User Id")
|
105
|
+
|
106
|
+
args = parser.parse_args()
|
107
|
+
|
108
|
+
server = args.server if args.server is not None else "view-server"
|
109
|
+
url = args.url if args.url is not None else "https://localhost:9443"
|
110
|
+
userid = args.userid if args.userid is not None else 'erinoverview'
|
111
|
+
# guid = args.guid if args.guid is not None else None
|
112
|
+
guid = None
|
113
|
+
|
114
|
+
display_asset_types(server, url, userid)
|
@@ -0,0 +1,120 @@
|
|
1
|
+
#!python
|
2
|
+
"""
|
3
|
+
SPDX-License-Identifier: Apache-2.0
|
4
|
+
Copyright Contributors to the ODPi Egeria project.
|
5
|
+
|
6
|
+
An example of displaying the status of two platforms concurrently.
|
7
|
+
"""
|
8
|
+
|
9
|
+
import time
|
10
|
+
import argparse
|
11
|
+
|
12
|
+
from rich.box import Box
|
13
|
+
|
14
|
+
from pyegeria._exceptions import (
|
15
|
+
InvalidParameterException,
|
16
|
+
PropertyServerException,
|
17
|
+
UserNotAuthorizedException,
|
18
|
+
print_exception_response,
|
19
|
+
)
|
20
|
+
from rich.table import Table
|
21
|
+
from rich.live import Live
|
22
|
+
from rich import print
|
23
|
+
from rich.console import Group
|
24
|
+
from rich.panel import Panel
|
25
|
+
from rich import box, align
|
26
|
+
from rich.layout import Layout
|
27
|
+
import rich
|
28
|
+
from pyegeria.server_operations import ServerOps
|
29
|
+
|
30
|
+
disable_ssl_warnings = True
|
31
|
+
|
32
|
+
good_platform1_url = "https://127.0.0.1:9443"
|
33
|
+
good_platform2_url = "https://egeria.pdr-associates.com:9443"
|
34
|
+
bad_platform1_url = "https://localhost:9443"
|
35
|
+
|
36
|
+
|
37
|
+
good_user_1 = "garygeeke"
|
38
|
+
good_user_2 = "erinoverview"
|
39
|
+
bad_user_1 = "eviledna"
|
40
|
+
bad_user_2 = ""
|
41
|
+
|
42
|
+
good_server_1 = "active-metadata-store"
|
43
|
+
good_server_2 = "simple-metadata-store"
|
44
|
+
good_server_3 = "view-server"
|
45
|
+
good_server_4 = "engine-host"
|
46
|
+
bad_server_1 = "coco"
|
47
|
+
bad_server_2 = ""
|
48
|
+
|
49
|
+
|
50
|
+
def test_display_status(server: str = good_server_1, url: str = good_platform2_url, username: str = good_user_1):
|
51
|
+
layout = Layout()
|
52
|
+
print(layout)
|
53
|
+
|
54
|
+
print(layout)
|
55
|
+
p_client1 = ServerOps(server, "https://cray.local:9443", username)
|
56
|
+
p_client2 = ServerOps('ecosystem-monitor', "https://cray.local:9446", username)
|
57
|
+
|
58
|
+
|
59
|
+
def generate_table(p_client) -> Table:
|
60
|
+
"""Make a new table."""
|
61
|
+
table = Table(
|
62
|
+
title=f"Server Status for Platform - {time.asctime()}",
|
63
|
+
# style = "black on grey66",
|
64
|
+
header_style="white on dark_blue",
|
65
|
+
caption=f"Server Status for Platform - '{url}'",
|
66
|
+
# show_lines=True,
|
67
|
+
)
|
68
|
+
|
69
|
+
table.add_column("Known Server")
|
70
|
+
table.add_column("Status")
|
71
|
+
|
72
|
+
known_server_list = p_client.get_known_servers()
|
73
|
+
active_server_list = p_client.get_active_server_list()
|
74
|
+
if len(known_server_list) == 0:
|
75
|
+
return table
|
76
|
+
|
77
|
+
for server in known_server_list:
|
78
|
+
if server in active_server_list:
|
79
|
+
status = "Active"
|
80
|
+
else:
|
81
|
+
status = "Inactive"
|
82
|
+
|
83
|
+
table.add_row(server,
|
84
|
+
"[red]Inactive" if status == "Inactive" else "[green]Active",
|
85
|
+
)
|
86
|
+
# p_client.close_session()
|
87
|
+
return table
|
88
|
+
|
89
|
+
try:
|
90
|
+
# panel_group = Group(
|
91
|
+
# rich.align.Align(Panel(, generate_table(p_client2)), box.ROUNDED))
|
92
|
+
#
|
93
|
+
# )
|
94
|
+
layout.split_row(
|
95
|
+
Layout(Panel(generate_table(p_client1), box.ROUNDED)),
|
96
|
+
Layout(Panel(generate_table(p_client2), box.ROUNDED))
|
97
|
+
)
|
98
|
+
with Live(layout, refresh_per_second=4, screen=True) as live:
|
99
|
+
while True:
|
100
|
+
time.sleep(2)
|
101
|
+
live.update(layout)
|
102
|
+
|
103
|
+
|
104
|
+
except (InvalidParameterException, PropertyServerException, UserNotAuthorizedException) as e:
|
105
|
+
print_exception_response(e)
|
106
|
+
assert e.related_http_code != "200", "Invalid parameters"
|
107
|
+
|
108
|
+
|
109
|
+
if __name__ == "__main__":
|
110
|
+
parser = argparse.ArgumentParser()
|
111
|
+
parser.add_argument("--server", help="Name of the server to display status for")
|
112
|
+
parser.add_argument("--url", help="URL Platform to connect to")
|
113
|
+
parser.add_argument("--userid", help="User Id")
|
114
|
+
args = parser.parse_args()
|
115
|
+
|
116
|
+
server = args.server if args.server is not None else "active-metadata-store"
|
117
|
+
url = args.url if args.url is not None else "https://cray.local:9443"
|
118
|
+
userid = args.userid if args.userid is not None else 'garygeeke'
|
119
|
+
|
120
|
+
test_display_status(server, url, userid)
|
@@ -0,0 +1,162 @@
|
|
1
|
+
#!python
|
2
|
+
"""
|
3
|
+
SPDX-License-Identifier: Apache-2.0
|
4
|
+
Copyright Contributors to the ODPi Egeria project.
|
5
|
+
|
6
|
+
Unit tests for the Utils helper functions using the Pytest framework.
|
7
|
+
|
8
|
+
|
9
|
+
A simple status display of a user's todos
|
10
|
+
"""
|
11
|
+
|
12
|
+
import argparse
|
13
|
+
import json
|
14
|
+
import time
|
15
|
+
|
16
|
+
from rich import box
|
17
|
+
from rich.live import Live
|
18
|
+
from rich.table import Table
|
19
|
+
from rich import console
|
20
|
+
|
21
|
+
from pyegeria import (
|
22
|
+
InvalidParameterException,
|
23
|
+
PropertyServerException,
|
24
|
+
UserNotAuthorizedException,
|
25
|
+
print_exception_response,
|
26
|
+
)
|
27
|
+
from pyegeria.gov_engine import GovEng
|
28
|
+
from pyegeria.my_profile_omvs import MyProfile
|
29
|
+
disable_ssl_warnings = True
|
30
|
+
|
31
|
+
good_platform1_url = "https://127.0.0.1:9443"
|
32
|
+
good_platform2_url = "https://egeria.pdr-associates.com:7443"
|
33
|
+
bad_platform1_url = "https://localhost:9443"
|
34
|
+
|
35
|
+
# good_platform1_url = "https://127.0.0.1:30080"
|
36
|
+
# good_platform2_url = "https://127.0.0.1:30081"
|
37
|
+
# bad_platform1_url = "https://localhost:9443"
|
38
|
+
|
39
|
+
good_user_1 = "garygeeke"
|
40
|
+
good_user_2 = "erinoverview"
|
41
|
+
bad_user_1 = "eviledna"
|
42
|
+
bad_user_2 = ""
|
43
|
+
|
44
|
+
good_server_1 = "active-metadata-store"
|
45
|
+
good_server_2 = "simple-metadata-store"
|
46
|
+
good_server_3 = "view-server"
|
47
|
+
good_server_4 = "engine-host"
|
48
|
+
bad_server_1 = "coco"
|
49
|
+
bad_server_2 = ""
|
50
|
+
|
51
|
+
|
52
|
+
def display_todos(server: str = good_server_4, url: str = good_platform1_url, user: str = good_user_1):
|
53
|
+
m_client = MyProfile(server, url, user_id=user)
|
54
|
+
token = m_client.create_egeria_bearer_token(user, "secret")
|
55
|
+
|
56
|
+
def add_rows(table: Table, guid: str, identity: str) -> None:
|
57
|
+
todo_items = m_client.get_assigned_actions(guid)
|
58
|
+
if type(todo_items) is str:
|
59
|
+
return
|
60
|
+
|
61
|
+
for item in todo_items:
|
62
|
+
assigned_actors = [" "]
|
63
|
+
if todo_items is None:
|
64
|
+
name = " "
|
65
|
+
type_name = " "
|
66
|
+
todo_guid = " "
|
67
|
+
created = " "
|
68
|
+
priority = " "
|
69
|
+
due = " "
|
70
|
+
completed = " "
|
71
|
+
status = " "
|
72
|
+
sponsor = " "
|
73
|
+
else:
|
74
|
+
props = item["properties"]
|
75
|
+
name = props["name"]
|
76
|
+
todo_type_name = props.get("toDoType", " ")
|
77
|
+
todo_guid = item["elementHeader"]["guid"]
|
78
|
+
created = props.get("creationTime", " ")
|
79
|
+
priority = str(props.get("priority", " "))
|
80
|
+
due = props.get("dueTime", " ")
|
81
|
+
completed = props.get("completionTime", " ")
|
82
|
+
status = props.get("status")
|
83
|
+
|
84
|
+
for actor in item["assignedActors"]:
|
85
|
+
assigned_actors.append(actor.get("uniqueName", "NoOne"))
|
86
|
+
if status in ("WAITING", "OPEN"):
|
87
|
+
status = f"[yellow]{status}"
|
88
|
+
elif status in ("INPROGRESS", "COMPLETE"):
|
89
|
+
status = f"[green]{status}"
|
90
|
+
else:
|
91
|
+
status = f"[red]{status}"
|
92
|
+
|
93
|
+
table.add_row(
|
94
|
+
str(identity), name, todo_type_name, todo_guid, created, priority, due,
|
95
|
+
completed, status, str(assigned_actors)
|
96
|
+
)
|
97
|
+
|
98
|
+
def generate_table() -> Table:
|
99
|
+
"""Make a new table."""
|
100
|
+
table = Table(
|
101
|
+
title=f"Open ToDos for Platform {good_platform1_url} @ {time.asctime()}",
|
102
|
+
# style = "black on grey66",
|
103
|
+
header_style="white on dark_blue",
|
104
|
+
show_lines=True,
|
105
|
+
box=box.ROUNDED,
|
106
|
+
caption=f"ToDos for Server '{server}' @ Platform - {url}",
|
107
|
+
expand=True
|
108
|
+
)
|
109
|
+
table.add_column("Actor")
|
110
|
+
table.add_column("ToDo Name")
|
111
|
+
table.add_column("Type Name")
|
112
|
+
table.add_column("GUID")
|
113
|
+
table.add_column("Created")
|
114
|
+
table.add_column("Priority")
|
115
|
+
table.add_column("Due")
|
116
|
+
table.add_column("Completion")
|
117
|
+
table.add_column("Status")
|
118
|
+
table.add_column("Sponsor")
|
119
|
+
|
120
|
+
my_profile = m_client.get_my_profile()
|
121
|
+
my_guid = my_profile["elementHeader"]["guid"]
|
122
|
+
my_ids = my_profile["userIdentities"]
|
123
|
+
my_title = my_profile["profileProperties"].get("jobTitle", "No Title")
|
124
|
+
user_ids = []
|
125
|
+
for id in my_ids:
|
126
|
+
user_ids.append(id["userIdentity"]["properties"].get("userId", "NoOne"))
|
127
|
+
add_rows(table, my_guid, user_ids)
|
128
|
+
|
129
|
+
my_roles = my_profile["roles"]
|
130
|
+
if type(my_roles) is list:
|
131
|
+
for role in my_roles:
|
132
|
+
role_guid = role["elementHeader"]["guid"]
|
133
|
+
role_title = role["properties"].get("title","No Title")
|
134
|
+
add_rows(table,role_guid,role_title)
|
135
|
+
|
136
|
+
# m_client.close_session()
|
137
|
+
return table
|
138
|
+
|
139
|
+
try:
|
140
|
+
with Live(generate_table(), refresh_per_second=4, screen=True) as live:
|
141
|
+
while True:
|
142
|
+
time.sleep(2)
|
143
|
+
live.update(generate_table())
|
144
|
+
live.console.pager()
|
145
|
+
|
146
|
+
except (InvalidParameterException, PropertyServerException, UserNotAuthorizedException) as e:
|
147
|
+
print_exception_response(e)
|
148
|
+
assert e.related_http_code != "200", "Invalid parameters"
|
149
|
+
|
150
|
+
|
151
|
+
if __name__ == "__main__":
|
152
|
+
parser = argparse.ArgumentParser()
|
153
|
+
parser.add_argument("--server", help="Name of the view server to connect to")
|
154
|
+
parser.add_argument("--url", help="URL Platform to connect to")
|
155
|
+
parser.add_argument("--userid", help="User Id")
|
156
|
+
args = parser.parse_args()
|
157
|
+
|
158
|
+
server = args.server if args.server is not None else "view-server"
|
159
|
+
url = args.url if args.url is not None else "https://localhost:9443"
|
160
|
+
userid = args.userid if args.userid is not None else 'erinoverview'
|
161
|
+
print(f"Starting display_todos with {server}, {url}, {userid}")
|
162
|
+
display_todos(server=server, url=url, user=userid)
|
@@ -0,0 +1,140 @@
|
|
1
|
+
#!python
|
2
|
+
"""
|
3
|
+
SPDX-License-Identifier: Apache-2.0
|
4
|
+
Copyright Contributors to the ODPi Egeria project.
|
5
|
+
|
6
|
+
Unit tests for the Utils helper functions using the Pytest framework.
|
7
|
+
|
8
|
+
|
9
|
+
A simple status display for Open To Dos
|
10
|
+
"""
|
11
|
+
|
12
|
+
import argparse
|
13
|
+
import json
|
14
|
+
import time
|
15
|
+
|
16
|
+
from rich import box
|
17
|
+
from rich.live import Live
|
18
|
+
from rich.table import Table
|
19
|
+
from rich import console
|
20
|
+
|
21
|
+
from pyegeria._exceptions import (
|
22
|
+
InvalidParameterException,
|
23
|
+
PropertyServerException,
|
24
|
+
UserNotAuthorizedException,
|
25
|
+
print_exception_response,
|
26
|
+
)
|
27
|
+
from pyegeria.gov_engine import GovEng
|
28
|
+
from pyegeria.my_profile_omvs import MyProfile
|
29
|
+
disable_ssl_warnings = True
|
30
|
+
|
31
|
+
good_platform1_url = "https://127.0.0.1:9443"
|
32
|
+
good_platform2_url = "https://egeria.pdr-associates.com:7443"
|
33
|
+
bad_platform1_url = "https://localhost:9443"
|
34
|
+
|
35
|
+
# good_platform1_url = "https://127.0.0.1:30080"
|
36
|
+
# good_platform2_url = "https://127.0.0.1:30081"
|
37
|
+
# bad_platform1_url = "https://localhost:9443"
|
38
|
+
|
39
|
+
good_user_1 = "garygeeke"
|
40
|
+
good_user_2 = "erinoverview"
|
41
|
+
bad_user_1 = "eviledna"
|
42
|
+
bad_user_2 = ""
|
43
|
+
|
44
|
+
good_server_1 = "active-metadata-store"
|
45
|
+
good_server_2 = "simple-metadata-store"
|
46
|
+
good_server_3 = "view-server"
|
47
|
+
good_server_4 = "engine-host"
|
48
|
+
bad_server_1 = "coco"
|
49
|
+
bad_server_2 = ""
|
50
|
+
|
51
|
+
|
52
|
+
def display_todos(server: str = good_server_4, url: str = good_platform1_url, user: str = good_user_1):
|
53
|
+
m_client = MyProfile(server, url, user_id=user)
|
54
|
+
token = m_client.create_egeria_bearer_token(user, "secret")
|
55
|
+
|
56
|
+
def generate_table(search_string:str = '*') -> Table:
|
57
|
+
"""Make a new table."""
|
58
|
+
table = Table(
|
59
|
+
title=f"Open ToDos for Platform {good_platform1_url} @ {time.asctime()}",
|
60
|
+
# style = "black on grey66",
|
61
|
+
header_style="white on dark_blue",
|
62
|
+
show_lines=True,
|
63
|
+
box=box.ROUNDED,
|
64
|
+
caption=f"ToDos for Server '{server}' @ Platform - {url}",
|
65
|
+
expand=True
|
66
|
+
)
|
67
|
+
|
68
|
+
table.add_column("Name")
|
69
|
+
table.add_column("Type Name")
|
70
|
+
|
71
|
+
table.add_column("Created")
|
72
|
+
table.add_column("Priority")
|
73
|
+
table.add_column("Due")
|
74
|
+
table.add_column("Completion")
|
75
|
+
table.add_column("Status")
|
76
|
+
table.add_column("Sponsor")
|
77
|
+
|
78
|
+
todo_items = m_client.find_to_do("*", starts_with=True)
|
79
|
+
|
80
|
+
if todo_items is None:
|
81
|
+
name = " "
|
82
|
+
type_name = " "
|
83
|
+
created = " "
|
84
|
+
priority = " "
|
85
|
+
due = " "
|
86
|
+
completed = " "
|
87
|
+
status = " "
|
88
|
+
sponsor = " "
|
89
|
+
else:
|
90
|
+
for item in todo_items:
|
91
|
+
props = item["properties"]
|
92
|
+
name = props["name"]
|
93
|
+
type_name = props.get("toDoType", " ")
|
94
|
+
created = props.get("creationTime", " ")
|
95
|
+
priority = str(props.get("priority", " "))
|
96
|
+
due = props.get("dueTime", " ")
|
97
|
+
completed = props.get("completionTime", " ")
|
98
|
+
status = props.get("status")
|
99
|
+
# assigned_actors = item["assignedActors"]
|
100
|
+
# sponsor = assigned_actors[0].get("uniqueName", " ")
|
101
|
+
sponsor = "erinoverview"
|
102
|
+
if status in ("WAITING", "OPEN"):
|
103
|
+
status = f"[yellow]{status}"
|
104
|
+
elif status in ("INPROGRESS", "COMPLETE"):
|
105
|
+
status = f"[green]{status}"
|
106
|
+
else:
|
107
|
+
status = f"[red]{status}"
|
108
|
+
|
109
|
+
table.add_row(
|
110
|
+
name, type_name, created, priority, due, completed, status, sponsor
|
111
|
+
)
|
112
|
+
|
113
|
+
return table
|
114
|
+
|
115
|
+
try:
|
116
|
+
with Live(generate_table(), refresh_per_second=4, screen=True) as live:
|
117
|
+
while True:
|
118
|
+
time.sleep(2)
|
119
|
+
live.update(generate_table())
|
120
|
+
live.console.pager()
|
121
|
+
|
122
|
+
except (InvalidParameterException, PropertyServerException, UserNotAuthorizedException) as e:
|
123
|
+
print_exception_response(e)
|
124
|
+
assert e.related_http_code != "200", "Invalid parameters"
|
125
|
+
finally:
|
126
|
+
m_client.close_session()
|
127
|
+
|
128
|
+
|
129
|
+
if __name__ == "__main__":
|
130
|
+
parser = argparse.ArgumentParser()
|
131
|
+
parser.add_argument("--server", help="Name of the view server to connect to")
|
132
|
+
parser.add_argument("--url", help="URL Platform to connect to")
|
133
|
+
parser.add_argument("--userid", help="User Id")
|
134
|
+
args = parser.parse_args()
|
135
|
+
|
136
|
+
server = args.server if args.server is not None else "view-server"
|
137
|
+
url = args.url if args.url is not None else "https://localhost:9443"
|
138
|
+
userid = args.userid if args.userid is not None else 'erinoverview'
|
139
|
+
print(f"Starting display_todos with {server}, {url}, {userid}")
|
140
|
+
display_todos(server=server, url=url, user=userid)
|
@@ -0,0 +1,105 @@
|
|
1
|
+
#!python
|
2
|
+
"""
|
3
|
+
SPDX-License-Identifier: Apache-2.0
|
4
|
+
Copyright Contributors to the ODPi Egeria project.
|
5
|
+
|
6
|
+
Unit tests for the Utils helper functions using the Pytest framework.
|
7
|
+
|
8
|
+
|
9
|
+
A simple server status display
|
10
|
+
"""
|
11
|
+
|
12
|
+
import time
|
13
|
+
import argparse
|
14
|
+
|
15
|
+
from pyegeria._exceptions import (
|
16
|
+
InvalidParameterException,
|
17
|
+
PropertyServerException,
|
18
|
+
UserNotAuthorizedException,
|
19
|
+
print_exception_response,
|
20
|
+
)
|
21
|
+
from rich.table import Table
|
22
|
+
from rich.live import Live
|
23
|
+
|
24
|
+
from pyegeria.server_operations import ServerOps
|
25
|
+
|
26
|
+
disable_ssl_warnings = True
|
27
|
+
|
28
|
+
good_platform1_url = "https://127.0.0.1:9443"
|
29
|
+
good_platform2_url = "https://egeria.pdr-associates.com:7443"
|
30
|
+
bad_platform1_url = "https://localhost:9443"
|
31
|
+
|
32
|
+
|
33
|
+
good_user_1 = "garygeeke"
|
34
|
+
good_user_2 = "erinoverview"
|
35
|
+
bad_user_1 = "eviledna"
|
36
|
+
bad_user_2 = ""
|
37
|
+
|
38
|
+
good_server_1 = "active-metadata-store"
|
39
|
+
good_server_2 = "simple-metadata-store"
|
40
|
+
good_server_3 = "view-server"
|
41
|
+
good_server_4 = "engine-host"
|
42
|
+
bad_server_1 = "coco"
|
43
|
+
bad_server_2 = ""
|
44
|
+
|
45
|
+
|
46
|
+
def test_display_status(server: str = good_server_1, url: str = good_platform2_url, username: str = good_user_1):
|
47
|
+
p_client = ServerOps(server, url, username)
|
48
|
+
|
49
|
+
def generate_table() -> Table:
|
50
|
+
"""Make a new table."""
|
51
|
+
table = Table(
|
52
|
+
title=f"Server Status for Platform - {time.asctime()}",
|
53
|
+
# style = "black on grey66",
|
54
|
+
header_style="white on dark_blue",
|
55
|
+
caption=f"Server Status for Platform - '{url}'",
|
56
|
+
# show_lines=True,
|
57
|
+
)
|
58
|
+
|
59
|
+
table.add_column("Known Server")
|
60
|
+
table.add_column("Status")
|
61
|
+
|
62
|
+
known_server_list = p_client.get_known_servers()
|
63
|
+
active_server_list = p_client.get_active_server_list()
|
64
|
+
if len(known_server_list) == 0:
|
65
|
+
return table
|
66
|
+
|
67
|
+
for server in known_server_list:
|
68
|
+
if server in active_server_list:
|
69
|
+
status = "Active"
|
70
|
+
else:
|
71
|
+
status = "Inactive"
|
72
|
+
|
73
|
+
table.add_row(server,
|
74
|
+
"[red]Inactive" if status == "Inactive" else "[green]Active",
|
75
|
+
)
|
76
|
+
# p_client.close_session()
|
77
|
+
return table
|
78
|
+
|
79
|
+
try:
|
80
|
+
with Live(generate_table(), refresh_per_second=4, screen=True) as live:
|
81
|
+
while True:
|
82
|
+
time.sleep(2)
|
83
|
+
live.update(generate_table())
|
84
|
+
# services = p_client.get_server_status(server)['serverStatus']['services']
|
85
|
+
# for service in services:
|
86
|
+
# service_name = service['serviceName']
|
87
|
+
# service_status = service['serviceStatus']
|
88
|
+
|
89
|
+
except (InvalidParameterException, PropertyServerException, UserNotAuthorizedException) as e:
|
90
|
+
print_exception_response(e)
|
91
|
+
assert e.related_http_code != "200", "Invalid parameters"
|
92
|
+
|
93
|
+
|
94
|
+
if __name__ == "__main__":
|
95
|
+
parser = argparse.ArgumentParser()
|
96
|
+
parser.add_argument("--server", help="Name of the server to display status for")
|
97
|
+
parser.add_argument("--url", help="URL Platform to connect to")
|
98
|
+
parser.add_argument("--userid", help="User Id")
|
99
|
+
args = parser.parse_args()
|
100
|
+
|
101
|
+
server = args.server if args.server is not None else "active-metadata-store"
|
102
|
+
url = args.url if args.url is not None else "https://localhost:9443"
|
103
|
+
userid = args.userid if args.userid is not None else 'garygeeke'
|
104
|
+
|
105
|
+
test_display_status(server, url, userid)
|