获取本机ip
(self)
| 84 | return result |
| 85 | |
| 86 | def get_host_ip(self): |
| 87 | """获取本机ip""" |
| 88 | try: |
| 89 | net_info_list = self.get_net_if_addr() |
| 90 | for net_info in net_info_list: |
| 91 | mac = net_info["mac"] |
| 92 | ipv4 = net_info["ipv4"] |
| 93 | if mac and ipv4 and ipv4 != "127.0.0.1": # 有mac地址和ipv4地址,才算获取到当前在用的ip |
| 94 | return ipv4 |
| 95 | except Exception as err: |
| 96 | LogPrinter.error("get host ip error: %s" % str(err)) |
| 97 | return "" |
| 98 | |
| 99 | |
| 100 | class HeartBeat(object): |
no test coverage detected