setting.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. # -*- coding: utf-8 -*-
  2. """
  3. -------------------------------------------------
  4. File Name: setting.py
  5. Description : 配置文件
  6. Author : JHao
  7. date: 2019/2/15
  8. -------------------------------------------------
  9. Change Activity:
  10. 2019/2/15:
  11. -------------------------------------------------
  12. """
  13. import sys
  14. from os import getenv
  15. from logging import getLogger
  16. log = getLogger(__name__)
  17. HEADER = """
  18. ______ ______ _
  19. | ___ \_ | ___ \ | |
  20. | |_/ / \__ __ __ _ __ _ | |_/ /___ ___ | |
  21. | __/| _// _ \ \ \/ /| | | || __// _ \ / _ \ | |
  22. | | | | | (_) | > < \ |_| || | | (_) | (_) || |___
  23. \_| |_| \___/ /_/\_\ \__ |\_| \___/ \___/ \_____\
  24. __ / /
  25. /___ /
  26. """
  27. PY3 = sys.version_info >= (3,)
  28. class ConfigError(BaseException):
  29. pass
  30. DB_TYPE = getenv('db_type', 'SSDB')
  31. if DB_TYPE == 'SSDB':
  32. DB_HOST = getenv('ssdb_host', '127.0.0.1')
  33. DB_PORT = getenv('ssdb_port', '6379')
  34. DB_PASSWORD = getenv('ssdb_password', '')
  35. elif DB_TYPE == 'MONGODB':
  36. DB_HOST = getenv('mongodb_host', '127.0.0.1')
  37. DB_PORT = getenv('mongodb_host', '27017')
  38. DB_PASSWORD = getenv('mongodb_password', '')
  39. else:
  40. raise ConfigError('Unknown database type, your environment variable `db_type` should be one of SSDB/MONGODB.')
  41. DATABASES = {
  42. "default": {
  43. "TYPE": DB_TYPE, # TYPE SSDB/MONGODB if use redis, only modify the host port, the type should be SSDB
  44. "HOST": DB_HOST,
  45. "PORT": DB_PORT,
  46. "NAME": "proxy",
  47. "PASSWORD": DB_PASSWORD
  48. }
  49. }
  50. # register the proxy getter function
  51. PROXY_GETTER = [
  52. "freeProxy01",
  53. "freeProxy02",
  54. "freeProxy03",
  55. "freeProxy04",
  56. "freeProxy05",
  57. "freeProxy06",
  58. "freeProxy07",
  59. "freeProxy08",
  60. "freeProxy09",
  61. ]
  62. # # API config http://127.0.0.1:5010
  63. SERVER_API = {
  64. "HOST": "0.0.0.0", # The ip specified which starting the web API
  65. "PORT": 5010 # port number to which the server listens to
  66. }