diff --git a/ohsomeTools/common/client.py b/ohsomeTools/common/client.py index 583ddbf..a8e8abe 100644 --- a/ohsomeTools/common/client.py +++ b/ohsomeTools/common/client.py @@ -59,7 +59,6 @@ def __init__(self, provider=None, retry_timeout=60): self.base_url = provider["base_url"] # self.session = requests.Session() - logger.log('NetworkAccessManager') self.nam = networkaccessmanager.NetworkAccessManager(debug=False) self.retry_timeout = timedelta(seconds=retry_timeout) @@ -190,7 +189,6 @@ def request( ) raise e raise - logger.log('request 1 done') return json.loads(content.decode("utf-8")) def _check_status(self): @@ -358,7 +356,6 @@ def __init__(self, provider=None, retry_timeout=60, feedback=None): self.base_url = provider["base_url"] # self.session = requests.Session() - logger.log('NetworkAccessManager') self.nam = networkaccessmanager.NetworkAccessManager(debug=False) self.retry_timeout = timedelta(seconds=retry_timeout) diff --git a/ohsomeTools/common/networkaccessmanager.py b/ohsomeTools/common/networkaccessmanager.py index 2059a33..eced365 100644 --- a/ohsomeTools/common/networkaccessmanager.py +++ b/ohsomeTools/common/networkaccessmanager.py @@ -272,7 +272,6 @@ def request( ) self.reply.sslErrors.connect(self.sslErrors) - logger.log('finished.connect 275') self.reply.finished.connect(self.replyFinished) self.reply.downloadProgress.connect(self.downloadProgress) @@ -283,7 +282,6 @@ def request( # Call and block self.el = QEventLoop() - logger.log('finished.connect 286') self.reply.finished.connect(self.el.quit) # Catch all exceptions (and clean up requests) @@ -293,7 +291,6 @@ def request( raise e if self.reply: - logger.log('finished.disconnect 296') self.reply.finished.disconnect(self.el.quit) # emit exception in case of error @@ -303,7 +300,6 @@ def request( else: raise self.exception_class(self.http_call_result.reason) - logger.log('request 2 done') return (self.http_call_result, self.http_call_result.content) def downloadProgress(self, bytesReceived, bytesTotal): @@ -452,8 +448,6 @@ def replyFinished(self): logger.log(msg) - logger.log('replyFinished done') - def sslErrors(self, ssl_errors): """ Handle SSL errors, logging them if debug is on and ignoring them diff --git a/ohsomeTools/common/request_core.py b/ohsomeTools/common/request_core.py index f999729..00c0cbb 100644 --- a/ohsomeTools/common/request_core.py +++ b/ohsomeTools/common/request_core.py @@ -51,29 +51,23 @@ def postprocess_metadata(original_json: dict, vlayer: QgsVectorLayer): - logger.log('postprocess_metadata 1') metadata: QgsLayerMetadata = vlayer.metadata() metadata.setTitle("ohsomeTools plugin query result.") if original_json.get("metadata") and original_json.get("metadata").get( "description" ): - logger.log('postprocess_metadata 2') metadata.setAbstract(original_json.get("metadata").get("description")) if original_json.get("apiVersion"): - logger.log('postprocess_metadata 3') metadata.addConstraint( QgsLayerMetadata.Constraint( f"{original_json.get('apiVersion')}", "apiVersion" ) ) if original_json.get("attribution"): - logger.log('postprocess_metadata 4') attribution: dict = original_json.get("attribution") licenses: [] = [value for _, value in attribution.items()] metadata.setLicenses(licenses=licenses) - logger.log('postprocess_metadata 5') vlayer.setMetadata(metadata=metadata) - logger.log('postprocess_metadata 6') def create_ohsome_csv_layer( @@ -290,7 +284,6 @@ def __init__( self.preferences = preferences if preferences is not None else {} self.activate_temporal = activate_temporal self.result: dict = {} - logger.log('debug ExtractionTaskFunction init') self.exception: OhsomeBaseException = None self.request_time = None self.client = client.Client(provider) diff --git a/ohsomeTools/gui/ohsome_spec.py b/ohsomeTools/gui/ohsome_spec.py index e5bbda9..0006e9f 100644 --- a/ohsomeTools/gui/ohsome_spec.py +++ b/ohsomeTools/gui/ohsome_spec.py @@ -347,13 +347,11 @@ def get_point_layer_request_preferences(self) -> []: endpoint_specific_request_properties = [] request_properties = self.__prepare_request_properties() list_of_bcircles = self._get_selected_point_layers_geometries() - logger.log(str(list_of_bcircles)) for bcircles in list_of_bcircles: request_properties["bcircles"] = bcircles endpoint_specific_request_properties.append( request_properties.copy() ) - logger.log('endpoint_specific_request_properties' + str(endpoint_specific_request_properties)) return endpoint_specific_request_properties def get_polygon_layer_request_preferences(self) -> []: @@ -393,17 +391,14 @@ def __init__(self, params): def _get_selected_polygon_layers_geometries(self) -> []: layer_list = [] polygon_layer_list = [self.params['LAYER'].name()] - logger.log(str([self.params['LAYER']])) for idx in range(len(polygon_layer_list)): item: str = polygon_layer_list[idx] - logger.log(item) layers = QgsProject.instance().mapLayersByName(item) layers = [ layer for layer in layers if layer.geometryType() == QgsWkbTypes.PolygonGeometry ] - logger.log(str([layer for layer in layers])) if len(layers) > 1: raise exceptions.TooManyInputsFound( str("error"), diff --git a/ohsomeTools/proc/procDialog.py b/ohsomeTools/proc/procDialog.py index bf969c9..dd145f0 100644 --- a/ohsomeTools/proc/procDialog.py +++ b/ohsomeTools/proc/procDialog.py @@ -1,23 +1,10 @@ -from ohsomeTools.utils import ( - logger, - configmanager, -) - -import json -from datetime import datetime -from PyQt5.QtWidgets import QDialogButtonBox, QMessageBox -from qgis._core import ( - QgsVectorLayer, - Qgis, - QgsProcessingUtils, -) - -from ohsomeTools.common import client, request_core -from ohsomeTools.utils import exceptions, logger +from ohsomeTools.common import client +from ohsomeTools.utils import exceptions, logger, configmanager from qgis.utils import iface from ohsomeTools.gui import ohsome_spec from .procRequest import processing_request + def run_processing_alg(processingParams, feedback): @@ -64,14 +51,11 @@ def run_processing_alg(processingParams, feedback): processing_request(clnt, preferences, processingParams, point_layer_preference) elif geom == 2: - logger.log('polygon') layer_preferences = ( preferences.get_polygon_layer_request_preferences() ) for polygon_layer_preference in layer_preferences: - logger.log('iteration') processing_request(clnt, preferences, processingParams, polygon_layer_preference) - logger.log('iteration done') else: return @@ -85,13 +69,9 @@ def run_processing_alg(processingParams, feedback): feedback.reportError("Request aborted. Check the tool log.") finally: if not metadata_check: - logger.log('metadata_check') return True elif not preferences.is_valid(True): - logger.log('debug preferences.is_valid(True)') feedback.reportError("Preferences are not valid. Check the plugin log.") - logger.log('debug preferences.is_valid(True) 2') return - logger.log('run_processing_alg done') diff --git a/ohsomeTools/proc/procRequest.py b/ohsomeTools/proc/procRequest.py index 1fb404d..85bbc52 100644 --- a/ohsomeTools/proc/procRequest.py +++ b/ohsomeTools/proc/procRequest.py @@ -11,31 +11,23 @@ def processing_request(clnt, preferences, parameters, point_layer_preference={}): - logger.log('requesting') try: request_time = datetime.now().strftime("%m-%d-%Y:%H-%M-%S") if len(point_layer_preference): - logger.log('requesting 1') result = clnt.request( f"/{preferences.get_request_url()}", {}, post_json=point_layer_preference, ) else: - logger.log('meta') result = clnt.request(f"/metadata", {}) except Exception as e: - logger.log(str(e)) result = None logger.log(e) - logger.log('postprocessing') if not result or not len(result): - logger.log('postdbabd') return False if "extractRegion" in result: - logger.log('extractRegion') - vlayer : QgsVectorLayer= QgsVectorLayer( json.dumps( result.get("extractRegion") @@ -43,16 +35,13 @@ def processing_request(clnt, preferences, parameters, point_layer_preference={}) f"OHSOME_API_spatial_extent", "ogr") QgsProject.instance().addMapLayer(vlayer) - logger.log('extractRegion2') if vlayer: - logger.log('extractRegion3') return True elif ( all(i in result.keys() for i in ["type", "features"]) and result.get("type").lower() == "featurecollection" ): # Process GeoJSON - logger.log('GeoJson') geojsons: [] = request_core.split_geojson_by_geometry( result, keep_geometry_less=parameters['check_keep_geometryless'], @@ -91,17 +80,12 @@ def processing_request(clnt, preferences, parameters, point_layer_preference={}) and len(result.get("groupByResult")) > 0 ): # Process non-flat tables - logger.log('non-flat tables procDialog') results = result["groupByResult"] - logger.log('debug1') - logger.log(str(len(results))) for result_group in results: - logger.log('debug2') file = QgsProcessingUtils.generateTempFilename( f'{result_group["groupByObject"]}_{preferences.get_request_url()}.csv' ) header = results[0]["result"][0].keys() - logger.log('debug3') vlayer = request_core.create_ohsome_csv_layer( iface, result_group["result"], @@ -109,10 +93,7 @@ def processing_request(clnt, preferences, parameters, point_layer_preference={}) file, request_time, ) - logger.log('debug4') request_core.postprocess_metadata(result, vlayer) - print('debug5') - print('debug6') return True elif ( "ratioResult" in result.keys() @@ -132,5 +113,4 @@ def processing_request(clnt, preferences, parameters, point_layer_preference={}) ) request_core.postprocess_metadata(result, vlayer) return True - logger.log('postprocessing done') return False \ No newline at end of file