/[smecontribs]/rpms/mailman/contribs7/mailman-crontab-edit
ViewVC logotype

Annotation of /rpms/mailman/contribs7/mailman-crontab-edit

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (hide annotations) (download)
Tue Nov 25 16:20:13 2008 UTC (15 years, 5 months ago) by slords
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +0 -0 lines
Restore

1 slords 1.1 #!/usr/bin/python
2    
3     # This script inserts the mailman user name into the crontab entries after
4     # the 5 time/date fields so that it can be installed under /etc/cron.d
5     #
6     # usage: mailman-crontab-edit [-s src_file] [-u mailman_user] [-d dst_file]
7     # src_file defaults to stdin
8     # mailman_user defaults to mailman
9     # dst_file defaults to stdout
10    
11     import sys, re, getopt
12    
13     srcFile = None
14     dstFile = None
15     mmUser = None
16    
17     opts, args = getopt.getopt(sys.argv[1:], "s:d:u:")
18     for o, a in opts:
19     if o == "-s":
20     srcFile = a
21     if o == "-d":
22     dstFile = a
23     if o == "-u":
24     mmUser = a
25    
26     if srcFile:
27     inFD = open(srcFile)
28     else:
29     inFD = sys.stdin
30    
31     if dstFile:
32     outFD = open(dstFile, mode='w')
33     else:
34     outFD = sys.stdout
35    
36     if not mmUser:
37     mmUser = "mailman"
38    
39     comment_re = re.compile(r'^\s*#')
40     time_date_re = re.compile(r'(^\s*(\S+\s+){5,5})')
41    
42     for line in inFD:
43     if not comment_re.search(line):
44     match = time_date_re.search(line)
45     if match:
46     line = time_date_re.sub(r'\1 %s ' % mmUser, line)
47     print >>outFD, line,

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed