ConfigGetter.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. # -*- coding: utf-8 -*-
  2. """
  3. -------------------------------------------------
  4. File Name: ConfigGetter
  5. Description : 读取配置
  6. Author : JHao
  7. date: 2019/2/15
  8. -------------------------------------------------
  9. Change Activity:
  10. 2019/2/15:
  11. -------------------------------------------------
  12. """
  13. __author__ = 'JHao'
  14. from Util.utilClass import LazyProperty
  15. from Config.setting import *
  16. class ConfigGetter(object):
  17. """
  18. get config
  19. """
  20. def __init__(self):
  21. pass
  22. @LazyProperty
  23. def db_type(self):
  24. return DATABASES.get("default", {}).get("TYPE", "SSDB")
  25. @LazyProperty
  26. def db_name(self):
  27. return DATABASES.get("default", {}).get("NAME", "proxy")
  28. @LazyProperty
  29. def db_host(self):
  30. return DATABASES.get("default", {}).get("HOST", "127.0.0.1")
  31. @LazyProperty
  32. def db_port(self):
  33. return DATABASES.get("default", {}).get("PORT", 8888)
  34. @LazyProperty
  35. def db_password(self):
  36. return DATABASES.get("default", {}).get("PASSWORD", "")
  37. @LazyProperty
  38. def proxy_getter_functions(self):
  39. return PROXY_GETTER
  40. @LazyProperty
  41. def host_ip(self):
  42. return SERVER_API.get("HOST", "127.0.0.1")
  43. @LazyProperty
  44. def host_port(self):
  45. return SERVER_API.get("PORT", 5010)
  46. @LazyProperty
  47. def verify_host(self):
  48. return VERIFY_HOST
  49. config = ConfigGetter()
  50. if __name__ == '__main__':
  51. print(config.db_type)
  52. print(config.db_name)
  53. print(config.db_host)
  54. print(config.db_port)
  55. print(config.proxy_getter_functions)
  56. print(config.host_ip)
  57. print(config.host_port)
  58. print(config.db_password)