auth/changePassword.py
Go to the documentation of this file.
1 #! /usr/bin/env python
2 
3 """
4 usage: %(progname)s username
5 """
6 
7 
8 import nstart
9 import os, sys, string, time, getopt
10 
11 from pyclearsilver.log import *
12 
13 import config
14 
15 from pyclearsilver import odb, hdfhelp, odb_sqlite3
16 from pyclearsilver import CSPage
17 
18 from pyclearsilver.odb import *
19 import db_auth
20 
21 
22 
23 def changePassword(db, username, password):
24  row = db.users.lookup(username)
25  row.setPassword(password)
26  row.changePassword = 1
27  row.save()
28 
29 
30 def usage(progname):
31  print __doc__ % vars()
32 
33 def main(argv, stdout, environ):
34  progname = argv[0]
35  optlist, args = getopt.getopt(argv[1:], "", ["help", "test", "debug"])
36 
37  testflag = 0
38  if len(args) != 1:
39  usage(progname)
40  return
41 
42  for (field, val) in optlist:
43  if field == "--help":
44  usage(progname)
45  return
46  elif field == "--debug":
47  debugfull()
48  elif field == "--test":
49  testflag = 1
50 
51  if testflag:
52  test()
53  return
54 
55  db = db_auth.initSchema(create=0)
56 
57  username = args[0]
58  import getpass
59  password1 = getpass.getpass("Password 1:")
60  password2 = getpass.getpass("Password 2:")
61  if password1 != password2:
62  print "password mismatch."
63  return
64 
65  changePassword(db, username, password1)
66 
67 
68 
69 
70 if __name__ == "__main__":
71  main(sys.argv, sys.stdout, os.environ)
72 
73 
74 
def main(argv, stdout, environ)
def changePassword(db, username, password)


webui
Author(s): Scott Hassan
autogenerated on Mon Jun 10 2019 15:51:24