Skip to content

Commit

Permalink
Remove debug logging entries
Browse files Browse the repository at this point in the history
  • Loading branch information
merydian committed Aug 15, 2023
1 parent b206e1c commit 73a017d
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 64 deletions.
3 changes: 0 additions & 3 deletions ohsomeTools/common/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 0 additions & 6 deletions ohsomeTools/common/networkaccessmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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):
Expand Down Expand Up @@ -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
Expand Down
7 changes: 0 additions & 7 deletions ohsomeTools/common/request_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 0 additions & 5 deletions ohsomeTools/gui/ohsome_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -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) -> []:
Expand Down Expand Up @@ -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"),
Expand Down
26 changes: 3 additions & 23 deletions ohsomeTools/proc/procDialog.py
Original file line number Diff line number Diff line change
@@ -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):


Expand Down Expand Up @@ -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

Expand All @@ -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')


20 changes: 0 additions & 20 deletions ohsomeTools/proc/procRequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,48 +11,37 @@


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")
.get("spatialExtent")),
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'],
Expand Down Expand Up @@ -91,28 +80,20 @@ 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"],
header,
file,
request_time,
)
logger.log('debug4')
request_core.postprocess_metadata(result, vlayer)
print('debug5')
print('debug6')
return True
elif (
"ratioResult" in result.keys()
Expand All @@ -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

0 comments on commit 73a017d

Please sign in to comment.