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 | |
---|
4 | import sys |
---|
5 | import os |
---|
6 | import time |
---|
7 | import stat |
---|
8 | import datetime |
---|
9 | |
---|
10 | from gluon.utils import md5_hash |
---|
11 | from gluon.restricted import RestrictedError |
---|
12 | from gluon.tools import Mail |
---|
13 | |
---|
14 | |
---|
15 | path = os.path.join(request.folder, 'errors') |
---|
16 | hashes = {} |
---|
17 | mail = Mail() |
---|
18 | |
---|
19 | ### CONFIGURE HERE |
---|
20 | SLEEP_MINUTES = 5 |
---|
21 | ALLOW_DUPLICATES = True |
---|
22 | mail.settings.server = 'localhost:25' |
---|
23 | mail.settings.sender = 'you@localhost' |
---|
24 | administrator_email = 'you@localhost' |
---|
25 | ### END CONFIGURATION |
---|
26 | |
---|
27 | while 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.