-c text... Comment to use
-r Reject not approve
-h This help
+ -v List emails as processed
Args is a list of email addresses.
"""
# Parse JCL
comment = 'From CLI';
reply = 'y'
-opts, args = getopt.getopt(sys.argv[1:], "c:hr")
+verbose = 0
+opts, args = getopt.getopt(sys.argv[1:], "c:hrv")
for o,a in opts:
if o == '-c':
comment = a
elif o == '-r':
reply = 'n'
+ elif o == '-v':
+ verbose = 1
else:
print __doc__
raise SystemExit
for uid in cursor:
cursor.execute(update, (today, reply, comment, uid[0]))
conn.commit()
+ if verbose:
+ print email, uid[0]
#! /usr/bin/env python
-"""Arguments is a list of SQL paterns (will get wrapped in wildcards, %),
-display uid email and name
+"""finduser [flags] pattern...
+
+Flags:
+ -1 Print just email
+
+Arguments is a list of SQL paterns (will get wrapped in wildcards, %),
+by default display full information as CSV.
"""
import mysql.connector
import datetime, os, re, subprocess, sys, string, random
+import getopt
dbconfig = {
'user': 'licensereader',
cursor = conn.cursor()
raw = open("request-approval.txt").read()
+single = 0
+opts, args = getopt.getopt(sys.argv[1:], "1")
+for o,a in opts:
+ if o == '-1':
+ single = 1
+ else:
+ print __doc__
+ raise SystemExit
+
# Get dict of matching users
-for email in sys.argv[1:]:
+for email in args:
q = ('SELECT users.uid,email,reply,name,count(log.uid) FROM users'
' LEFT JOIN log ON log.uid = users.uid'
- ' WHERE email like %s GROUP BY email' );
+ ' WHERE email like %s GROUP BY email' )
pat = '%' + email + '%'
cursor.execute(q, (pat,))
for row in cursor:
uid,email,reply,name,count = row
if reply == None:
reply = '-'
- print '%d, %s, %s, %d, "%s"' % (uid, email, reply, count, name)
+ if single:
+ print email
+ else:
+ print '%d, %s, %s, %d, "%s"' % (uid, email, reply, count, name)