Explorar o código

Merge pull request #389 from calmkart/master

MOD:fix default db_port to int and add a type check for env
J_hao104 %!s(int64=6) %!d(string=hai) anos
pai
achega
f79b0ac4c4
Modificáronse 2 ficheiros con 4 adicións e 4 borrados
  1. 1 1
      Config/ConfigGetter.py
  2. 3 3
      Config/setting.py

+ 1 - 1
Config/ConfigGetter.py

@@ -39,7 +39,7 @@ class ConfigGetter(object):
 
     @LazyProperty
     def db_port(self):
-        return DATABASES.get("default", {}).get("PORT", 8080)
+        return DATABASES.get("default", {}).get("PORT", 8888)
 
     @LazyProperty
     def db_password(self):

+ 3 - 3
Config/setting.py

@@ -35,7 +35,7 @@ PY3 = sys.version_info >= (3,)
 
 DB_TYPE = getenv('db_type', 'SSDB').upper()
 DB_HOST = getenv('db_host', '127.0.0.1')
-DB_PORT = getenv('db_port', '8080')
+DB_PORT = getenv('db_port', 8888)
 DB_PASSWORD = getenv('db_password', '')
 
 
@@ -79,8 +79,8 @@ def checkConfig():
     if DB_TYPE not in ["SSDB", "REDIS"]:
         raise ConfigError('db_type Do not support: %s, must SSDB/REDIS .' % DB_TYPE)
 
-    if not DB_PORT.isdigit():
-        raise ConfigError('db_port must be digit, not %s' % DB_PORT)
+    if type(DB_PORT) == str and not DB_PORT.isdigit():
+        raise ConfigError('if db_port is string, it must be digit, not %s' % DB_PORT)
 
     from ProxyGetter import getFreeProxy
     illegal_getter = list(filter(lambda key: not hasattr(getFreeProxy.GetFreeProxy, key), PROXY_GETTER))