changePassword.py
Go to the documentation of this file.
00001 #! /usr/bin/env python
00002 
00003 """
00004 usage: %(progname)s username
00005 """
00006 
00007 
00008 import nstart
00009 import os, sys, string, time, getopt
00010 
00011 from pyclearsilver.log import *
00012 
00013 import config
00014 
00015 from pyclearsilver import odb, hdfhelp, odb_sqlite3
00016 from pyclearsilver import CSPage
00017 
00018 from pyclearsilver.odb import *
00019 import db_auth
00020 
00021 
00022 
00023 def changePassword(db, username, password):
00024   row = db.users.lookup(username)
00025   row.setPassword(password)
00026   row.changePassword = 1
00027   row.save()
00028 
00029 
00030 def usage(progname):
00031   print __doc__ % vars()
00032 
00033 def main(argv, stdout, environ):
00034   progname = argv[0]
00035   optlist, args = getopt.getopt(argv[1:], "", ["help", "test", "debug"])
00036 
00037   testflag = 0
00038   if len(args) != 1:
00039     usage(progname)
00040     return
00041 
00042   for (field, val) in optlist:
00043     if field == "--help":
00044       usage(progname)
00045       return
00046     elif field == "--debug":
00047       debugfull()
00048     elif field == "--test":
00049       testflag = 1
00050 
00051   if testflag:
00052     test()
00053     return
00054 
00055   db = db_auth.initSchema(create=0)
00056 
00057   username = args[0]
00058   import getpass
00059   password1 = getpass.getpass("Password 1:")
00060   password2 = getpass.getpass("Password 2:")
00061   if password1 != password2:
00062     print "password mismatch."
00063     return
00064 
00065   changePassword(db, username, password1)
00066     
00067 
00068 
00069 
00070 if __name__ == "__main__":
00071   main(sys.argv, sys.stdout, os.environ)
00072 
00073   
00074   


webui
Author(s): Scott Hassan/hassan@willowgarage.com
autogenerated on Sat Dec 28 2013 17:47:58