test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
update_db_credential Namespace Reference

Functions

def main
 
def update_credential
 

Function Documentation

def update_db_credential.main ( )

Definition at line 13 of file update_db_credential.py.

References update_credential().

13 
14 def main():
15 
16  parser = optparse.OptionParser(usage =
17  'Usage: %prog <file> [<file> ...]\n'
18  )
19 
20  parser.add_option('-s', '--service',
21  dest = 'service',
22  help = 'the service hosting the account'
23  )
24 
25  parser.add_option('-a','--accountName',
26  dest = 'accountName',
27  help = 'the account name to change'
28  )
29 
30  (options, arguments) = parser.parse_args()
31 
32  if options.service == None or options.accountName == None:
33  parser.print_help()
34  return -2
35 
36  password = getpass.getpass( prompt= 'Enter the new password:')
37 
38  try:
39  print update_credential( options.service, options.accountName, password )
40  print 'Password changed.'
41  except e:
print 'Update credential failed.'
def update_db_credential.update_credential (   serviceName,
  accountName,
  newPassword 
)

Definition at line 7 of file update_db_credential.py.

Referenced by main().

7 
8 def update_credential( serviceName, accountName, newPassword ):
9  command = 'cmscond_authentication_manager --update_conn -s %s -u %s -p %s' %(serviceName, accountName, newPassword )
10  pipe = subprocess.Popen( command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT )
11  stdout_val = pipe.communicate()[0]
12  return stdout_val