Skip to content

Commit

Permalink
Merge pull request #2610 from wangyinz/maintenance_1.2.x
Browse files Browse the repository at this point in the history
Fix bug in mass_downloader
  • Loading branch information
megies committed Jun 19, 2020
2 parents 0777ef0 + 2c52cf1 commit 2926827
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.txt
Expand Up @@ -10,6 +10,7 @@ Changes:
data when requesting an invalid, out-of-epochs time window for a valid
station (see #2611)
* update RASPISHAKE URL mapping to use https
* fix a bug of not handling HTTPException in mass_downloader (see #2606)
- obspy.clients.neic:
* Make client socket blocking (see #2617)
- obspy.io.nordic:
Expand Down
1 change: 1 addition & 0 deletions obspy/CONTRIBUTORS.txt
Expand Up @@ -96,6 +96,7 @@ Trani, Luca
Uieda, Leonardo
Walker, Andrew
Walther, Marcus
Wang, Yinzhi
Wassermann, Joachim
van Wijk, Kasper
Williams, Mark C.
Expand Down
4 changes: 3 additions & 1 deletion obspy/clients/fdsn/mass_downloader/utils.py
Expand Up @@ -25,8 +25,10 @@

if sys.version_info.major == 2:
from urllib2 import HTTPError, URLError
from httplib import HTTPException
else:
from urllib.error import HTTPError, URLError
from http.client import HTTPException

import obspy
from obspy.core import compatibility
Expand All @@ -37,7 +39,7 @@

# Different types of errors that can happen when downloading data via the
# FDSN clients.
ERRORS = [FDSNException, HTTPError, URLError, socket_timeout]
ERRORS = [FDSNException, HTTPException, HTTPError, URLError, socket_timeout]

# Python 2 does have special classes for connection errors.
if sys.version_info.major == 2:
Expand Down
21 changes: 21 additions & 0 deletions obspy/clients/fdsn/tests/test_mass_downloader.py
Expand Up @@ -20,9 +20,15 @@
import os
import shutil
from socket import timeout as socket_timeout
import sys
import tempfile
import unittest

if sys.version_info.major == 2:
from httplib import HTTPException
else:
from http.client import HTTPException

import numpy as np

import obspy
Expand Down Expand Up @@ -2163,6 +2169,21 @@ def test_download_mseed(self, patch_check_data, patch_download_mseed):
# is just an info message.
self.assertEqual(c.logger.error.call_count, 0)

patch_check_data.reset_mock()
patch_download_mseed.reset_mock()
c = self._init_client()
c.stations = {
("A", "A"): Station("A", "A", 0, 10, copy.deepcopy(channels))
}

patch_download_mseed.side_effect = HTTPException("disconnected")

c.download_mseed()
self.assertEqual(patch_check_data.call_count, 1)
self.assertEqual(patch_download_mseed.call_count, 1)
# The error logger should have been called once
self.assertEqual(c.logger.error.call_count, 1)

@mock.patch("obspy.clients.fdsn.mass_downloader."
"utils.download_stationxml")
@mock.patch("obspy.clients.fdsn.mass_downloader."
Expand Down

0 comments on commit 2926827

Please sign in to comment.