def configure_logging(): requestedLogLevel = os.environ.get("LOG_LEVEL", "info") logLevelMapping = { "debug": logging.DEBUG, "info": logging.INFO, "warn": logging.WARN, "error": logging.ERROR, } handlers = [ logging.StreamHandler(stream=sys.stdout), logging.FileHandler(filename=os.path.join(API_LOG_DIR, f"api-{os.getpid()}.log"), mode="w"), ] logging.basicConfig( handlers=handlers, level=logLevelMapping.get(requestedLogLevel, logging.INFO), format="%(levelname)s %(asctime)s %(message)s", ) logger_name = "gdal" enable_debug = logging.getLogger().level == logging.DEBUG ConfigurePythonLogging(logger_name, enable_debug) if not enable_debug: # suppress noisy GDAL log output as it is meaningless to most users logging.getLogger(logger_name).setLevel(logging.ERROR) UseExceptions()
import numpy as np from numpy.testing import assert_array_equal from osgeo import gdal from osgeo.gdal import Open, Dataset, UseExceptions from tests.common import SML_TEST_TIF, SML_TEST_DEM_TIF, TEMPDIR from pyrate.core import shared, ifgconstants as ifc, config as cf, prepifg_helper, gamma from pyrate import prepifg, conv2tif from pyrate.configuration import Configuration, MultiplePaths from pyrate.core.shared import Ifg, DEM, RasterException from pyrate.core.shared import cell_size, _utm_zone from tests import common UseExceptions() if not exists(SML_TEST_TIF): sys.exit("ERROR: Missing small_test data for unit tests\n") class IfgTests(unittest.TestCase): """Unit tests for the Ifg/interferogram class.""" def setUp(self): self.ifg = Ifg(join(SML_TEST_TIF, 'geo_060619-061002_unw.tif')) self.ifg.open() self.ifg.nodata_value = 0 def test_headers_as_attr(self): for a in [ 'ncols', 'nrows', 'x_first', 'x_step', 'y_first', 'y_step',