-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetupIP.py
30 lines (26 loc) · 904 Bytes
/
setupIP.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import json, sys, os, requests
from time import sleep
# Get absolute path to resource, works for dev and for PyInstaller
def resource_path(relative_path):
base_path = getattr(sys, '_MEIPASS', os.path.dirname(os.path.abspath(__file__)))
return os.path.join(base_path, relative_path)
# Function to return ips
def loadIPs(network=None):
with open(resource_path('ips.json'), 'r') as f:
ips = json.load(f)
if network:
return ips[network]
else:
allIPs = []
for network in ips:
for subnetMask in ips[network]:
allIPs.append(ips[network][subnetMask])
return allIPs
def updateIPs():
print("Updating...")
url = 'https://pastebin.com/raw/mpZdJ12n'
ipFile = requests.get(url)
with open(resource_path('ips.json'), 'wb') as f:
f.write(ipFile.content)
print("IPs updated successfully")
sleep(1)