通过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)

  

相关文章:

  • 2021-05-26
  • 2022-12-23
  • 2021-11-05
  • 2021-11-03
  • 2021-10-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-06-24
  • 2022-01-27
  • 2022-12-23
  • 2021-05-12
  • 2022-12-23
  • 2022-02-21
  • 2022-12-23
相关资源
相似解决方案