source: OpenRLabs-Git/deploy/rlabs-docker/web2py-rlabs/scripts/tickets2email.py @ 42095c5

mainqndtest v1.1.1
Last change on this file since 42095c5 was 42bd667, checked in by David Fuertes <dfuertes@…>, 4 years ago

Historial Limpio

  • Property mode set to 100755
File size: 1.1 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3
4import sys
5import os
6import time
7import stat
8import datetime
9
10from gluon.utils import md5_hash
11from gluon.restricted import RestrictedError
12from gluon.tools import Mail
13
14
15path = os.path.join(request.folder, 'errors')
16hashes = {}
17mail = Mail()
18
19### CONFIGURE HERE
20SLEEP_MINUTES = 5
21ALLOW_DUPLICATES = True
22mail.settings.server = 'localhost:25'
23mail.settings.sender = 'you@localhost'
24administrator_email = 'you@localhost'
25### END CONFIGURATION
26
27while 1:
28    for file in os.listdir(path):
29        if not ALLOW_DUPLICATES:
30            fileobj = open(file, 'r')
31            try:
32                file_data = fileobj.read()
33            finally:
34                fileobj.close()
35            key = md5_hash(file_data)
36
37            if key in hashes:
38                continue
39
40            hashes[key] = 1
41
42        error = RestrictedError()
43        error.load(request, request.application, file)
44
45        mail.send(to=administrator_email,
46                  subject='new web2py ticket', message=error.traceback)
47
48        os.unlink(os.path.join(path, file))
49    time.sleep(SLEEP_MINUTES * 60)
Note: See TracBrowser for help on using the repository browser.