I've got a large file somewhere (FTP/HTTP).
I want to
- Download first
N
bytes, - Check its header which is embedded into the file (whether the version differs)
- Then decide whether to proceed with or abort the download.
It's definitely not such a straightforward task as I've imagined (to my surprise). Even calling wget
/curl
externally doesn't seem to be a good solution (Maybe I overlooked the right command line option).
How could this be done as simple as possible in Python?
I'm thinking about a custom handler for ftp.retrbinary
which will raise an exception as soon as the sum of blocks will be above defined value, but it's overkill in my eyes. Python code is supposed to be elegant, right?