This commit is contained in:
yumoqing 2020-04-26 15:29:37 +08:00
parent 35b6d7a565
commit e9d449e0b6
3 changed files with 8 additions and 8 deletions

View File

@ -1,6 +1,6 @@
import tempfile import tempfile
from kivyblocks.baseWidget import HTTPDataHandler from kivyblocks.baseWidget import HTTPDataHandler
from kivyblocks.utils import blocksImage, absurl from kivyblocks.utils import blockImage, absurl
from kivy.uix.image import Image from kivy.uix.image import Image
@ -8,7 +8,7 @@ class HostImage(Image):
def __init__(self, target,**kwargs): def __init__(self, target,**kwargs):
self.options = kwargs self.options = kwargs
self.target = target self.target = target
kwargs['source'] = blocksImage('running.gif') kwargs['source'] = blockImage('running.gif')
url = kwargs.get('url') url = kwargs.get('url')
del kwargs['url'] del kwargs['url']
super().__init__(**kwargs) super().__init__(**kwargs)
@ -22,14 +22,14 @@ class HostImage(Image):
loader.handle() loader.handle()
def showBadImage(self,o,e): def showBadImage(self,o,e):
self.source = blocksImage('break.png') self.source = blockImage('broken.png')
def createTmpfile(self,o,resp): def createTmpfile(self,o,resp):
fn = tempfile.NamedTemporaryFile(delete=True) fn = tempfile.NamedTemporaryFile(delete=True)
with open(fn, 'wb') as f: with open(fn, 'wb') as f:
for chunk in r.iter_content(chunk_size=8192): for chunk in r.iter_content(chunk_size=8192):
if chunk: # filter out keep-alive new chunks if chunk: # filter out keep-alive new chunks
f.write(chunk) f.write(chunk)
# f.flush() # f.flush()
self.source = fn self.source = fn

BIN
kivyblocks/imgs/broken.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

View File

@ -92,7 +92,7 @@ class HttpClient:
def _webcall(self,url,method="GET", def _webcall(self,url,method="GET",
params={}, params={},
files={}, files={},
headers={} headers={},
stream=False): stream=False):
app = App.get_running_app() app = App.get_running_app()
domain = self.url2domain(url) domain = self.url2domain(url)