From 719f2144d3fcdd44445818bb99be9df784be230c Mon Sep 17 00:00:00 2001 From: Corinne Bosley Date: Mon, 13 Mar 2017 15:29:29 +0000 Subject: [PATCH 1/3] removed all instances of logging --- lib/iris/__init__.py | 6 ------ lib/iris/config.py | 9 --------- lib/iris/etc/site.cfg.template | 2 -- lib/iris/fileformats/rules.py | 7 +++++++ lib/iris/tests/__init__.py | 8 -------- lib/iris/tests/pp.py | 1 - lib/iris/tests/test_cdm.py | 1 - lib/iris/tests/test_coord_api.py | 2 -- lib/iris/tests/test_coordsystem.py | 2 -- lib/iris/tests/test_image_json.py | 1 - lib/iris/tests/test_pp_module.py | 1 - 11 files changed, 7 insertions(+), 33 deletions(-) diff --git a/lib/iris/__init__.py b/lib/iris/__init__.py index 77fd7cda5a..3344f1b498 100644 --- a/lib/iris/__init__.py +++ b/lib/iris/__init__.py @@ -103,7 +103,6 @@ def callback(cube, field, filename): import contextlib import glob import itertools -import logging import os.path import threading @@ -131,11 +130,6 @@ def callback(cube, field, filename): 'IrisDeprecation'] -# When required, log the usage of Iris. -if iris.config.IMPORT_LOGGER: - logging.getLogger(iris.config.IMPORT_LOGGER).info('iris %s' % __version__) - - Constraint = iris._constraints.Constraint AttributeConstraint = iris._constraints.AttributeConstraint diff --git a/lib/iris/config.py b/lib/iris/config.py index a20b7bb5a0..514f3b5f6b 100644 --- a/lib/iris/config.py +++ b/lib/iris/config.py @@ -116,15 +116,6 @@ def get_dir_option(section, option, default=None): PALETTE_PATH = get_dir_option(_RESOURCE_SECTION, 'palette_path', os.path.join(CONFIG_PATH, 'palette')) - -################# -# Logging options -_LOGGING_SECTION = 'Logging' - -IMPORT_LOGGER = get_option(_LOGGING_SECTION, 'import_logger') - - -################# # Runtime options class NetCDF(object): diff --git a/lib/iris/etc/site.cfg.template b/lib/iris/etc/site.cfg.template index b78e9c4b97..ef5459cc92 100644 --- a/lib/iris/etc/site.cfg.template +++ b/lib/iris/etc/site.cfg.template @@ -6,5 +6,3 @@ dot_path = /path/to/dot # see iris.fileformats.dot sample_data_dir = /path/to/iris/resources/sample_data test_data_dir = /path/to/iris/resources/test_data -[Logging] -import_logger = logger_name diff --git a/lib/iris/fileformats/rules.py b/lib/iris/fileformats/rules.py index 54057c9227..aa0a26a2f6 100644 --- a/lib/iris/fileformats/rules.py +++ b/lib/iris/fileformats/rules.py @@ -24,6 +24,13 @@ import six import collections +from contextlib import contextmanager +import getpass +import os +import os.path +import platform +import sys +import types import warnings import cf_units diff --git a/lib/iris/tests/__init__.py b/lib/iris/tests/__init__.py index 480239c295..8c37a9785b 100644 --- a/lib/iris/tests/__init__.py +++ b/lib/iris/tests/__init__.py @@ -45,7 +45,6 @@ import inspect import json import io -import logging import math import os import os.path @@ -146,9 +145,6 @@ os.environ['IRIS_TEST_CREATE_MISSING'] = 'true' -# A shared logger for use by unit tests -logger = logging.getLogger('tests') - # Whether to display matplotlib output to the screen. _DISPLAY_FIGURES = False @@ -430,7 +426,6 @@ def assertDataAlmostEqual(self, data, reference_filename, **kwargs): self.assertArrayAllClose(nstats, data_stats, **kwargs) else: self._ensure_folder(reference_path) - logger.warning('Creating result file: %s', reference_path) stats = collections.OrderedDict([ ('std', np.float_(data.std())), ('min', np.float_(data.min())), @@ -449,7 +444,6 @@ def assertFilesEqual(self, test_filename, reference_filename): fmt.format(test_filename, reference_path)) else: self._ensure_folder(reference_path) - logger.warning('Creating result file: %s', reference_path) shutil.copy(test_filename, reference_path) def assertString(self, string, reference_filename=None): @@ -492,7 +486,6 @@ def _check_same(self, item, reference_path, type_comparison_name='CML'): type_comparison_name) else: self._ensure_folder(reference_path) - logger.warning('Creating result file: %s', reference_path) with open(reference_path, 'wb') as reference_fh: reference_fh.writelines( part.encode('utf-8') @@ -694,7 +687,6 @@ def _check_reference_file(self, reference_path): def _ensure_folder(self, path): dir_path = os.path.dirname(path) if not os.path.exists(dir_path): - logger.warning('Creating folder: %s', dir_path) os.makedirs(dir_path) def check_graphic(self): diff --git a/lib/iris/tests/pp.py b/lib/iris/tests/pp.py index 6f166bc1eb..02f72e80b9 100644 --- a/lib/iris/tests/pp.py +++ b/lib/iris/tests/pp.py @@ -58,7 +58,6 @@ def cube_save_test(self, reference_txt_path, reference_cubes=None, reference_pp_ """ # Watch out for a missing reference text file if not os.path.isfile(reference_txt_path): - tests.logger.warning('Creating result file: %s', reference_txt_path) if reference_cubes: temp_pp_path = iris.util.create_temp_filename(".pp") try: diff --git a/lib/iris/tests/test_cdm.py b/lib/iris/tests/test_cdm.py index 1e03bdfbf4..f7e5a3c4a5 100644 --- a/lib/iris/tests/test_cdm.py +++ b/lib/iris/tests/test_cdm.py @@ -55,7 +55,6 @@ def check_dot(self, cube, reference_filename): reference = ''.join(reference_fh.readlines()) self._assert_str_same(reference, test_string, reference_filename, type_comparison_name='DOT files') else: - tests.logger.warning('Creating result file: %s', reference_path) with open(reference_path, 'w') as reference_fh: reference_fh.writelines(test_string) diff --git a/lib/iris/tests/test_coord_api.py b/lib/iris/tests/test_coord_api.py index d7c0f25d99..4708e2febb 100644 --- a/lib/iris/tests/test_coord_api.py +++ b/lib/iris/tests/test_coord_api.py @@ -23,7 +23,6 @@ import iris.tests as tests from xml.dom.minidom import Document -import logging import cf_units import numpy as np @@ -37,7 +36,6 @@ import iris.tests.stock -logger = logging.getLogger('tests') @tests.skip_data diff --git a/lib/iris/tests/test_coordsystem.py b/lib/iris/tests/test_coordsystem.py index 0c1f7a501b..ca6dcef8d7 100644 --- a/lib/iris/tests/test_coordsystem.py +++ b/lib/iris/tests/test_coordsystem.py @@ -22,7 +22,6 @@ # import iris tests first so that some things can be initialised before importing anything else import iris.tests as tests -import logging import cartopy.crs as ccrs import cf_units @@ -34,7 +33,6 @@ from iris.coord_systems import * -logger = logging.getLogger('tests') def osgb(): diff --git a/lib/iris/tests/test_image_json.py b/lib/iris/tests/test_image_json.py index 972edeb28e..d04cc4e1bd 100644 --- a/lib/iris/tests/test_image_json.py +++ b/lib/iris/tests/test_image_json.py @@ -27,7 +27,6 @@ import codecs import itertools import json -import logging import os import requests import unittest diff --git a/lib/iris/tests/test_pp_module.py b/lib/iris/tests/test_pp_module.py index e3106f95e4..acdaff158e 100644 --- a/lib/iris/tests/test_pp_module.py +++ b/lib/iris/tests/test_pp_module.py @@ -89,7 +89,6 @@ def check_pp(self, pp_fields, reference_filename): reference = ''.join(reference_fh.readlines()) self._assert_str_same(reference+'\n', test_string+'\n', reference_filename, type_comparison_name='PP files') else: - tests.logger.warning('Creating result file: %s', reference_path) with open(reference_path, 'w') as reference_fh: reference_fh.writelines(test_string) From 7e9fc7e3c521304a5808cc4d53ce5bc789bb348e Mon Sep 17 00:00:00 2001 From: Corinne Bosley Date: Tue, 24 Oct 2017 12:32:12 +0100 Subject: [PATCH 2/3] some pep8 corrections --- lib/iris/tests/test_coordsystem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/iris/tests/test_coordsystem.py b/lib/iris/tests/test_coordsystem.py index ca6dcef8d7..25be9bb1be 100644 --- a/lib/iris/tests/test_coordsystem.py +++ b/lib/iris/tests/test_coordsystem.py @@ -1,4 +1,4 @@ -# (C) British Crown Copyright 2010 - 2016, Met Office +# (C) British Crown Copyright 2010 - 2017, Met Office # # This file is part of Iris. # From c09ed31bbf12545907d3c83c3e4857e462a0e0e2 Mon Sep 17 00:00:00 2001 From: Corinne Bosley Date: Tue, 24 Oct 2017 14:55:31 +0100 Subject: [PATCH 3/3] pep8 correction and conflict resolution correction --- lib/iris/config.py | 1 + lib/iris/fileformats/rules.py | 7 ------- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/lib/iris/config.py b/lib/iris/config.py index 514f3b5f6b..eb44ec0bd8 100644 --- a/lib/iris/config.py +++ b/lib/iris/config.py @@ -118,6 +118,7 @@ def get_dir_option(section, option, default=None): # Runtime options + class NetCDF(object): """Control Iris NetCDF options.""" diff --git a/lib/iris/fileformats/rules.py b/lib/iris/fileformats/rules.py index aa0a26a2f6..54057c9227 100644 --- a/lib/iris/fileformats/rules.py +++ b/lib/iris/fileformats/rules.py @@ -24,13 +24,6 @@ import six import collections -from contextlib import contextmanager -import getpass -import os -import os.path -import platform -import sys -import types import warnings import cf_units