Advertisement
Guest User

Untitled

a guest
Jan 21st, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. def cmd_parse():
  2. """
  3. init for main function
  4. :rtype : object
  5. """
  6. # cmd line arguments
  7. parser = argparse.ArgumentParser(description='An RDM client used to talk to SmartGreen system',
  8. formatter_class=argparse.ArgumentDefaultsHelpFormatter)
  9. parser.add_argument('--config', default="RDM_config.txt",
  10. help="This is the location of the config file.")
  11. parser.add_argument("-v", "--verbose", action="store_true",
  12. help="This sets log level to debug and will show suds requests and other info"
  13. " useful for debug, log is at RDM_reader.log")
  14. warnings.filterwarnings("error")
  15. args = parser.parse_args()
  16. if args.verbose:
  17. logging.basicConfig(filename='RDM_reader.log', level=logging.DEBUG,
  18. format='%(asctime)s %(message)s')
  19. else:
  20. logging.basicConfig(filename='RDM_reader.log', level=logging.WARNING,
  21. format='%(asctime)s %(message)s')
  22. return args.config
  23.  
  24.  
  25. class Main:
  26. def __init__(self):
  27. try:
  28. config = ConfigParser.ConfigParser()
  29. config.read(cmd_parse())
  30. self.sql_data = dict(host=config.get("MySQLConfig", "host"),
  31. user=config.get("MySQLConfig", "username"),
  32. passwd=config.get("MySQLConfig", "password"),
  33. db=config.get("MySQLConfig", "database"))
  34. self.wsdl_data = dict(username=config.get("WSDLConfig", "username"),
  35. password=config.get("WSDLConfig", "password"))
  36. except TypeError:
  37. logging.warning("The program needs a functioning config file")
  38. return
  39.  
  40. if 'RDMConfig_overides' in config.sections():
  41. self.source_config = 'RDMConfig_overides'
  42. else:
  43. self.source_config = 'RDMConfig_default'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement