[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [trac-email/master] Clean up scripts and set log messages



commit 5e70f3018f6515ab3a1165e2096dc6eb13d5dc6e
Author: hiromipaw <hiro@xxxxxxxxxxxxxx>
Date:   Wed Dec 14 12:37:56 2016 +0100

    Clean up scripts and set log messages
---
 notify.py | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/notify.py b/notify.py
index 25992d4..9224231 100755
--- a/notify.py
+++ b/notify.py
@@ -15,7 +15,7 @@ def verify_email_signature(message, user):
     gpg = gnupg.GPG(gnupghome='/home/tracadm/.gnupg')
     verified = gpg.verify(message)
     if verified.trust_level is not None and verified.trust_level >= verified.TRUST_UNDEFINED:
-        with open('bin/map', 'rb') as csvfile:
+        with open('/home/tracadm/bin/map', 'rb') as csvfile:
             keysreader = csv.reader(csvfile, delimiter=' ')
             for row in keysreader:
                 k = row[0]
@@ -50,7 +50,10 @@ def find_or_create_ticket(message, env):
         t_id = ticket_id.group(1)
         tkt = Ticket(env, int(t_id))
         if verify_user_permissions(env, reporter, 'TICKET_MODIFY'):
-            tkt.save_changes(comment=body)
+            if tkt.save_changes(comment=body):
+                return tkt
+            else:
+                return False
     else:
         if verify_user_permissions(env, reporter, 'TICKET_CREATE'):
             summary = message['Subject']
@@ -64,7 +67,10 @@ def find_or_create_ticket(message, env):
             tkt['description'] = body
             tkt['status'] = 'new'
             tkt['priority'] = 'medium'
-            tkt.insert()
+            if tkt.insert():
+                return tkt
+            else:
+                return False
 
 # Open logs file
 with open('/home/tracadm/log/test.log', 'w') as f:
@@ -82,4 +88,10 @@ with open('/home/tracadm/log/test.log', 'w') as f:
     if verified:
         # Find or create ticket
         f.write('GPG verified')
-        find_or_create_ticket(msg, env)
+        tkt = find_or_create_ticket(msg, env)
+        if tkt:
+            f.write(str(tkt))
+        else:
+            f.write('Could not create Ticket. I should send an email back I suppose')
+    else:
+        f.write('Could not verify GPG. I should send an email back I suppose')

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits