SHARE
TWEET

Untitled

a guest Jun 18th, 2019 93 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. test.py -lu="aa" -lp="kkk" -ju="nnn" -jp="hhhh" -nc="ffff" -np="ppppp"
  2.      
  3. import argparse
  4. import os
  5.  
  6. def get_credentials_from_file():
  7.   luser = None
  8.   lpassword = None
  9.   juser = None
  10.   puser = None
  11.  
  12.   try:
  13.     "have some code works file"
  14.   except Exception as e:
  15.     print("Could not get credentials from file.properties: {}".format(e.message))
  16.  
  17.   return luser, lpassword, juser, puser
  18.  
  19. def create_bat_file_for_test(luser=None,lpassword=None,juser=None,jpassword=None,puser=None,ppassword=None):
  20.   with open(r"a.txt", "r+") as file:
  21.     data = file.readlines()
  22.     for line in data:
  23.       a = line.split('=')
  24.       BType = a[0]
  25.       fName = a[1]
  26.       Key = a[2]
  27.       f= open("{}.bat".format(fName),"w+")
  28.       f.write("@ECHO OFFn")
  29.       f.write("SET aa={}n".format(luser))
  30.       f.write("SET bb={}n".format(lpassword))
  31.       f.write("SET bb={}n".format(puser))
  32.       f.write("SET dd={}n".format(ppassword))
  33.       f.write("SET ee={}n".format(juser))
  34.       f.write("SET ff={}n".format(jpassword))
  35.       f.close()
  36.  
  37. def ask_for_input_to_fill_batch_file(luser=None,lpassword=None,juser=None,jpassword=None,puser=None,ppassword=None):
  38.   luser = raw_input("Enter the ldap user name: ")
  39.   lpassword = raw_input("Enter the ldap password: ")
  40.   juser = raw_input("Enter the JiraUser name: ")
  41.   jpassword = raw_input("Enter the JiraPassword: ")
  42.   puser = raw_input("Enter the NCUser name: ")
  43.   ppassword = raw_input("Enter the NCPassword: ")
  44. def main():
  45.   parser = argparse.ArgumentParser(description="Bootstrap to setup environment")
  46.   parser.add_argument("-lu", "--luser", dest="luser", default=None, help="username")
  47.   parser.add_argument("-lp", "--lppassword", dest="lppassword", default=None, help="password")
  48.   parser.add_argument("-ju", "--juser", dest="juser", default=None, help="Jira user")
  49.   parser.add_argument("-jp", "--jpassword", dest="jpassword", default=None, help="Jxxx Password")
  50.   parser.add_argument("-nc", "--puser", dest="puser", default=None, help="Port user")
  51.   parser.add_argument("-np", "--ppassword", dest="ppassword", ", default=None, help="Port Password")
  52.  
  53.   args = parser.parse_args()
  54.  
  55.   luser = args.luser
  56.   lpassword = args.lpassword
  57.   juser = args.juser
  58.   jpassword = args.jpassword
  59.   puser = args.puser
  60.   ppassword = args.ppassword
  61.   if luser is None or lpassword is None or juser is None or puser is None:
  62.     luser, lpassword, juser, puser = get_credentials_from_file()
  63.  
  64.  
  65.   ask_for_input_to_fill_batch_file(luser=luser,lpassword=lpassword,juser=juser,jpassword=jpassword,puser=puser,ppassword=ppassword)
  66.  
  67.   create_bat_file_for_test(luser,lpassword,juser,jpassword,puser,ppassword)
  68.  
  69. if __name__ == "__main__":
  70.   main()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top