Guest User

Untitled

a guest
Jan 4th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. import sys
  2. import os
  3. import re
  4. from os.path import exists
  5. from sys import argv
  6.  
  7.  
  8. def conn():
  9. connect(USERNAME, PASSWORD, ADMINURL)
  10.  
  11. def store_custom():
  12. storeUserConfig(CONFIGFILE,KEYFILE)
  13.  
  14. def store_default():
  15. storeUserConfig()
  16.  
  17. def get_script_path():
  18. return os.path.dirname(os.path.realpath(sys.argv[0]))
  19.  
  20. def start():
  21. try:
  22. global CONFIGFILE
  23. global KEYFILE
  24. global USERNAME
  25. global PASSWORD
  26. global ADMINURL
  27. global DEFAULTFLAG
  28.  
  29. CONFIGFILE = _dict.get('configfile')
  30. KEYFILE = _dict.get('keyfile')
  31. USERNAME = _dict.get('username')
  32. PASSWORD = _dict.get('password')
  33. ADMINURL = _dict.get('adminurl')
  34. DEFAULTFLAG = _dict.get('defaultflag')
  35.  
  36. if (DEFAULTFLAG != "ON"):
  37. if (CONFIGFILE and KEYFILE and USERNAME and PASSWORD and ADMINURL):
  38. print "\nINFO: Values have been set properly"
  39. conn()
  40. store_custom()
  41. else:
  42. print "\nERROR: Some Essential Keys are missing";
  43. else:
  44. if (USERNAME and PASSWORD and ADMINURL):
  45. print "\nValues have been set properly"
  46. conn()
  47. store_default()
  48. else:
  49. print "\nERROR: Some Essential Keys are missing";
  50. usage()
  51. except:
  52. print "\nERROR: Got Some Error! Please make sure you are executing the script right",sys.exc_info()[0]
  53. usage()
  54.  
  55. # MAIN
  56.  
  57. _dict={}
  58. propfile = get_script_path()+"/store.properties"
  59.  
  60. if exists(propfile):
  61. fileobj = open(propfile, 'r+')
  62. lines = fileobj.readlines()
  63. for line in lines:
  64. mat = re.search(r'(.+)(=)(.+)', line)
  65. if mat:
  66. line = line.rstrip()
  67. key = line.split('=')[0]
  68. value = line.split('=')[1]
  69. _dict[key]=value
  70. if key != "password":
  71. print key+":"+value
  72. else:
  73. print key+":********"
  74. fileobj.close()
  75. start()
  76. else:
  77. print "Unable to find the store.properties in the base location",propfile
  78. sys.exit(2)
Add Comment
Please, Sign In to add comment