Fix long-polling request for project notifications.

This commit is contained in:
grossmj committed 2019-02-23 21:08:52 +07:00
1 parent 10702f87bc
commit 7fe8f7e716
10 files changed
+82 -64

No files matched your search

+3 -3
View File
@@ -405,7 +405,7 @@ class Node:
await self.parse_node_response(response.json)
elif old_json != self.__json__():
# We send notif only if object has changed
self.project.controller.notification.project_emit("node.updated", self.__json__())
self.project.emit_notification("node.updated", self.__json__())
self.project.dump()
async def parse_node_response(self, response):
@@ -563,13 +563,13 @@ class Node:
for directory in images_directories(type):
image = os.path.join(directory, img)
if os.path.exists(image):
self.project.controller.notification.project_emit("log.info", {"message": "Uploading missing image {}".format(img)})
self.project.emit_notification("log.info", {"message": "Uploading missing image {}".format(img)})
try:
with open(image, 'rb') as f:
await self._compute.post("/{}/images/{}".format(self._node_type, os.path.basename(img)), data=f, timeout=None)
except OSError as e:
raise aiohttp.web.HTTPConflict(text="Can't upload {}: {}".format(image, str(e)))
self.project.controller.notification.project_emit("log.info", {"message": "Upload finished for {}".format(img)})
self.project.emit_notification("log.info", {"message": "Upload finished for {}".format(img)})
return True
return False