1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 """
17 Text based news notifier (via NNTP)
18 """
19 __author__ = "André Malo"
20 __docformat__ = "epytext en"
21 __all__ = ['getNotifier']
22
23
25 """ Returns an initialized notifier or nothing
26
27 @param settings: The svnmailer settings
28 @type settings: C{svnmailer.settings.Settings}
29
30 @param groupset: The groupset to process
31 @type groupset: C{list}
32
33 @return: The list of notifiers (containing 0 or 1 member)
34 @rtype: C{list}
35 """
36 from svnmailer.notifier import _textnews
37
38 cls = None
39 if settings.general.nntp_host:
40 cls = NNTPSubmitter
41
42 if cls:
43 return _textnews.getNotifier(cls, settings, groupset)
44
45 return []
46
47
49 """ Use NNTP to submit the notification as news article """
50 _settings = None
51
53 """ Sends the posting via nntp """
54 import cStringIO, nntplib
55
56 fp = cStringIO.StringIO()
57 try:
58 posting.dump(fp)
59 fp.seek(0)
60
61 general = self._settings.general
62 host, port = (general.nntp_host, nntplib.NNTP_PORT)
63 if ':' in host and host.find(':') == host.rfind(':'):
64 host, port = host.split(':', 1)
65
66 conn = nntplib.NNTP(
67 host = host, port = int(port), readermode = True,
68 user = general.nntp_user, password = general.nntp_pass,
69 )
70 conn.post(fp)
71 conn.quit()
72 finally:
73 fp.close()
74