Selaa lähdekoodia

Merge branch 'dev' into test

liqian 3 vuotta sitten
vanhempi
commit
028a5d761b
3 muutettua tiedostoa jossa 8 lisäystä ja 7 poistoa
  1. 0 2
      .gitignore
  2. 8 4
      config.py
  3. 0 1
      env.conf

+ 0 - 2
.gitignore

@@ -63,5 +63,3 @@ target/
 data/
 *.csv
 *.pickle
-
-env.conf

+ 8 - 4
config.py

@@ -1,4 +1,5 @@
 # coding:utf-8
+import os
 from log import Log
 log_ = Log()
 
@@ -285,17 +286,20 @@ class ProductionConfig(BaseConfig):
 
 
 def set_config():
-    with open('env.conf', 'r') as env_f:
-        line = env_f.read()
-        env = line.split('=')[1].strip()
+    # 获取环境变量 ROV_OFFLINE_ENV
+    env = os.environ.get('ROV_OFFLINE_ENV')
+    if env is None:
+        log_.error('ENV ERROR: is None!')
+        return
     if env == 'dev':
         return DevelopmentConfig(), env
     elif env == 'test':
+        print(env)
         return TestConfig(), env
     elif env == 'pre':
         return PreProductionConfig(), env
     elif env == 'pro':
         return ProductionConfig(), env
     else:
-        log_.error('env error')
+        log_.error('ENV ERROR: is {}'.format(env))
         return

+ 0 - 1
env.conf

@@ -1 +0,0 @@
-ENV=test