clean patch
This commit is contained in:
+2
-21
@@ -173,24 +173,7 @@ def execute_from_flask(api_function, request: Request, *args,
|
||||
|
||||
|
||||
def handle_client(url_route: str):
|
||||
try:
|
||||
from geopy.geocoders import Nominatim
|
||||
except ModuleNotFoundError:
|
||||
from subprocess import run
|
||||
import sys
|
||||
|
||||
completed_process = run(
|
||||
[
|
||||
sys.executable,
|
||||
"-m",
|
||||
"pip",
|
||||
"install",
|
||||
"geopy==2.4.1",
|
||||
],
|
||||
capture_output=True,
|
||||
)
|
||||
#if completed_process.returncode != 0:
|
||||
from geopy.geocoders import Nominatim
|
||||
from geopy.geocoders import Nominatim
|
||||
|
||||
# if called fromm the browser, Exceptions from this function will result in infinite load
|
||||
agent = request.headers.get('User-Agent')
|
||||
@@ -216,6 +199,7 @@ def handle_client(url_route: str):
|
||||
country_code = ""
|
||||
try:
|
||||
geolocator = Nominatim(user_agent="specklePygeoapi")
|
||||
|
||||
lat = float(url_lower.split("&lat=")[1].split("&")[0])
|
||||
lon = float(url_lower.split("&lon=")[1].split("&")[0])
|
||||
|
||||
@@ -230,8 +214,6 @@ def handle_client(url_route: str):
|
||||
if country_code == "ru":
|
||||
print(f"Validating project location: blocked LAT LON {lat}, {lon}")
|
||||
raise PermissionError("Review Speckle Terms and Conditions")
|
||||
else:
|
||||
print(f"Error validating project location: LAT LON {lat}, {lon}")
|
||||
|
||||
# by IP:
|
||||
try:
|
||||
@@ -284,7 +266,6 @@ def landing_page():
|
||||
|
||||
# if requested from the browser, return this, otherwise ignore IF statement
|
||||
if request.method == 'GET' and browser_agent: # list items
|
||||
print("browser")
|
||||
return Response(stream_with_context(generate()))
|
||||
|
||||
# for non-browsers
|
||||
|
||||
@@ -128,6 +128,7 @@ class SpeckleProvider(BaseProvider):
|
||||
self.commit_gis = False
|
||||
self.url_params = {"url_data_type":"", "url_preserve_attributes":"", "url_crs_authid":"", "url_lat":"","url_lon":"","url_north_degrees":"","url_limit":""}
|
||||
self.times = {}
|
||||
self.country_code = ""
|
||||
|
||||
self.requested_data_type: str = "polygons (default)" # points, lines, polygons, projectcomments
|
||||
self.preserve_attributes: str = "true (default)"
|
||||
|
||||
@@ -126,9 +126,8 @@ def validate_coords(self, coords):
|
||||
country_code = address.get('country_code', '')
|
||||
except Exception as e:
|
||||
print(f"Error validating project location: {e}")
|
||||
self.country_code = country_code
|
||||
|
||||
if country_code == "ru":
|
||||
print(f"Validating project location: blocked LAT LON {coords[1]}, {coords[0]}")
|
||||
raise PermissionError("Review Speckle Terms and Conditions")
|
||||
else:
|
||||
print(f"Error validating project location: LAT LON {coords[1]}, {coords[0]}")
|
||||
|
||||
@@ -225,6 +225,7 @@ def set_actions(self: "SpeckleProvider", client: "SpeckleClient", action: str =
|
||||
full_dict["model"] = f"{self.project_name}, {self.model_name}"
|
||||
full_dict["time_TOTAL"] = sum([x[1] for x in self.times.items()])
|
||||
full_dict["model_url"] = self.speckle_url
|
||||
full_dict["country_code"] = self.country_code
|
||||
track(action, client.account, full_dict)
|
||||
except Exception as ex:
|
||||
print(f"_Cannot set action '{action}': {ex}")
|
||||
|
||||
Reference in New Issue
Block a user