Extra exceptions

main2
Bob Mottram 2019-10-14 22:38:03 +01:00
parent ebed9f5202
commit dac79d53f9
1 changed files with 37 additions and 7 deletions

View File

@ -788,8 +788,18 @@ class PubServer(BaseHTTPRequestHandler):
mediaFilename= \
self.server.baseDir+'/accounts/login.png'
if os.path.isfile(mediaFilename):
tries=0
mediaBinary=None
while tries<5:
try:
with open(mediaFilename, 'rb') as avFile:
mediaBinary = avFile.read()
break
except Exception as e:
print(e)
time.sleep(1)
tries+=1
if mediaBinary:
self._set_headers('image/png',len(mediaBinary),cookie)
self.wfile.write(mediaBinary)
self.wfile.flush()
@ -801,8 +811,18 @@ class PubServer(BaseHTTPRequestHandler):
mediaFilename= \
self.server.baseDir+'/accounts/login-background.png'
if os.path.isfile(mediaFilename):
tries=0
mediaBinary=None
while tries<5:
try:
with open(mediaFilename, 'rb') as avFile:
mediaBinary = avFile.read()
break
except Exception as e:
print(e)
time.sleep(1)
tries+=1
if mediaBinary:
self._set_headers('image/png',len(mediaBinary),cookie)
self.wfile.write(mediaBinary)
self.wfile.flush()
@ -814,8 +834,18 @@ class PubServer(BaseHTTPRequestHandler):
mediaFilename= \
self.server.baseDir+'/accounts/follow-background.png'
if os.path.isfile(mediaFilename):
tries=0
mediaBinary=None
while tries<5:
try:
with open(mediaFilename, 'rb') as avFile:
mediaBinary = avFile.read()
break
except Exception as e:
print(e)
time.sleep(1)
tries+=1
if mediaBinary:
self._set_headers('image/png',len(mediaBinary),cookie)
self.wfile.write(mediaBinary)
self.wfile.flush()