diff --git a/bin/geomag.py b/bin/geomag.py index 84e7868836f1d7d06dae55053475511c87e88469..0682db176f1bb22d090980a7238719e5d0d9e11d 100755 --- a/bin/geomag.py +++ b/bin/geomag.py @@ -5,7 +5,7 @@ import sys # ensure geomag is on the path before importing try: import geomagio # noqa (tells linter to ignore this line.) -except: +except ImportError: script_dir = path.dirname(path.abspath(__file__)) sys.path.append(path.normpath(path.join(script_dir, '..'))) diff --git a/bin/main.py b/bin/main.py index 5cf6dbdefa41f717ad9e0d40cae1261bd11822fe..40be09ea3db72dc7e578ad28aa619b417ba2e5fd 100755 --- a/bin/main.py +++ b/bin/main.py @@ -5,7 +5,7 @@ import sys # ensure geomag is on the path before importing try: import geomagio # noqa (ignores this line for lint purposes.) -except: +except ImportError: script_dir = path.dirname(path.abspath(__file__)) sys.path.append(path.normpath(path.join(script_dir, '..'))) diff --git a/bin/monitor.py b/bin/monitor.py index 012bcd68ead096b8c2c48491452fd5d8e6fa19c9..7e636abda7eceec6bcfec7ceb72a3da95e1bb991 100755 --- a/bin/monitor.py +++ b/bin/monitor.py @@ -6,7 +6,7 @@ import sys # ensure geomag is on the path before importing try: import geomagio # noqa (tells linter to ignore this line.) -except: +except ImportError: script_dir = path.dirname(path.abspath(__file__)) sys.path.append(path.normpath(path.join(script_dir, '..'))) diff --git a/geomagio/StreamConverter.py b/geomagio/StreamConverter.py index f0ff48b64ee920170ea3cf8934041e81c6f768ae..d2e65e47b83bd287b8dcb1295566eb73c016734a 100644 --- a/geomagio/StreamConverter.py +++ b/geomagio/StreamConverter.py @@ -276,7 +276,7 @@ def __get_obs_d_from_obs(obs): """ try: d = obs.select(channel='D')[0] - except: + except IndexError: h = obs.select(channel='H')[0] e = obs.select(channel='E')[0] d = __get_trace('D', e.stats, @@ -301,7 +301,7 @@ def __get_obs_e_from_obs(obs): """ try: e = obs.select(channel='E')[0] - except: + except IndexError: h = obs.select(channel='H')[0] d = obs.select(channel='D')[0] e = __get_trace('E', d.stats, diff --git a/geomagio/WebService.py b/geomagio/WebService.py index 416381a36e7389ba44d6a0c691b70bdba4e55288..a06a7181c21b98e5ed5ac23c4a46d01a19aba013 100644 --- a/geomagio/WebService.py +++ b/geomagio/WebService.py @@ -238,7 +238,7 @@ class WebService(object): else: try: starttime = UTCDateTime(starttime) - except: + except TypeError: raise WebServiceException( 'Bad starttime value "%s".' ' Valid values are ISO-8601 timestamps.' % starttime) @@ -247,7 +247,7 @@ class WebService(object): else: try: endtime = UTCDateTime(endtime) - except: + except TypeError: raise WebServiceException( 'Bad endtime value "%s".' ' Valid values are ISO-8601 timestamps.' % endtime) diff --git a/geomagio/edge/LocationCode.py b/geomagio/edge/LocationCode.py index aa5168eb80567c273618894a172d86923f768620..0cbafd3916f3069f93fe85463112cc65c5eace64 100644 --- a/geomagio/edge/LocationCode.py +++ b/geomagio/edge/LocationCode.py @@ -27,6 +27,6 @@ def LocationCode(code): """ try: return re.match('^[A-Z0-9]{2}$', code).group(0) - except: + except AttributeError: raise argparse.ArgumentTypeError( 'Invalid location code, expected /^[A-Z0-9]{2}$/') diff --git a/geomagio/iaga2002/IAGA2002Parser.py b/geomagio/iaga2002/IAGA2002Parser.py index 917411bd252d8fa42cbfec73c6f1f09ef7879698..b0604d22d71f9775b9b7132a902a352e954c6962 100644 --- a/geomagio/iaga2002/IAGA2002Parser.py +++ b/geomagio/iaga2002/IAGA2002Parser.py @@ -108,7 +108,7 @@ class IAGA2002Parser(object): value = 1 / float(value.replace('second', '').strip()) elif value.find('Hz') != -1: value = float(value.replace('Hz', '').strip()) - except: + except ValueError: return elif key_upper == 'DATA INTERVAL TYPE': key = 'data_interval_type' diff --git a/gruntconfig/flake8.js b/gruntconfig/flake8.js index 38805efbd05aa1b1c2d7db5355e8bdaace30cfbc..2c664c628e288e4fe113d4902a9ae4ef565b6aec 100644 --- a/gruntconfig/flake8.js +++ b/gruntconfig/flake8.js @@ -3,7 +3,7 @@ module.exports = { src: { options: { - ignore: ['E122', 'E126', 'E127', 'E128', 'E131'] + ignore: ['E122', 'E126', 'E127', 'E128', 'E131', 'E741'] }, src: [ 'bin/*.py', @@ -13,7 +13,7 @@ module.exports = { test: { options: { - ignore: ['E122', 'E126', 'E127', 'E128', 'E131'] + ignore: ['E122', 'E126', 'E127', 'E128', 'E131', 'E741'] }, src: [ 'test/**/*.py'