mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 14:01:15 +02:00
Update package versions.
Do not use Path in schemas (causes issues with empty paths). Change how notifications are handled. Run tests with Python 3.9
This commit is contained in:
1 parent
bf19da1dc2
commit
acc5c7ebfa
26 files changed
+121
-134
No files matched your search
@@ -30,7 +30,7 @@ class Notification:
|
||||
def __init__(self, controller):
|
||||
self._controller = controller
|
||||
self._project_listeners = {}
|
||||
self._controller_listeners = []
|
||||
self._controller_listeners = set()
|
||||
|
||||
@contextmanager
|
||||
def project_queue(self, project_id):
|
||||
@@ -39,6 +39,7 @@ class Notification:
|
||||
|
||||
Use it with Python with
|
||||
"""
|
||||
|
||||
queue = NotificationQueue()
|
||||
self._project_listeners.setdefault(project_id, set())
|
||||
self._project_listeners[project_id].add(queue)
|
||||
@@ -54,8 +55,9 @@ class Notification:
|
||||
|
||||
Use it with Python with
|
||||
"""
|
||||
|
||||
queue = NotificationQueue()
|
||||
self._controller_listeners.append(queue)
|
||||
self._controller_listeners.add(queue)
|
||||
try:
|
||||
yield queue
|
||||
finally:
|
||||
@@ -100,6 +102,7 @@ class Notification:
|
||||
:param event: Event to send
|
||||
:param compute_id: Compute id of the sender
|
||||
"""
|
||||
|
||||
if action == "node.updated":
|
||||
try:
|
||||
# Update controller node data and send the event node.updated
|
||||
|
||||
@@ -100,7 +100,7 @@ class Project:
|
||||
# Disallow overwrite of existing project
|
||||
if project_id is None and path is not None:
|
||||
if os.path.exists(path):
|
||||
raise ControllerForbiddenError("The path {} already exist.".format(path))
|
||||
raise ControllerForbiddenError("The path {} already exists".format(path))
|
||||
|
||||
if project_id is None:
|
||||
self._id = str(uuid4())
|
||||
@@ -128,7 +128,6 @@ class Project:
|
||||
self.dump()
|
||||
|
||||
self._iou_id_lock = asyncio.Lock()
|
||||
|
||||
log.debug('Project "{name}" [{id}] loaded'.format(name=self.name, id=self._id))
|
||||
|
||||
def emit_notification(self, action, event):
|
||||
|
||||
@@ -99,13 +99,13 @@ class Template:
|
||||
if builtin is False:
|
||||
try:
|
||||
template_schema = TEMPLATE_TYPE_TO_SHEMA[self.template_type]
|
||||
template_settings_with_defaults = template_schema .parse_obj(self.__json__())
|
||||
self._settings = jsonable_encoder(template_settings_with_defaults.dict())
|
||||
template_settings_with_defaults = template_schema.parse_obj(self.__json__())
|
||||
self._settings = template_settings_with_defaults.dict()
|
||||
if self.template_type == "dynamips":
|
||||
# special case for Dynamips to cover all platform types that contain specific settings
|
||||
dynamips_template_schema = DYNAMIPS_PLATFORM_TO_SHEMA[self._settings["platform"]]
|
||||
dynamips_template_settings_with_defaults = dynamips_template_schema.parse_obj(self.__json__())
|
||||
self._settings = jsonable_encoder(dynamips_template_settings_with_defaults.dict())
|
||||
self._settings = dynamips_template_settings_with_defaults.dict()
|
||||
except ValidationError as e:
|
||||
print(e) #TODO: handle errors
|
||||
raise
|
||||
|
||||
Reference in new issue
Block a user