ConfigGetter.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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", 8080)
  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. config = ConfigGetter()
  47. if __name__ == '__main__':
  48. print(config.db_type)
  49. print(config.db_name)
  50. print(config.db_host)
  51. print(config.db_port)
  52. print(config.proxy_getter_functions)
  53. print(config.host_ip)
  54. print(config.host_port)
  55. print(config.db_password)