rawpython / remi

Python REMote Interface library. Platform independent. In about 100 Kbytes, perfect for your diet.
Apache License 2.0
3.48k stars 401 forks source link

Feature Request: File downloader callbacks #105

Open KenT2 opened 8 years ago

KenT2 commented 8 years ago

The FileDownloader should have on_finished and on_fail callbacks.

The download could fail. Also an on_finished callback would allow deletion of temporary files such as zip archives.

dddomodossola commented 8 years ago

Hi Ken, Interesting request. I'm not sure it is feasible, I've to study a solution about this.

KenT2 commented 8 years ago

I thought something like this:

<def download(self): f.open(self._filename, 'r+b') if exception: callback fail content = f.read() f.close() headers = {'Content-type': 'application/octet-stream', 'Content-Disposition': 'attachment; filename=%s' % os.path.basename(self._filename)} callback finished return [content, headers]>

After f.close self._filename can be safely deleted as the content will as a minimum have been written into a buffer. It may not however have been downloaded and this download could fail. I am not worried about this as the user will be able to detect that the download has failed. The important thing is to have a callback when the remi knows its safe for the App to continue.

I know its not that simple as callback finished and return bothe need to be executed

dddomodossola commented 8 years ago

Hi Ken,

I thought about the same solution. I will implement this soon. Thank you.

KenT2 commented 7 years ago

Hi Davide I'm back, updating Pi Presents to your latest and greatest. Lots of good things have been happening while I have been sunning myself ;-} Any progress with this one likely to happen in the near future Ken

dddomodossola commented 7 years ago

@KenT2 Still no updates about this. Excuse me. Do you need a quick fix for your project?

KenT2 commented 7 years ago

Hi Davide No its not urgent. I have a workaround. Looking at the code again the filedownloader widget is in a dialog and I can use the OK button to delete the zip files.