Skip to content

Commit ec06cbf

Browse files
committed
report script
1 parent c5f84c7 commit ec06cbf

File tree

1 file changed

+13
-23
lines changed

1 file changed

+13
-23
lines changed

report.py

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import datetime
77
#~ import smtplib
88
import mimetypes
9-
from optparse import OptionParser
9+
import argparse
1010
from email import encoders
1111
from email.message import Message
1212
from email.mime.multipart import MIMEMultipart
@@ -80,26 +80,16 @@ def makecsv(datestr):
8080
return open(filename).read()
8181

8282
if __name__=='__main__':
83-
#~ parser = OptionParser(usage="""\
84-
#~ XXX TODO FILLIN""")
85-
#~ parser.add_option('-d', '--directory',
86-
#~ type='string', action='store',
87-
#~ help="""Mail the contents of the specified directory,
88-
#~ otherwise use the current directory. Only the regular
89-
#~ files in the directory are sent, and we don't recurse to
90-
#~ subdirectories.""")
91-
#~ parser.add_option('-o', '--output',
92-
#~ type='string', action='store', metavar='FILE',
93-
#~ help="""Print the composed message to FILE instead of
94-
#~ sending the message to the SMTP server.""")
95-
#~ parser.add_option('-s', '--sender',
96-
#~ type='string', action='store', metavar='SENDER',
97-
#~ help='The value of the From: header (required)')
98-
#~ parser.add_option('-r', '--recipient',
99-
#~ type='string', action='append', metavar='RECIPIENT',
100-
#~ default=[], dest='recipients',
101-
#~ help='A To: header value (at least one required)')
102-
#~ opts, args= parser.parse_args()
83+
parser= argparse.ArgumentParser(description="""\
84+
Usage report script for catgraph-jsonp""")
85+
parser.add_argument('-m', '--month',
86+
metavar='MONTH',
87+
help='month, in %%Y-%%m format')
88+
89+
args= parser.parse_args()
10390

104-
last_month= datetime.date.fromtimestamp(time.time() - 1*60*60*24).strftime('%Y-%m')
105-
print_report('catgraph-jsonp@tools.wmflabs.org', ['johannes.kroll@wikimedia.de'], last_month, makecsv(last_month))
91+
if args.month:
92+
month= args.month
93+
else:
94+
month= datetime.date.fromtimestamp(time.time() - 1*60*60*24).strftime('%Y-%m')
95+
print_report('catgraph-jsonp@tools.wmflabs.org', ['johannes.kroll@wikimedia.de'], month, makecsv(month))

0 commit comments

Comments
 (0)