summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael G. Martins <rafael.martins@collabora.com>2012-07-12 22:04:55 (GMT)
committerRafael G. Martins <rafael.martins@collabora.com>2012-07-12 22:04:55 (GMT)
commitf880883648b15fb6b15cd8c59bf462f7b0cb9401 (patch)
tree83a1d00cd3ccb794652a6586fbebd947f73719ed
parente50748b444d1af7fef83e90e1bc2fbf218ddfd68 (diff)
downloadqa-bughandler-f880883648b15fb6b15cd8c59bf462f7b0cb9401.tar.gz
qa-bughandler-f880883648b15fb6b15cd8c59bf462f7b0cb9401.tar.xz
added custom comment support
-rwxr-xr-xqa-bughandler.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/qa-bughandler.py b/qa-bughandler.py
index 4d97cfb..3c2877a 100755
--- a/qa-bughandler.py
+++ b/qa-bughandler.py
@@ -25,6 +25,7 @@
from argparse import ArgumentParser
from ConfigParser import ConfigParser
+from datetime import datetime
from xmlrpclib import ServerProxy
from urlparse import ParseResult, urlparse, urlunparse
import logging
@@ -36,10 +37,6 @@ __version__ = '0.1'
LOG_FORMATTER = "[%(asctime)s] %(name)s.%(levelname)s: %(message)s"
LOG_DATEFORMAT = "%Y-%m-%d %H:%M:%S %Z"
-COMMENT = '''\
-My random comment!
-'''
-
class Config(object):
"""This class reads some settings from a configuration file. It depends on
@@ -170,10 +167,22 @@ def main():
settings.logger)
bugz.login(settings.config.username, settings.config.password)
bug = bugz.get()
+ now = datetime.utcnow()
+ try:
+ comment_template = settings.config.comment_template
+ except RuntimeError:
+ comment_template = 'Ticket updated by %(script)s, %(date)s ' \
+ '%(time)s %(timezone)s:'
+ comment = comment_template % {'script': 'qa-bughandler',
+ 'date': now.strftime('%Y-%m-%d'),
+ 'time': now.strftime('%H:%M:%S'),
+ 'timezone': 'UTC'}
+ comment = comment.strip() + '\n\n'
for field in fields:
if field not in bug:
raise RuntimeError('Field not found: %s' % field)
- bugz.add_comment(COMMENT)
+ comment += '* %s: %s\n' % (field, fields[field])
+ bugz.add_comment(comment)
bugz.update(**fields)
except Exception, e:
settings.logger.critical('%s: %s', e.__class__.__name__, e)