forked from indymedia/epicyon
Extra exceptions
parent
ebed9f5202
commit
dac79d53f9
44
daemon.py
44
daemon.py
|
@ -788,8 +788,18 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
mediaFilename= \
|
mediaFilename= \
|
||||||
self.server.baseDir+'/accounts/login.png'
|
self.server.baseDir+'/accounts/login.png'
|
||||||
if os.path.isfile(mediaFilename):
|
if os.path.isfile(mediaFilename):
|
||||||
with open(mediaFilename, 'rb') as avFile:
|
tries=0
|
||||||
mediaBinary = avFile.read()
|
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._set_headers('image/png',len(mediaBinary),cookie)
|
||||||
self.wfile.write(mediaBinary)
|
self.wfile.write(mediaBinary)
|
||||||
self.wfile.flush()
|
self.wfile.flush()
|
||||||
|
@ -801,8 +811,18 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
mediaFilename= \
|
mediaFilename= \
|
||||||
self.server.baseDir+'/accounts/login-background.png'
|
self.server.baseDir+'/accounts/login-background.png'
|
||||||
if os.path.isfile(mediaFilename):
|
if os.path.isfile(mediaFilename):
|
||||||
with open(mediaFilename, 'rb') as avFile:
|
tries=0
|
||||||
mediaBinary = avFile.read()
|
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._set_headers('image/png',len(mediaBinary),cookie)
|
||||||
self.wfile.write(mediaBinary)
|
self.wfile.write(mediaBinary)
|
||||||
self.wfile.flush()
|
self.wfile.flush()
|
||||||
|
@ -814,8 +834,18 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
mediaFilename= \
|
mediaFilename= \
|
||||||
self.server.baseDir+'/accounts/follow-background.png'
|
self.server.baseDir+'/accounts/follow-background.png'
|
||||||
if os.path.isfile(mediaFilename):
|
if os.path.isfile(mediaFilename):
|
||||||
with open(mediaFilename, 'rb') as avFile:
|
tries=0
|
||||||
mediaBinary = avFile.read()
|
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._set_headers('image/png',len(mediaBinary),cookie)
|
||||||
self.wfile.write(mediaBinary)
|
self.wfile.write(mediaBinary)
|
||||||
self.wfile.flush()
|
self.wfile.flush()
|
||||||
|
@ -837,7 +867,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
elif emojiFilename.endswith('.jpg'):
|
elif emojiFilename.endswith('.jpg'):
|
||||||
mediaImageType='jpeg'
|
mediaImageType='jpeg'
|
||||||
else:
|
else:
|
||||||
mediaImageType='gif'
|
mediaImageType='gif'
|
||||||
with open(emojiFilename, 'rb') as avFile:
|
with open(emojiFilename, 'rb') as avFile:
|
||||||
mediaBinary = avFile.read()
|
mediaBinary = avFile.read()
|
||||||
self._set_headers('image/'+mediaImageType,len(mediaBinary),cookie)
|
self._set_headers('image/'+mediaImageType,len(mediaBinary),cookie)
|
||||||
|
|
Loading…
Reference in New Issue