| Conditions | 3 |
| Total Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 1 | Features | 2 |
| 1 | import socket |
||
| 35 | def global_ip(DEBUG=False): |
||
| 36 | ''' |
||
| 37 | return ip with by http://ipinfo.io/ip api |
||
| 38 | :param DEBUG:Flag for debug mode |
||
| 39 | :type DEBUG:bool |
||
| 40 | :return: global ip as string |
||
| 41 | ''' |
||
| 42 | try: |
||
| 43 | new_session=requests.session() |
||
| 44 | response=new_session.get(api_1) |
||
| 45 | ip_list=re.findall(ip_pattern,response.text) |
||
| 46 | new_session.close() |
||
| 47 | return ip_list[0] |
||
| 48 | except Exception as e: |
||
| 49 | if DEBUG==True: |
||
| 50 | print(str(e)) |
||
| 51 | return "Error" |
||
| 52 | |||
| 53 |