Skip to content

Commit e4161fa

Browse files
committed
Create LambdaService object when button is pressed.
Create LambdaService object when button is pressed. Removed redundant code.
1 parent 84bb89d commit e4161fa

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

arho_feature_template/core/lambda_service.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from arho_feature_template.utils.misc_utils import get_active_plan_id, get_plan_name, get_settings
1010

1111

12-
# Luo uusi lambda service kun nappia painaa
1312
class LambdaService(QObject):
1413
jsons_received = pyqtSignal(dict, dict)
1514

@@ -57,7 +56,6 @@ def _process_reply(self, reply: QNetworkReply):
5756

5857
try:
5958
response_data = reply.readAll().data().decode("utf-8")
60-
6159
response_json = json.loads(response_data)
6260

6361
# Determine if the proxy is set up.
@@ -75,7 +73,7 @@ def _process_reply(self, reply: QNetworkReply):
7573
if not isinstance(plan_json, dict):
7674
plan_json = {}
7775

78-
outline_json = None
76+
outline_json = {}
7977
if plan_json:
8078
geographical_area = plan_json.get("geographicalArea")
8179
if geographical_area:
@@ -87,9 +85,6 @@ def _process_reply(self, reply: QNetworkReply):
8785
"geometry": geographical_area.get("geometry"),
8886
}
8987

90-
if outline_json is None:
91-
outline_json = {} # Fallback to empty dictionary if no outline JSON is created
92-
9388
# Emit the signal with the two JSONs
9489
self.jsons_received.emit(plan_json, outline_json)
9590

arho_feature_template/core/plan_manager.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
class PlanManager:
1818
def __init__(self):
19-
self.lambda_service = LambdaService()
20-
self.lambda_service.jsons_received.connect(self.save_plan_jsons)
2119
self.json_plan_path = None
2220
self.json_plan_outline_path = None
2321
self.kaava_layer = get_layer_by_name("Kaava")
@@ -121,6 +119,8 @@ def get_plan_json(self):
121119
QMessageBox.critical(None, "Virhe", "Ei aktiivista kaavaa.")
122120
return
123121

122+
self.lambda_service = LambdaService()
123+
self.lambda_service.jsons_received.connect(self.save_plan_jsons)
124124
self.lambda_service.send_request("get_plans", plan_id)
125125

126126
def save_plan_jsons(self, plan_json, outline_json):

0 commit comments

Comments
 (0)