123456789101112131415161718192021222324252627 |
- import json
- class ConfigLoader(object):
- def __init__(self, manager: str, sourcename: str):
- with open(manager+'|'+sourcename+'.source','r') as f:
- self.json_str = json.loads(f.read())
- if self.json_str.get('source')== 'mysql':
- self.config = {}
- self.config["user"] = self.json_str.get("user")
- self.config["password"] = self.json_str.get("password")
- self.config["port"] = int(self.json_str.get("port"))
- self.config["host"] = self.json_str.get("host")
- self.config["charset"] = "utf8"
- elif self.json_str.get('source') == 'hive':
- self.config = {}
- self.config["host"] = self.json_str.get("host")
- self.config["port"] = int(self.json_str.get("port"))
- self.config["kerberos_service_name"]= self.json_str.get("kerberos_service_name")if self.json_str.get("kerberos_service_name")=='' else ""
- self.config["auth"]="" if self.json_str.get("kerberos_service_name")=='' else "KERBEROS"
- else:
- self.config=""
- def read_config(self):
- print(self.config)
- return self.config
|