Make TDV steal more resilient
This commit is contained in:
parent
bb20dc3119
commit
edef07a592
1 changed files with 18 additions and 13 deletions
|
@ -6,8 +6,13 @@ import subprocess
|
||||||
import tempfile
|
import tempfile
|
||||||
import pathlib
|
import pathlib
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from stitching import tiles_to_equirectangular_blender, multistitch
|
from stitching import tiles_to_equirectangular_blender, multistitch
|
||||||
|
|
||||||
|
from socket import timeout
|
||||||
|
from ssl import SSLError
|
||||||
|
from urllib.error import URLError, HTTPError
|
||||||
|
|
||||||
def tdv_normalize(url):
|
def tdv_normalize(url):
|
||||||
'''
|
'''
|
||||||
Takes the URL of any image in a tdv panorama and returns a string
|
Takes the URL of any image in a tdv panorama and returns a string
|
||||||
|
@ -42,16 +47,7 @@ def tdv_getmaxzoom(schema):
|
||||||
:return: int value of largest available zoom level
|
:return: int value of largest available zoom level
|
||||||
'''
|
'''
|
||||||
|
|
||||||
l = 0
|
return 0
|
||||||
|
|
||||||
while True:
|
|
||||||
try:
|
|
||||||
url = schema % ("f", l+1, 0, 0)
|
|
||||||
with urllib.request.urlopen(url) as res:
|
|
||||||
assert res.getcode() == 200
|
|
||||||
l += 1
|
|
||||||
except:
|
|
||||||
return l
|
|
||||||
|
|
||||||
def tdv_export(schema):
|
def tdv_export(schema):
|
||||||
'''
|
'''
|
||||||
|
@ -75,9 +71,18 @@ def tdv_export(schema):
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
res = urllib.request.urlopen(schema % (tile, maxzoom, y, x))
|
print("Getting %s" % (schema % (tile, maxzoom, y, x)))
|
||||||
assert res.getcode() == 200
|
while True:
|
||||||
fo = io.BytesIO(res.read())
|
try:
|
||||||
|
res = urllib.request.urlopen(schema % (tile, maxzoom, y, x), timeout=10)
|
||||||
|
assert res.getcode() == 200
|
||||||
|
fo = io.BytesIO(res.read())
|
||||||
|
break
|
||||||
|
except (timeout, SSLError, URLError) as e:
|
||||||
|
if isinstance(e, HTTPError):
|
||||||
|
raise
|
||||||
|
continue
|
||||||
|
print("Done")
|
||||||
img = PIL.Image.open(fo)
|
img = PIL.Image.open(fo)
|
||||||
r_array.append(img)
|
r_array.append(img)
|
||||||
x += 1
|
x += 1
|
||||||
|
|
Loading…
Reference in a new issue