#! /usr/bin/env python """approved [flags] args... Flags: -c text... Comment to use -h This help Args is a list of email addresses. """ import datetime, mysql.connector, os, re, subprocess, sys import string, random import getopt dbconfig = { 'user': 'license', 'password': open('rwpass.txt').read().strip(), 'database': 'license' } conn = mysql.connector.connect(**dbconfig) cursor = conn.cursor() # Parse JCL comment = 'From CLI'; opts, args = getopt.getopt(sys.argv[1:], "c:h") for o,a in opts: if o == '-c': comment = a else: print __doc__ raise SystemExit q = 'select uid from users where email = %s' update = ("UPDATE users SET date_replied=%s, reply=%s, comment=%s" " WHERE uid=%s") today = datetime.datetime.today().date() reply = 'y' for email in args: cursor.execute(q, (email,)) for uid in cursor: cursor.execute(update, (today, reply, comment, uid[0])) conn.commit()