In the absence of the total_bytes key, just say "Completed" (looks
better than a bare "100%").
Compose the msg_template additively.
In practice, for pipes (where we lack total bytes) we also lack
elapsed time, so we end up with:
[download] Completed
though if elapsed time were somehow set we'd have:
[download] Completed in 00:10
In the real_download() method of the ExternalFD class:
Special-case output to stdout, when filename=='-', because otherwise
the call to os.path.getsize() raises
OSError: [Errno 2] No such file or directory: '-'
which in turn gets masked by a try block and re-raised as
UnavailableVideoError().
And even if getsize had succeeded, we would fail on renaming, and then
we would also fail on reporting progress as report_progress() expects
to have file size information.
So report download completion with self.to_screen() just as
report_progress() would in the noprogress==True case.
You might ask whether it's an abstraction violation for external.py to
have to know and think about '-' as a filename, but unfortunately
we're there already. _call_downloader() thinks about it, and also
real_download() calls common.py's temp_name() which special-cases the
'-' filename to preserve it instead of returnign a temp file. So we
already worry about this case at this abstraction level, as well as
both below and above. Perhaps that should change, but that's for
another day.
An OSError or IOError generally indicates something a little more
wrong than a "simple" UnavailableVideoError, so print the actual
traceback that leads to the exception. Otherwise meaningful postmortem
debugging a bug report is essentially infeasible.
Closes#9387
The shell assignment operator != was introduced in GNU make 4.0, or
specifically the commit in [1]. This fix removes such usages and
fallback to a more portable syntax. Tested with:
* GNU make 3.82 on CentOS 7.2
* bmake 20150910 on CentOS 7.2, source RPM from Fedora 24 [2]
* GNU make 4.2.1 on Arch Linux (Arch official package)
* bmake 20160926 on Arch Linux (Arch official package)
* GNU make 3.82 on Arch Linux (Compiled from source)
* Apple bsdmake-24 on macOS Sierra, binary package from Homebrew
Thanks @bdeyal for the feedback of the first tests
[1] http://git.savannah.gnu.org/cgit/make.git/commit/?id=b34438bee83ee906a23b881f257e684a0993b9b1
[2] http://koji.fedoraproject.org/koji/buildinfo?buildID=716769