许家凯 1 tahun lalu
induk
melakukan
0d1d03e791

+ 0 - 8
.gitignore

@@ -105,14 +105,6 @@ celerybeat.pid
 # SageMath parsed files
 *.sage.py
 
-# Environments
-.env
-.venv
-env/
-venv/
-ENV/
-env.bak/
-venv.bak/
 
 # Spyder project settings
 .spyderproject

+ 5 - 0
data_clean/env/__init__.py

@@ -0,0 +1,5 @@
+# -*- coding: utf-8 -*-
+# @Time : 2021/5/27 11:21
+# @Author : XuJiakai
+# @File : __init__.py
+# @Software: PyCharm

+ 74 - 0
data_clean/env/env-dev.yaml

@@ -0,0 +1,74 @@
+es:
+#  old:
+#    hosts: http://es-cn-0pp0r32zf000ipovd.public.elasticsearch.aliyuncs.com:9200
+#    username: elastic
+#    pwd: elastic_168
+  new:
+    hosts: http://es-cn-oew22t8bw002iferu.public.elasticsearch.aliyuncs.com:9200
+    username: elastic
+    pwd: elastic_168
+  old:
+    hosts: es-cn-zxu362ii6000oj8y3.public.elasticsearch.aliyuncs.com:9200
+    username: elastic
+    pwd: elastic_168
+
+mongo:
+  itslaw:
+    url: mongodb://itslaw:itslaw_168@dds-uf6ff5dfd9aef3641601-pub.mongodb.rds.aliyuncs.com:3717,dds-uf6ff5dfd9aef3642555-pub.mongodb.rds.aliyuncs.com:3717/itslaw?
+
+kafka:
+  base:
+    hosts: 47.101.221.131:9092
+  dev:
+    hosts: 47.101.221.131:9092
+
+
+winhc_open_api:
+  eci_data:
+    host: 47.101.221.131
+
+
+mysql:
+  test_firefly:
+    host: 139.224.213.4
+    port: 3306
+    user: firefly
+    pwd: firefly
+  winhc_biz_prod:
+    host: rm-uf69d46no0wbj3s9zo.mysql.rds.aliyuncs.com
+    port: 3306
+    user: winhc_data
+    pwd: winhc_data168
+  eci_data:
+    host: rm-uf6bb73kr7541bdeu0o.mysql.rds.aliyuncs.com
+    port: 3306
+    user: myeci
+    pwd: myeci_Fasac_168
+  wenshu:
+    host: rm-uf666q55e678h9514so.mysql.rds.aliyuncs.com
+    port: 3306
+    user: wenshu
+    pwd: wenshu_168
+  prism1:
+    host: rm-uf61r3m23ba1p5z3dfo.mysql.rds.aliyuncs.com
+    port: 3306
+    user: wenshu
+    pwd: wenshu_168
+
+
+
+holo:
+  base:
+    host: hgprecn-cn-zvp2dvgsr005-cn-shanghai.hologres.aliyuncs.com
+    port: 80
+    dbname: winhc_biz
+    username: LTAI4G4yiyJV4ggnLyGMduqV
+    pwd: nokDg5HlVIBh80nL2dOXsKa2La4XL5
+
+  winhc_ng_rt:
+    host: hgprecn-cn-zvp2dvgsr005-cn-shanghai.hologres.aliyuncs.com
+    port: 80
+    dbname: winhc_ng_rt
+    username: LTAI4G4yiyJV4ggnLyGMduqV
+    pwd: nokDg5HlVIBh80nL2dOXsKa2La4XL5
+

+ 47 - 0
data_clean/env/env-prod.yaml

@@ -0,0 +1,47 @@
+es:
+  old:
+    hosts: es-cn-0pp0r32zf000ipovd.elasticsearch.aliyuncs.com:9200
+    username: elastic
+    pwd: elastic_168
+  new:
+    hosts: es-cn-oew22t8bw002iferu.elasticsearch.aliyuncs.com:9200
+    username: elastic
+    pwd: elastic_168
+
+mongo:
+  itslaw:
+    url: mongodb://itslaw:itslaw_168@dds-uf6ff5dfd9aef3641.mongodb.rds.aliyuncs.com:3717,dds-uf6ff5dfd9aef3642.mongodb.rds.aliyuncs.com:3717/itslaw?
+
+kafka:
+  base:
+    hosts: 192.168.4.239:9092,192.168.4.241:9092,192.168.4.240:9092
+  prod:
+    hosts: 192.168.4.239:9092,192.168.4.241:9092,192.168.4.240:9092
+  dev:
+    hosts: 47.101.221.131:9092
+
+
+winhc_open_api:
+  eci_data:
+    host: 192.168.5.20
+
+mysql:
+  test_firefly:
+    host: 139.224.213.4
+    port: 3306
+    user: firefly
+    pwd: firefly
+  winhc_biz_prd:
+    host: rm-uf69d46no0wbj3s9z.mysql.rds.aliyuncs.com
+    port: 3306
+    user: winhc_data
+    pwd: winhc_data168
+
+holo:
+  base:
+    host: hgprecn-cn-zvp2dvgsr005-cn-shanghai.hologres.aliyuncs.com
+    port: 80
+    dbname: winhc_biz
+    username: LTAI4G4yiyJV4ggnLyGMduqV
+    pwd: nokDg5HlVIBh80nL2dOXsKa2La4XL5
+

+ 75 - 0
data_clean/env/environment_switch.py

@@ -0,0 +1,75 @@
+# -*- coding: utf-8 -*-
+# @Time : 2021/5/27 11:23
+# @Author : XuJiakai
+# @File : environment_switch
+# @Software: PyCharm
+
+import platform
+import subprocess
+import os
+
+import yaml
+
+_module_path = os.path.dirname(__file__)
+
+
+def __ping_judge(ip):
+    CREATE_NO_WINDOW = 0x08000000
+    win_ping_cmd = "ping -n 1 {}".format(ip)
+    linux_ping_cmd = "ping -c 1 {}".format(ip)
+    if platform.system() == "Windows":
+        ret = subprocess.call(win_ping_cmd, shell=True, creationflags=CREATE_NO_WINDOW)
+    if platform.system() == "Linux":
+        ret = subprocess.call(linux_ping_cmd, shell=True)
+    if ret == 0:
+        return True
+    if ret == 1:
+        return False
+
+
+def _is_intranet_env():
+    if platform.system() == "Windows":
+        return False
+    # return __ping_judge("oss-cn-shanghai-internal.aliyuncs.com")
+    return True
+
+
+class environment_switch:
+    def __init__(self):
+        self.is_intranet = _is_intranet_env()
+        self.config = self.__get_conf()
+        pass
+
+    def __get_conf(self):
+        if self.is_intranet:
+            f = open(os.path.join(_module_path, 'env-prod.yaml'))  # 打开yaml文件
+            pass
+        else:
+            f = open(os.path.join(_module_path, 'env-dev.yaml'))  # 打开yaml文件
+            pass
+        d = yaml.load(f, Loader=yaml.FullLoader)  # 使用load方法加载
+        return d
+
+    def get_val(self, path):
+        return self.__get_val(self.config, path)
+
+    def __get_val(self, conf, path):
+        index = path.find('.')
+        if index == -1 and path in conf:
+            return conf[path]
+
+        k = path[0: index]
+        other_path = path[index + 1:]
+
+        if k in conf:
+            v = conf[k]
+            return self.__get_val(v, other_path)
+        return None
+
+
+if __name__ == '__main__':
+    env = environment_switch()
+    print(env.is_intranet)
+    # vv = env.get_val('mongo.itslaw.url')
+    # print(vv)
+    pass