Skip to content
Snippets Groups Projects
Commit dca43310 authored by Eterevskiy Georgiy's avatar Eterevskiy Georgiy
Browse files

Merge branch 'feature/add-space-to-ext' into 'master'

Исправлена ошибка в методе uninstall

See merge request !71
parents c8ffc5eb 05ad2398
No related branches found
Tags v1.7.1
1 merge request!71Исправлена ошибка в методе uninstall
Pipeline #57256 passed with stage
in 31 seconds
......@@ -15,7 +15,7 @@ from perxis.items import items_pb2_grpc, items_pb2
from perxis.common import common_pb2
from perxis.clients import clients_pb2_grpc, clients_pb2
from perxis.environments import environments_pb2_grpc, environments_pb2
from perxis.extensions.actions import make_action_item, make_action_struct, ACTIONS_COLLECTION_ID
from perxis.extensions.actions import make_action_item, ACTIONS_COLLECTION_ID
logger = logging.getLogger(__name__)
......@@ -491,7 +491,7 @@ class ExtensionSetup:
action_item = make_action_item(space_id, env_id, action)
try:
r = await self.items_service.Update(
await self.items_service.Update(
items_pb2.UpdateRequest(
item=items_pb2.Item(
id=action_item.id,
......@@ -508,6 +508,10 @@ class ExtensionSetup:
continue
not_found = True
except Exception as e:
errors_list.append(f"Не удалось обновить действие {action_item.id}, {e}")
continue
if not_found:
try:
......@@ -518,6 +522,10 @@ class ExtensionSetup:
)
except grpc.RpcError as e:
errors_list.append(f"Не удалось создать действие {action_item.id}, {e.details()}")
except Exception as e:
errors_list.append(f"Не удалось создать действие {action_item.id}, {e}")
continue
try:
await self.items_service.Publish(
......@@ -526,40 +534,26 @@ class ExtensionSetup:
)
)
except grpc.RpcError as e:
errors_list.append(f"Не удалось опубликовать действие {action_item.id}, {e.details()}")
# Если action уже опубликован
if "item cannot be published in this state" not in e.details():
errors_list.append(f"Не удалось опубликовать действие {action_item.id}, {e.details()}")
except Exception as e:
errors_list.append(f"Не удалось опубликовать действие {action_item.id}, {e}")
return errors_list
async def __remove_actions(self, space_id: str, env_id: str) -> list[str]:
errors_list = []
for action in self.actions:
action_item = make_action_item(space_id, env_id, action)
try:
await self.items_service.Unpublish(
items_pb2.UnpublishRequest(
item=items_pb2.Item(
id=action_item.id,
space_id=action_item.space_id,
env_id=action_item.env_id,
collection_id=action_item.collection_id,
)
)
)
except grpc.RpcError as e:
if "not found" not in e.details():
errors_list.append(f"Не удалось снять с публикации действие {action.get('id', 'n/a')}, {e.details()}")
try:
await self.items_service.Delete(
items_pb2.DeleteRequest(
space_id=space_id,
env_id=env_id,
item=items_pb2.Item(
id=action_item.id,
space_id=action_item.space_id,
env_id=action_item.env_id,
space_id=space_id,
env_id=env_id,
collection_id=action_item.collection_id,
),
options=items_pb2.DeleteOptions(
......@@ -572,6 +566,8 @@ class ExtensionSetup:
# Отсутствие действия это не ошибка
if "not found" not in e.details():
errors_list.append(f"Не удалось удалить действие {action.get('id', 'n/a')}, {e.details()}")
except Exception as e:
errors_list.append(f"Не удалось удалить действие - {e}")
return errors_list
......@@ -605,7 +601,6 @@ class ExtensionSetup:
async def uninstall(self, space_id: str, env_id: str, use_remove: bool) -> list[str]:
errors = []
if use_remove:
errors += await self.__remove_collections(space_id, env_id)
errors += await self.__remove_clients(space_id)
......
......@@ -14,7 +14,7 @@ def load_requirements():
setup(
name='perxis',
version='1.7.0',
version='1.7.1',
description='Perxis python client',
long_description=long_description,
long_description_content_type='text/markdown',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment