allura
修訂 | 595cff09d70a91fe4b3ff3320b57b882f9fee5c8 (tree) |
---|---|
時間 | 2012-05-18 06:15:02 |
作者 | Cory Johns <johnsca@geek...> |
Commiter | Jenny Steele |
[#4100] Added email notification on repo clone failure
Signed-off-by: Cory Johns <johnsca@geek.net>
@@ -1,10 +1,13 @@ | ||
1 | 1 | import shutil |
2 | 2 | import logging |
3 | +import traceback | |
3 | 4 | |
4 | 5 | from pylons import c |
5 | 6 | |
6 | 7 | from allura.lib.decorators import task |
7 | 8 | from allura.lib.repository import RepositoryApp |
9 | +from allura.lib import helpers as h | |
10 | +from allura.tasks.mail_tasks import sendmail | |
8 | 11 | |
9 | 12 | @task |
10 | 13 | def init(**kwargs): |
@@ -20,15 +23,28 @@ def clone( | ||
20 | 23 | cloned_from_path, |
21 | 24 | cloned_from_name, |
22 | 25 | cloned_from_url): |
23 | - from allura import model as M | |
24 | - c.app.repo.init_as_clone( | |
25 | - cloned_from_path, | |
26 | - cloned_from_name, | |
27 | - cloned_from_url) | |
28 | - M.Notification.post_user( | |
29 | - c.user, c.app.repo, 'created', | |
30 | - text='Repository %s/%s created' % ( | |
31 | - c.project.shortname, c.app.config.options.mount_point)) | |
26 | + try: | |
27 | + from allura import model as M | |
28 | + c.app.repo.init_as_clone( | |
29 | + cloned_from_path, | |
30 | + cloned_from_name, | |
31 | + cloned_from_url) | |
32 | + M.Notification.post_user( | |
33 | + c.user, c.app.repo, 'created', | |
34 | + text='Repository %s/%s created' % ( | |
35 | + c.project.shortname, c.app.config.options.mount_point)) | |
36 | + except: | |
37 | + sendmail( | |
38 | + destinations=['sfengineers@geek.net'], | |
39 | + fromaddr=u'SourceForge.net <noreply+project-upgrade@in.sf.net>', | |
40 | + reply_to=u'noreply@in.sf.net', | |
41 | + subject=u'SourceForge Repo Clone Failure', | |
42 | + message_id=h.gen_message_id(), | |
43 | + text=u''.join([ | |
44 | + u'Clone of repo %s from %s failed.\n', | |
45 | + u'\n', | |
46 | + u'%s', | |
47 | + ]) % (cloned_from_name, cloned_from_url, traceback.format_exc())) | |
32 | 48 | |
33 | 49 | @task |
34 | 50 | def reclone(*args, **kwargs): |