## Comment stuff
- def comment(self, *args, **kwargs):
+ async def comment(self, *args, **kwargs):
"""
Submits a comment
"""
# Create a new comment
- comment = self.backend.builds.comments.create(self, *args, **kwargs)
+ comment = await self.backend.builds.comments.create(self, *args, **kwargs)
# Add to cache
self.comments.append(comment)
# Notify everyone this build has finished...
if success:
- self._send_email("builds/messages/finished.txt")
+ await self._send_email("builds/messages/finished.txt")
# ... or that it has failed
else:
- self._send_email("builds/messages/failed.txt")
+ await self._send_email("builds/messages/failed.txt")
# Create any test builds
if success:
"""
return self.has_finished() and not self.data.failed
- def _send_email(self, *args, exclude=None, **kwargs):
+ async def _send_email(self, *args, exclude=None, **kwargs):
"""
Convenience function which sends an email to everybody who would care
"""
self.add_points(-2)
# Send an email on fail
- self._send_email("builds/messages/test-builds-failed.txt",
+ await self._send_email("builds/messages/test-builds-failed.txt",
build=self, test_builds=self.test_builds)
""", id,
)
- def create(self, build, user, text=None):
+ async def create(self, build, user, text=None):
comment = self._get_comment("""
INSERT INTO
build_comments(
)
# Notify people about this new comment
- comment.notify()
+ await comment.notify()
return comment
def text(self):
return self.data.text
- def notify(self):
+ async def notify(self):
"""
Notifies all watchers about this comment (except the user who posted it)
"""
- self.build._send_email("builds/messages/comment.txt",
+ await self.build._send_email("builds/messages/comment.txt",
exclude=[self.user], build=self.build, comment=self)
class CommentHandler(base.BaseHandler):
@tornado.web.authenticated
- def post(self, uuid):
+ async def post(self, uuid):
build = self.backend.builds.get_by_uuid(uuid)
if not build:
raise tornado.web.HTTPError(404, "Could not find build %s" % uuid)
# Add a new comment to the build
with self.db.transaction():
- build.comment(self.current_user, text)
+ await build.comment(self.current_user, text)
# Redirect to the build
self.redirect("/builds/%s" % build.uuid)