Skip to content

Commit 8a5dc80

Browse files
committed
additional tweaks for python2
1 parent 9ddb640 commit 8a5dc80

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

ddsc/core/download.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,9 @@ def _print_path_filter_warnings(self):
278278

279279
def _download_file(self, pool, project_file):
280280
output_path = project_file.get_local_path(self.dest_directory)
281-
if not os.path.exists(output_path):
282-
os.makedirs(os.path.dirname(output_path))
281+
output_path_parent = os.path.dirname(output_path)
282+
if not os.path.exists(output_path_parent):
283+
os.makedirs(output_path_parent)
283284
file_download_state = FileDownloadState(project_file, output_path, self.config)
284285
self._async_download_file(pool, file_download_state)
285286

@@ -322,6 +323,7 @@ def show_progress_bar(self):
322323
files_downloaded,
323324
self.files_to_download
324325
))
326+
sys.stdout.flush()
325327

326328
def make_spinner_char(self, current_time):
327329
half_seconds = int(current_time)

ddsc/core/tests/test_download.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ def test_download_file(self, mock_file_download_state, mock_os, mock_multiproces
396396
path_filter=None)
397397
project_file_downloader._download_file(mock_pool, mock_project_file)
398398
mock_os.path.dirname.assert_called_with("/tmp/data.out")
399+
mock_os.path.exists.assert_called_with(mock_os.path.dirname.return_value)
399400
mock_os.makedirs.assert_called_with(mock_os.path.dirname.return_value)
400401
mock_file_download_state.assert_called_with(mock_project_file, '/tmp/data.out', self.config)
401402
mock_pool.apply_async.assert_called_with(download_file, (mock_file_download_state.return_value,
@@ -474,6 +475,7 @@ def test_show_progress_bar(self, mock_time, mock_sys, mock_multiprocessing):
474475
downloader.get_download_progress.return_value = (10, 1000)
475476
downloader.show_progress_bar()
476477
mock_sys.stdout.write.assert_called_with('\r| downloaded 1 KB @ 10 B/s (10 of 20 files complete)')
478+
mock_sys.stdout.flush.assert_called_with()
477479

478480
@patch('ddsc.core.download.multiprocessing')
479481
def test_make_spinner_char(self, mock_multiprocessing):

0 commit comments

Comments
 (0)