[chronojump-server] Sends the user comments in the body of the email.
- From: Carles Pina i Estany <carlespina src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump-server] Sends the user comments in the body of the email.
- Date: Sat, 25 Jul 2015 20:36:44 +0000 (UTC)
commit ac3a0760e218cf6879b02e068e434188d34f2fe0
Author: Carles Pina i Estany <carles pina cat>
Date: Sat Jul 25 22:36:29 2015 +0200
Sends the user comments in the body of the email.
email_error_log.py | 22 ++++++++++++++++++++--
1 files changed, 20 insertions(+), 2 deletions(-)
---
diff --git a/email_error_log.py b/email_error_log.py
index 4bb8653..ebc5443 100644
--- a/email_error_log.py
+++ b/email_error_log.py
@@ -5,6 +5,15 @@ import string
config = ConfigParser.ConfigParser()
config.read('/etc/chronojump.conf')
+def user_comments_from_log(log):
+ user_comment_separator = "----------"
+
+ if log.startswith(user_comment_separator):
+ text = log.split(user_comment_separator)[1]
+ return text
+
+ return ""
+
def metadata_to_dictionary(metadata):
"""
Given metadata like "1 5 2 0-email_del_usuari2-o-no usuari com"
@@ -21,11 +30,13 @@ def metadata_to_dictionary(metadata):
def send(metadata_str, attachment_data):
metadata = metadata_to_dictionary(metadata_str)
- d = {}
+ d = {'user_comments':user_comments_from_log(attachment_data)}
body = string.Template("""Hola,
Hi ha un nou error log al servidor.
+$user_comments
+
El Servidor
""").substitute(d)
@@ -49,5 +60,12 @@ El Servidor
emailMsg.as_string())
if __name__ == "__main__":
- data = open("/home/carles/cups-pantalla.png", 'rb').read()
+ data = """----------
+This is a comment
+from the user
+----------
+this is a log
+from C# :-)
+"""
+
send("1 5 2 0-email_del_usuari2 usuari com", data)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]