multithreaded
This commit is contained in:
2
connectionfailslog.txt
Normal file
2
connectionfailslog.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#1: at 93
|
||||||
|
#2: at 236
|
||||||
5
h.txt
Normal file
5
h.txt
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
import requests
|
||||||
|
|
||||||
|
x = [requests.Response() for _ in range(20)]
|
||||||
|
|
||||||
|
print(x)
|
||||||
@@ -3,6 +3,7 @@ from time import time
|
|||||||
from time import sleep
|
from time import sleep
|
||||||
from contextlib import chdir
|
from contextlib import chdir
|
||||||
import copy
|
import copy
|
||||||
|
from concurrent.futures import ThreadPoolExecutor
|
||||||
|
|
||||||
headerz = {'Accept' : 'image/avif,image/webp,image/png,image/svg+xml,image/*;q=0.8,*/*;q=0.5', 'Accept-Encoding' :
|
headerz = {'Accept' : 'image/avif,image/webp,image/png,image/svg+xml,image/*;q=0.8,*/*;q=0.5', 'Accept-Encoding' :
|
||||||
'gzip, deflate, br, zstd', 'Accept-Language' :
|
'gzip, deflate, br, zstd', 'Accept-Language' :
|
||||||
@@ -11,62 +12,61 @@ headerz = {'Accept' : 'image/avif,image/webp,image/png,image/svg+xml,image/*;q=0
|
|||||||
|
|
||||||
milliseconds = int(time() * 1000)
|
milliseconds = int(time() * 1000)
|
||||||
|
|
||||||
|
x = [requests.Response() for _ in range(20)]
|
||||||
|
|
||||||
x1 = requests.Response()
|
print(x)
|
||||||
x2 = requests.Response()
|
|
||||||
x3 = requests.Response()
|
|
||||||
x4 = requests.Response()
|
|
||||||
x5 = requests.Response()
|
|
||||||
x6 = requests.Response()
|
|
||||||
x7 = requests.Response()
|
|
||||||
x8 = requests.Response()
|
|
||||||
x9 = requests.Response()
|
|
||||||
x10 = requests.Response()
|
|
||||||
x11 = requests.Response()
|
|
||||||
x12 = requests.Response()
|
|
||||||
x13 = requests.Response()
|
|
||||||
x14 = requests.Response()
|
|
||||||
x15 = requests.Response()
|
|
||||||
x16 = requests.Response()
|
|
||||||
x17 = requests.Response()
|
|
||||||
x18 = requests.Response()
|
|
||||||
x19 = requests.Response()
|
|
||||||
x20 = requests.Response()
|
|
||||||
|
|
||||||
astr = ["Hi!"] * 21
|
astr = ["Hi!"] * 20
|
||||||
|
lastr = ["Hi!"] * 20
|
||||||
|
|
||||||
astr[0] = "Hi!"
|
astr[0] = "https://ehub.portvancouver.com/Webcams/Photos/CommOver?"
|
||||||
astr[1] = "https://ehub.portvancouver.com/Webcams/Photos/CommOver?"
|
astr[1] = "https://ehub.portvancouver.com/webcams/Photos/DPWExitWest?"
|
||||||
astr[2] = "https://ehub.portvancouver.com/webcams/Photos/DPWExitWest?"
|
astr[2] = "https://ehub.portvancouver.com/Webcams/Photos/CentermMainGates?"
|
||||||
astr[3] = "https://ehub.portvancouver.com/Webcams/Photos/CentermMainGates?"
|
astr[3] = "https://ehub.portvancouver.com/Webcams/Photos/VantermEntrance?"
|
||||||
astr[4] = "https://ehub.portvancouver.com/Webcams/Photos/VantermEntrance?"
|
astr[4] = "https://ehub.portvancouver.com/Webcams/Photos/VantermGates?"
|
||||||
astr[5] = "https://ehub.portvancouver.com/Webcams/Photos/VantermGates?"
|
astr[5] = "https://ehub.portvancouver.com/Webcams/Photos/ClarkEntrance?"
|
||||||
astr[6] = "https://ehub.portvancouver.com/Webcams/Photos/ClarkEntrance?"
|
astr[6] = "https://ehub.portvancouver.com/Webcams/Photos/ColumbiaContainerCrossing?"
|
||||||
astr[7] = "https://ehub.portvancouver.com/Webcams/Photos/ColumbiaContainerCrossing?"
|
astr[7] = "https://ehub.portvancouver.com/webcams/Photos/TerminalDock?"
|
||||||
astr[8] = "https://ehub.portvancouver.com/webcams/Photos/TerminalDock?"
|
astr[8] = "https://ehub.portvancouver.com/Webcams/Photos/CommEntrance?"
|
||||||
astr[9] = "https://ehub.portvancouver.com/Webcams/Photos/CommEntrance?"
|
astr[9] = "https://ehub.portvancouver.com/Webcams/Photos/CommOverMcGill?"
|
||||||
astr[10] = "https://ehub.portvancouver.com/Webcams/Photos/CommOverMcGill?"
|
astr[10] = "https://ehub.portvancouver.com/Webcams/Photos/CameraDP_FS1?"
|
||||||
astr[11] = "https://ehub.portvancouver.com/Webcams/Photos/CameraDP_FS1?"
|
astr[11] = "https://ehub.portvancouver.com/Webcams/Photos/DeltaportGate1?"
|
||||||
astr[12] = "https://ehub.portvancouver.com/Webcams/Photos/DeltaportGate1?"
|
astr[12] = "https://ehub.portvancouver.com/Webcams/Photos/DMSWest?"
|
||||||
astr[13] = "https://ehub.portvancouver.com/Webcams/Photos/DMSWest?"
|
astr[13] = "https://ehub.portvancouver.com/Webcams/Photos/FSMainIntersection?"
|
||||||
astr[14] = "https://ehub.portvancouver.com/Webcams/Photos/FSMainIntersection?"
|
astr[14] = "https://ehub.portvancouver.com/Webcams/Photos/FSTruckInGate?"
|
||||||
astr[15] = "https://ehub.portvancouver.com/Webcams/Photos/FSTruckInGate?"
|
astr[15] = "https://ehub.portvancouver.com/Webcams/Photos/FSVACSGates?"
|
||||||
astr[16] = "https://ehub.portvancouver.com/Webcams/Photos/FSVACSGates?"
|
astr[16] = "https://ehub.portvancouver.com/Webcams/Photos/FS5TrackCrossing?"
|
||||||
astr[17] = "https://ehub.portvancouver.com/Webcams/Photos/FS5TrackCrossing?"
|
astr[17] = "https://ehub.portvancouver.com/Webcams/Photos/PortsideNo8?"
|
||||||
astr[18] = "https://ehub.portvancouver.com/Webcams/Photos/PortsideNo8?"
|
astr[18] = "https://ehub.portvancouver.com/Webcams/Photos/PortsideCoast2000?"
|
||||||
astr[19] = "https://ehub.portvancouver.com/Webcams/Photos/PortsideCoast2000?"
|
astr[19] = "https://ehub.portvancouver.com/Webcams/Photos/CPCTruckRoute?"
|
||||||
astr[20] = "https://ehub.portvancouver.com/Webcams/Photos/CPCTruckRoute?"
|
|
||||||
|
|
||||||
i = [-1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
|
folder = ["Commissioner entrance","Waterfront_road Centerm crossing","Centerm in gate",
|
||||||
|
"Vanterm Alliance Grain Terminal crossing", "Vanterm in gate", "Clark Drive overpass",
|
||||||
|
"Columbia Container - crossing", "Terminal dock","Commissioner truck staging",
|
||||||
|
"Commissioner street overpass", "Deltaport causeway", "Deltaport gate 1",
|
||||||
|
"Delta truck staging", "Fraser Surrey main intersection","Fraser Surrey in gate",
|
||||||
|
"Fraser Surrey VACS gates", "Fraser Surrey track crossing", "PortsideBlundellNo.8 road intersection",
|
||||||
|
"Portside road - westbound", "Convention Centre East"]
|
||||||
|
|
||||||
|
reference = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]
|
||||||
|
i = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
|
||||||
|
|
||||||
|
|
||||||
image_name = "image"
|
image_name = "image"
|
||||||
|
|
||||||
def acquireImage(request_string, folder_name, response):
|
def acquireImage(request_string, folder_name, response, number):
|
||||||
global image_check
|
image_check = requests.Response()
|
||||||
image_check = copy.deepcopy(response)
|
image_check = copy.deepcopy(response)
|
||||||
response = requests.get(request_string, headers=headerz)
|
resp = requests.get(request_string, headers=headerz, timeout=(5,30))
|
||||||
|
response._content = resp.content
|
||||||
|
response.status_code = resp.status_code
|
||||||
|
|
||||||
if response.content != image_check.content:
|
if response.content != image_check.content:
|
||||||
|
|
||||||
|
global i
|
||||||
|
i[number] += 1
|
||||||
|
image_name = "image" + f"{i[number]:04}" + ".jpg"
|
||||||
|
print(response)
|
||||||
with chdir(folder_name):
|
with chdir(folder_name):
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
with open(image_name, 'wb') as f:
|
with open(image_name, 'wb') as f:
|
||||||
@@ -75,57 +75,18 @@ def acquireImage(request_string, folder_name, response):
|
|||||||
print("Copy detected and removed (folder_name)")
|
print("Copy detected and removed (folder_name)")
|
||||||
|
|
||||||
|
|
||||||
def getTimeAndName(index):
|
def getName():
|
||||||
milliseconds = int(time() * 1000)
|
milliseconds = int(time() * 1000)
|
||||||
global image_name
|
global lastr
|
||||||
image_name = "image" + f"{i[index]:04}" + ".jpg"
|
lastr = [s + str(milliseconds) for s in astr]
|
||||||
i[index] += 1
|
|
||||||
|
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
getTimeAndName(1)
|
getName()
|
||||||
acquireImage(astr[1] + str(milliseconds), 'Commissioner entrance', x1)
|
|
||||||
getTimeAndName(2)
|
|
||||||
acquireImage(astr[2] + str(milliseconds), 'Waterfront_road Centerm crossing', x2)
|
|
||||||
getTimeAndName(3)
|
|
||||||
acquireImage(astr[3] + str(milliseconds), 'Centerm in gate', x3)
|
|
||||||
getTimeAndName(4)
|
|
||||||
acquireImage(astr[4] + str(milliseconds), 'Vanterm Alliance Grain Terminal crossing', x4)
|
|
||||||
getTimeAndName(5)
|
|
||||||
acquireImage(astr[5] + str(milliseconds), 'Vanterm in gate', x5)
|
|
||||||
getTimeAndName(6)
|
|
||||||
acquireImage(astr[6] + str(milliseconds), 'Clark Drive overpass', x6)
|
|
||||||
getTimeAndName(7)
|
|
||||||
acquireImage(astr[7] + str(milliseconds), 'Columbia Container - crossing', x7)
|
|
||||||
getTimeAndName(8)
|
|
||||||
acquireImage(astr[8] + str(milliseconds), 'Terminal dock', x8)
|
|
||||||
getTimeAndName(9)
|
|
||||||
acquireImage(astr[9] + str(milliseconds), 'Commissioner truck staging', x9)
|
|
||||||
getTimeAndName(10)
|
|
||||||
acquireImage(astr[10] + str(milliseconds), 'Commissioner street overpass', x10)
|
|
||||||
getTimeAndName(11)
|
|
||||||
acquireImage(astr[11] + str(milliseconds), 'Deltaport causeway', x11)
|
|
||||||
getTimeAndName(12)
|
|
||||||
acquireImage(astr[12] + str(milliseconds), 'Deltaport gate 1', x12)
|
|
||||||
getTimeAndName(13)
|
|
||||||
acquireImage(astr[13] + str(milliseconds), 'Delta truck staging', x13)
|
|
||||||
getTimeAndName(14)
|
|
||||||
acquireImage(astr[14] + str(milliseconds), 'Fraser Surrey main intersection', x14)
|
|
||||||
getTimeAndName(15)
|
|
||||||
acquireImage(astr[15] + str(milliseconds), 'Fraser Surrey in gate', x15)
|
|
||||||
getTimeAndName(16)
|
|
||||||
acquireImage(astr[16] + str(milliseconds), 'Fraser Surrey VACS gates', x16)
|
|
||||||
getTimeAndName(17)
|
|
||||||
acquireImage(astr[17] + str(milliseconds), 'Fraser Surrey track crossing', x17)
|
|
||||||
getTimeAndName(18)
|
|
||||||
acquireImage(astr[18] + str(milliseconds), 'PortsideBlundellNo.8 road intersection', x18)
|
|
||||||
getTimeAndName(19)
|
|
||||||
acquireImage(astr[19] + str(milliseconds), 'Portside road - westbound', x19)
|
|
||||||
getTimeAndName(20)
|
|
||||||
acquireImage(astr[20] + str(milliseconds), 'Convention Centre East', x20)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
with ThreadPoolExecutor() as executor:
|
||||||
|
results = executor.map(acquireImage, lastr, folder, x, reference)
|
||||||
|
|
||||||
print(i)
|
print(i)
|
||||||
|
|
||||||
print("Scanned")
|
print("Scanned")
|
||||||
|
|||||||
Reference in New Issue
Block a user