通过MAC地址,自动判定生产环境、测试环境
通过MAC地址,自动判定生产环境、测试环境
以python为例:
# 自动判断环境:生产、test import uuid def get_mac_address(): mac = uuid.UUID(int=uuid.getnode()).hex[-12:] return ":".join([mac[e:e + 2] for e in range(0, 11, 2)]) mac_addr_ = get_mac_address() print(mac_addr_) test_env_mac_list_ = [ '0b:5c:56:c0:22:ee', # lyyj notebook '3a:24:a9:94:22:33' # company notebook ] if mac_addr_ in test_env_mac_list_: LOG_LEVEL = 'DEBUG' else: LOG_LEVEL = 'INFO' print(LOG_LEVEL)