ConfigLoader.py 1.1 KB

123456789101112131415161718192021222324252627
  1. import json
  2. class ConfigLoader(object):
  3. def __init__(self, manager: str, sourcename: str):
  4. with open(manager+'|'+sourcename+'.source','r') as f:
  5. self.json_str = json.loads(f.read())
  6. if self.json_str.get('source')== 'mysql':
  7. self.config = {}
  8. self.config["user"] = self.json_str.get("user")
  9. self.config["password"] = self.json_str.get("password")
  10. self.config["port"] = int(self.json_str.get("port"))
  11. self.config["host"] = self.json_str.get("host")
  12. self.config["charset"] = "utf8"
  13. elif self.json_str.get('source') == 'hive':
  14. self.config = {}
  15. self.config["host"] = self.json_str.get("host")
  16. self.config["port"] = int(self.json_str.get("port"))
  17. self.config["kerberos_service_name"]= self.json_str.get("kerberos_service_name")if self.json_str.get("kerberos_service_name")=='' else ""
  18. self.config["auth"]="" if self.json_str.get("kerberos_service_name")=='' else "KERBEROS"
  19. else:
  20. self.config=""
  21. def read_config(self):
  22. print(self.config)
  23. return self.config