From 400c31af13c3978e01e036d7857937233bb8cb37 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Sun, 3 May 2020 19:22:41 +0100 Subject: [PATCH] gdrive: move towards next pydrive2 release - depends on https://github.com/iterative/PyDrive2/pull/30 --- dvc/remote/gdrive.py | 34 +++++++--------------------------- 1 file changed, 7 insertions(+), 27 deletions(-) diff --git a/dvc/remote/gdrive.py b/dvc/remote/gdrive.py index 1095300164..ede722e452 100644 --- a/dvc/remote/gdrive.py +++ b/dvc/remote/gdrive.py @@ -397,33 +397,13 @@ def _gdrive_download_file( # it does not create a file on the remote gdrive_file = self._drive.CreateFile(param) - import httplib2 - - OrigClass = httplib2.HTTPConnectionWithTimeout.response_class - - class Custom(OrigClass): - def _readall_chunked(self): - assert self.chunked != "UNKNOWN" - value = [] - with Tqdm( - total=int(gdrive_file["fileSize"]), - desc=progress_desc, - disable=no_progress_bar, - bytes=True, - ) as pbar: - while True: - chunk_left = self._get_chunk_left() - if chunk_left is None: - break - chunk = self._safe_read(chunk_left) - value.append(chunk) - pbar.update(len(chunk)) - self.chunk_left = 0 - return b"".join(value) - - httplib2.HTTPConnectionWithTimeout.response_class = Custom - gdrive_file.GetContentFile(to_file) - httplib2.HTTPConnectionWithTimeout.response_class = OrigClass + with Tqdm( + total=int(gdrive_file["fileSize"]), + desc=progress_desc, + disable=no_progress_bar, + bytes=True, + ) as pbar: + gdrive_file.GetContentFile(to_file, callback=pbar.update_to) @_gdrive_retry def _gdrive_delete_file(self, item_id):