Skip to content

Commit 192f6ff

Browse files
fix : variables uppercased
1 parent 33ca44c commit 192f6ff

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

orangetool/orangetool_ip.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
import requests
88
import re
99
import platform
10-
ip_pattern = r"(?:[0-9]{1,3}\.){3}[0-9]{1,3}"
11-
api_1 = "http://ipinfo.io/ip"
10+
IP_PATTERN = r"(?:[0-9]{1,3}\.){3}[0-9]{1,3}"
11+
GLOBAL_IP_API_1 = "http://ipinfo.io/ip"
1212

1313

1414
def internet(host="8.8.8.8", port=53, timeout=3):
@@ -77,8 +77,8 @@ def global_ip(debug=False):
7777
"""
7878
try:
7979
new_session = requests.session()
80-
response = new_session.get(api_1)
81-
ip_list = re.findall(ip_pattern, response.text)
80+
response = new_session.get(GLOBAL_IP_API_1)
81+
ip_list = re.findall(IP_PATTERN, response.text)
8282
new_session.close()
8383
return ip_list[0]
8484
except Exception as e:
@@ -111,7 +111,7 @@ def set_ip(ip, restart=False, device="eth0", debug=False):
111111
dns-nameservers 8.8.8.8 8.8.4.4
112112
'''
113113
try:
114-
if bool(re.match(ip_pattern, ip)) == False or ip.find(
114+
if bool(re.match(IP_PATTERN, ip)) == False or ip.find(
115115
"192.168.") == -1 or device not in mac().keys():
116116
raise Exception("IP Formation Error")
117117
static_string = static_string.replace("ip", ip)
@@ -143,7 +143,7 @@ def ping(ip, packet_number=3, debug=False):
143143
:return: a boolean value (True if ip is available and False otherwise)
144144
"""
145145
try:
146-
if re.match(ip_pattern, ip) == False:
146+
if re.match(IP_PATTERN, ip) == False:
147147
raise Exception("IP Formation Error")
148148
output = str(list(sub.Popen(["ping",
149149
ip,

orangetool/orangetool_system.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
import time
55
import requests
66
from art import tprint
7-
ip_pattern = r"(?:[0-9]{1,3}\.){3}[0-9]{1,3}"
8-
api_1 = "http://ipinfo.io/ip"
7+
98
ORANGETOOL_VERSION = "0.35"
109
UPDATE_URL = "http://www.orangetool.ir/version"
1110

0 commit comments

Comments
 (0)