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

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

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


Revision 1.1 - (hide annotations) (download)
Tue Jul 2 20:11:40 2013 UTC (11 years, 4 months ago) by unnilennium
Branch: MAIN
CVS Tags: mailman-2_1_5_1-34_rhel4_6_el5_sme, mailman-2_1_9-6_el5_6_1, mailman-2_1_9-20_el5_sme, mailman-2_1_9-6_el5_sme_20, HEAD
Initial import

1 unnilennium 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