Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import os
- import re
- from os.path import exists
- from sys import argv
- def conn():
- connect(USERNAME, PASSWORD, ADMINURL)
- def store_custom():
- storeUserConfig(CONFIGFILE,KEYFILE)
- def store_default():
- storeUserConfig()
- def get_script_path():
- return os.path.dirname(os.path.realpath(sys.argv[0]))
- def start():
- try:
- global CONFIGFILE
- global KEYFILE
- global USERNAME
- global PASSWORD
- global ADMINURL
- global DEFAULTFLAG
- CONFIGFILE = _dict.get('configfile')
- KEYFILE = _dict.get('keyfile')
- USERNAME = _dict.get('username')
- PASSWORD = _dict.get('password')
- ADMINURL = _dict.get('adminurl')
- DEFAULTFLAG = _dict.get('defaultflag')
- if (DEFAULTFLAG != "ON"):
- if (CONFIGFILE and KEYFILE and USERNAME and PASSWORD and ADMINURL):
- print "\nINFO: Values have been set properly"
- conn()
- store_custom()
- else:
- print "\nERROR: Some Essential Keys are missing";
- else:
- if (USERNAME and PASSWORD and ADMINURL):
- print "\nValues have been set properly"
- conn()
- store_default()
- else:
- print "\nERROR: Some Essential Keys are missing";
- usage()
- except:
- print "\nERROR: Got Some Error! Please make sure you are executing the script right",sys.exc_info()[0]
- usage()
- # MAIN
- _dict={}
- propfile = get_script_path()+"/store.properties"
- if exists(propfile):
- fileobj = open(propfile, 'r+')
- lines = fileobj.readlines()
- for line in lines:
- mat = re.search(r'(.+)(=)(.+)', line)
- if mat:
- line = line.rstrip()
- key = line.split('=')[0]
- value = line.split('=')[1]
- _dict[key]=value
- if key != "password":
- print key+":"+value
- else:
- print key+":********"
- fileobj.close()
- start()
- else:
- print "Unable to find the store.properties in the base location",propfile
- sys.exit(2)
Add Comment
Please, Sign In to add comment