Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def cmd_parse():
- """
- init for main function
- :rtype : object
- """
- # cmd line arguments
- parser = argparse.ArgumentParser(description='An RDM client used to talk to SmartGreen system',
- formatter_class=argparse.ArgumentDefaultsHelpFormatter)
- parser.add_argument('--config', default="RDM_config.txt",
- help="This is the location of the config file.")
- parser.add_argument("-v", "--verbose", action="store_true",
- help="This sets log level to debug and will show suds requests and other info"
- " useful for debug, log is at RDM_reader.log")
- warnings.filterwarnings("error")
- args = parser.parse_args()
- if args.verbose:
- logging.basicConfig(filename='RDM_reader.log', level=logging.DEBUG,
- format='%(asctime)s %(message)s')
- else:
- logging.basicConfig(filename='RDM_reader.log', level=logging.WARNING,
- format='%(asctime)s %(message)s')
- return args.config
- class Main:
- def __init__(self):
- try:
- config = ConfigParser.ConfigParser()
- config.read(cmd_parse())
- self.sql_data = dict(host=config.get("MySQLConfig", "host"),
- user=config.get("MySQLConfig", "username"),
- passwd=config.get("MySQLConfig", "password"),
- db=config.get("MySQLConfig", "database"))
- self.wsdl_data = dict(username=config.get("WSDLConfig", "username"),
- password=config.get("WSDLConfig", "password"))
- except TypeError:
- logging.warning("The program needs a functioning config file")
- return
- if 'RDMConfig_overides' in config.sections():
- self.source_config = 'RDMConfig_overides'
- else:
- self.source_config = 'RDMConfig_default'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement