Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Abente <martin.abente.lahaye@gmail.com>2011-03-24 14:32:40 (GMT)
committer Martin Abente <martin.abente.lahaye@gmail.com>2011-03-24 14:32:40 (GMT)
commitbe622a33cdd4f1c999a81f610b4099769cef1617 (patch)
tree08b9eb86321a8a43dc230845a386a41ebcfd0eaf
parent013e2327af4bf9c9d8545f4a7a865353f05a6614 (diff)
Improve email body format
-rwxr-xr-xreports_mailer.py56
-rw-r--r--sugar-fbserver.spec5
2 files changed, 52 insertions, 9 deletions
diff --git a/reports_mailer.py b/reports_mailer.py
index d81d703..fd4bd7b 100755
--- a/reports_mailer.py
+++ b/reports_mailer.py
@@ -36,9 +36,28 @@ SMTP_PASSWORD = ''
SMTP_SERVER = ''
SMTP_PORT = 0
-CUSTOM_SUBJECT = 'custom.feedback.report'
+CUSTOM_SUBJECT = '[custom.feedback.report]'
UNKNOWN_SUBJECT = '???'
+CUSTOM_BODY = '''
+Reported: %s
+Nickname: %s
+Serial number: %s
+Jabber server: %s
+Message:
+
+%s
+
+'''
+
+AUTOMATIC_BODY = '''
+Reported: %s
+Component: %s
+Type: %s
+Ocurrences: %s
+
+'''
+
def send_email(message):
mail_server = smtplib.SMTP(SMTP_SERVER, SMTP_PORT)
mail_server.ehlo()
@@ -76,19 +95,36 @@ def prepare_message(subject, body, report_path):
return message
-def generate_body(info_data, report_info_path):
+def generate_body(info, report_info_path):
report_time = time.ctime(os.path.getctime(report_info_path))
- return ('%s\n\nReported at %s.' % (info_data, report_time))
+
+ if 'serial_number' in info:
+ body = CUSTOM_BODY % (
+ report_time,
+ info.get('nick', ''),
+ info.get('serial_number', ''),
+ info.get('jabber_server', ''),
+ info.get('message', ''))
+ else:
+ body = ''
+ for component in info:
+ for bugtype in info[component]:
+ ocurrences = info[component][bugtype]
+ body += AUTOMATIC_BODY % (
+ report_time,
+ component,
+ bugtype,
+ ocurrences)
+
+ return body
def generate_subject(info):
if 'serial_number' in info:
subject = CUSTOM_SUBJECT
else:
- subject = UNKNOWN_SUBJECT
- if len(info.keys()) > 0:
- subject = info.keys()[0]
+ subject = '[%s]' % ','.join(info.keys())
- return ('[%s]' % subject)
+ return subject
def check_reports():
for report in os.listdir(REPORTS_PATH):
@@ -112,7 +148,11 @@ def check_reports():
print 'Error while parsing %s: %s' % (report_info_path, str(e))
continue
- body = generate_body(report_data, report_info_path)
+ if len(report_info.keys()) <= 0:
+ print 'Empty report %s.' % report_info_path
+ continue
+
+ body = generate_body(report_info, report_info_path)
subject = generate_subject(report_info)
message = prepare_message(subject, body, report_path)
diff --git a/sugar-fbserver.spec b/sugar-fbserver.spec
index e786654..d2e48c9 100644
--- a/sugar-fbserver.spec
+++ b/sugar-fbserver.spec
@@ -1,6 +1,6 @@
Name: sugar-fbserver
Version: 0.2
-Release: 2
+Release: 3
Vendor: Activity Central
Summary: Sugar debugging feedback server
Group: Applications/Internet
@@ -59,6 +59,9 @@ chkconfig --level 345 fbserverd off
%changelog
+* Thu Mar 24 2011 Martin Abente. <martin.abente.lahaye@gmail.com>
+- Improved email body content format
+
* Wed Mar 23 2011 Martin Abente. <martin.abente.lahaye@gmail.com>
- Add feedback mailer script
- Robustness enhancements