| 39 | | # Get list of pages |
|---|
| 40 | | q.execute("select name, time, author, comment, version from wiki where time > strftime('%%s','now') - %i order by time desc", int(time_delta)) |
|---|
| 41 | | changes = q.fetchall() |
|---|
| | 58 | # Get list of pages |
|---|
| | 59 | act_time = int(strftime('%s', localtime())) - int(time_delta) |
|---|
| | 60 | q.execute("select name, time, author, comment, version from wiki where time > %s order by time desc" % str(act_time)) |
|---|
| | 61 | changes = q.fetchall() |
|---|
| 49 | | for change in changes: |
|---|
| 50 | | change_time = strftime("%Y/%d/%m %H:%M:%S", localtime(int(change[1]))) |
|---|
| 51 | | smtp_body += " %s (version %s) modified %s by %s" % (change[0], change[4], change_time, change[2]) |
|---|
| 52 | | smtp_body += "\n %swiki/%s?version=%s\n" % (trac_url, change[0], change[4]) |
|---|
| 53 | | if change[3]: smtp_body += " \"%s\"\n" % change[3] |
|---|
| 54 | | smtp_body += "\n" |
|---|
| | 65 | # Create the email-body |
|---|
| | 66 | email_body = "Changes since %s\n\n" % strftime("%Y/%d/%m %H:%M:%S", localtime(time() - float(time_delta))) |
|---|
| 56 | | smtp_body += "You can remove yourself from notifications at this URL:\n %swiki/%s\n" % (trac_url, notify_page) |
|---|
| 57 | | # Send the mail |
|---|
| 58 | | smtp = smtplib.SMTP(smtp_server) |
|---|
| 59 | | smtp.sendmail(smtp_from, smtp_to, smtp_body) |
|---|
| 60 | | smtp.quit() |
|---|
| | 68 | for change in changes: |
|---|
| | 69 | change_time = strftime("%Y/%d/%m %H:%M:%S", localtime(int(change[1]))) |
|---|
| | 70 | email_body += " %s (version %s) modified %s by %s" % (change[0], change[4], change_time, change[2]) |
|---|
| | 71 | email_body += "\n %swiki/%s?version=%s\n" % (trac_url, change[0], change[4]) |
|---|
| | 72 | if change[3]: email_body += " \"%s\"\n" % change[3] |
|---|
| | 73 | email_body += "\n" |
|---|
| | 74 | |
|---|
| | 75 | email_body += "\nYou can remove yourself from notifications at this URL:\n %swiki/%s\n" % (trac_url, notify_page) |
|---|
| | 76 | |
|---|
| | 77 | smtp = smtplib.SMTP(smtp_server) |
|---|
| | 78 | smtp = smtplib.SMTP(smtp_server) |
|---|
| | 79 | # Finish the email |
|---|
| | 80 | for email in smtp_to: |
|---|
| | 81 | smtp_body = "From: %s\n" % smtp_from |
|---|
| | 82 | smtp_body += "To: %s\n" % email |
|---|
| | 83 | smtp_body += "Reply-To: %s\n" % smtp_from |
|---|
| | 84 | smtp_body += "Subject: Notification of %i changes to Trac Wiki %s\n\n" % (len(changes), trac_url) |
|---|
| | 85 | smtp_body += email_body |
|---|
| | 86 | # Send the mail |
|---|
| | 87 | smtp.sendmail(smtp_from, email, smtp_body) |
|---|
| | 88 | |
|---|
| | 89 | smtp.quit() |
|---|
| | 90 | |
|---|
| | 91 | # Write logfile (or not) |
|---|
| | 92 | if len(sys.argv) > 7: |
|---|
| | 93 | fileobj = open(sys.argv[7], 'au') |
|---|
| | 94 | fileobj.write('\n#######################################################\n') |
|---|
| | 95 | fileobj.write('%s\n' % str(strftime('%Y-%m-%d %H:%M:%S', localtime()))) |
|---|
| | 96 | fileobj.write('Trac-Wiki-Notification-Email sent to: %s' % smtp_to) |
|---|
| | 97 | fileobj.write('\n\n %s \n\n' % smtp_body) |
|---|
| | 98 | fileobj.close() |
|---|