Skip to content

Commit 82ff066

Browse files
author
Vincent Grimmeisen
committed
Dockerfile still not installing basemap
1 parent afdfaf2 commit 82ff066

File tree

8 files changed

+39
-9709
lines changed

8 files changed

+39
-9709
lines changed

Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ RUN cat /etc/issue
44

55
RUN pip install matplotlib
66
RUN pip install numpy
7-
RUN apt update && apt install -y python-mpltoolkits.basemap
8-
7+
RUN pip install requests
8+
#RUN apt update && apt install -y python-mpltoolkits.basemap
9+
RUN pip install https://github.com/matplotlib/basemap/archive/v1.0.7rel.tar.gz
910
RUN echo 'alias e=exit' >> ~/.bashrc
1011
RUN echo 'alias c=clear' >> ~/.bashrc
1112

analyse.py

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import codecs
55
import os
66
import time
7-
7+
import sys
88
def getInfo(ip):
99
resp = requests.get('http://ip-api.com/json/' + ip)
1010
if resp.status_code != 200:
@@ -15,12 +15,15 @@ def getInfo(ip):
1515
data_formated = {"ip": ip, "lon": data["lon"], "lat": data["lat"], "country": data["country"], "isp": data["isp"],"org": data["org"] }
1616
return data_formated
1717

18-
def getIps():
19-
f = open('ips.txt','r')
18+
def readIpFile(filename):
19+
script_dir = os.getcwd()
20+
s = "input/"
21+
s += filename
22+
filepath = os.path.join(script_dir, s)
23+
f = open(filepath,'r')
2024
ips = []
2125
for line in f:
2226
ips.append(line.rstrip("\n"))
23-
#print(line.rstrip("\n"))
2427
return ips
2528

2629
def generatePayload(ips):
@@ -33,7 +36,7 @@ def batchRequest(ips):
3336
payload = generatePayload(ips)
3437
resp = requests.post('http://ip-api.com/batch', data=json.dumps(payload))
3538
if resp.status_code != 200:
36-
data_formated = "Error while getting Data for ", ip
39+
data_formated = "Error while getting Data"
3740
if resp.status_code == 422:
3841
data_formated = "Too much IPs in request"
3942
else:
@@ -42,25 +45,25 @@ def batchRequest(ips):
4245

4346

4447
def main():
45-
ips = getIps()
46-
ip_arry = []
47-
# Cut array in chunks because of the api limitation
48-
chunks = [ips[x:x+100] for x in range(0, len(ips), 100)]
49-
for c,l in enumerate(chunks):
50-
51-
data = batchRequest(l)
52-
time.sleep( 1 )
53-
script_dir = os.path.dirname(r'C:\Users\admin\Documents\git\pyAuthLog\data')
54-
s = "data\\"
55-
s += str(c)
56-
s += "_output.json"
57-
absPath = os.path.join(script_dir, s)
58-
print("Chunk Number ", str(c) + " Path: " + str(absPath) )
59-
with open(absPath, "wb") as outfile:
60-
json.dump(data,codecs.getwriter('utf-8')(outfile), ensure_ascii=False)
61-
62-
63-
48+
if len(sys.argv) < 2:
49+
print("Usage: analyse.py <Filename in /input>")
50+
sys.exit()
51+
else:
52+
ips = readIpFile(sys.argv[1])
53+
# Cut array in chunks because of the api limitation
54+
chunks = [ips[x:x+100] for x in range(0, len(ips), 100)]
55+
for c,l in enumerate(chunks):
56+
data = batchRequest(l)
57+
# More than 150 Requests per Second will get you blocked
58+
time.sleep( 1 )
59+
script_dir = os.getcwd()
60+
s = "data/"
61+
s += str(c)
62+
s += "_output.json"
63+
absPath = os.path.join(script_dir, s)
64+
print("Chunk Number ", str(c) + " Path: " + str(absPath) )
65+
with open(absPath, "wb") as outfile:
66+
json.dump(data,codecs.getwriter('utf-8')(outfile), ensure_ascii=False)
6467

6568

6669

input/19-04-19_ips.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5774,4 +5774,4 @@
57745774
23.95.113.42
57755775
118.25.221.166
57765776
211.171.43.72
5777-
58.242.83.29
5777+
58.242.83.29

0 commit comments

Comments
 (0)