From 66251e7235bbfadd271d7cdffe4cb9549dbe0f00 Mon Sep 17 00:00:00 2001 From: KatKatKateryna Date: Tue, 5 Dec 2023 05:37:44 +0800 Subject: [PATCH] transport warning on receive; receive streams even without local account on that server; read units properly on receive --- speckle/converter/geometry/mesh.py | 5 ++- speckle/utils/validation.py | 51 ++++++++++++++++++------------ speckle_qgis.py | 8 ++++- 3 files changed, 41 insertions(+), 23 deletions(-) diff --git a/speckle/converter/geometry/mesh.py b/speckle/converter/geometry/mesh.py index 178d3f4d..f5fd3824 100644 --- a/speckle/converter/geometry/mesh.py +++ b/speckle/converter/geometry/mesh.py @@ -26,7 +26,10 @@ def meshToNative(meshes: List[Mesh], dataStorage) -> QgsMultiPolygon: parts_list, types_list = deconstructSpeckleMesh(mesh, dataStorage) for part in parts_list: polygon = QgsPolygon() - pts = [Point(x=pt[0], y=pt[1], z=pt[2], units="m") for pt in part] + units = dataStorage.currentUnits + if not isinstance(units, str): + units = "m" + pts = [Point(x=pt[0], y=pt[1], z=pt[2], units=units) for pt in part] pts.append(pts[0]) boundary = QgsLineString([pointToNative(pt, dataStorage) for pt in pts]) polygon.setExteriorRing(boundary) diff --git a/speckle/utils/validation.py b/speckle/utils/validation.py index 34711827..b8a91a6d 100644 --- a/speckle/utils/validation.py +++ b/speckle/utils/validation.py @@ -23,6 +23,8 @@ def tryGetClient(sw: StreamWrapper, dataStorage, write=False, dockwidget=None): ) try: client.authenticate_with_account(acc) + if client.account.token is not None: + break except SpeckleException as ex: if "already connected" in ex.message: logToUser( @@ -35,27 +37,34 @@ def tryGetClient(sw: StreamWrapper, dataStorage, write=False, dockwidget=None): else: raise ex - if client.account.token is not None: - stream = client.stream.get( - id=sw.stream_id, branch_limit=100, commit_limit=100 - ) - if isinstance(stream, Stream): - # print(stream.role) - if write == False: - # try get stream, only read access needed - # print("only read access needed") - return client, stream - else: - # check write access - # print("write access needed") - if stream.role is None or ( - isinstance(stream.role, str) - and "reviewer" in stream.role - ): - savedRole = stream.role - savedStreamId = stream.id - else: - return client, stream + # if token still not found + if client is None or client.account.token is None: + for acc in dataStorage.accounts: + client = sw.get_client() + if client is not None: + break + + if client is not None: + stream = client.stream.get( + id=sw.stream_id, branch_limit=100, commit_limit=100 + ) + if isinstance(stream, Stream): + # print(stream.role) + if write == False: + # try get stream, only read access needed + # print("only read access needed") + return client, stream + else: + # check write access + # print("write access needed") + if stream.role is None or ( + isinstance(stream.role, str) and "reviewer" in stream.role + ): + savedRole = stream.role + savedStreamId = stream.id + else: + return client, stream + if savedRole is not None and savedStreamId is not None: logToUser( f"You don't have write access to the stream '{savedStreamId}'. You role is '{savedRole}'", diff --git a/speckle_qgis.py b/speckle_qgis.py index b498079b..d915a9ff 100644 --- a/speckle_qgis.py +++ b/speckle_qgis.py @@ -786,6 +786,12 @@ def onReceive(self): transport = validateTransport(client, streamId) if transport == None: + logToUser( + "Transport not found", + level=2, + func=inspect.stack()[0][3], + plugin=self.dockwidget, + ) return # data transfer @@ -1293,7 +1299,7 @@ def handleStreamAdd(self, objectPacked: Tuple): self.add_stream_modal.handleStreamAdd.disconnect(self.handleStreamAdd) except: pass - set_project_streams(self) + #set_project_streams(self) self.dockwidget.populateProjectStreams(self) except Exception as e: logToUser(e, level=2, func=inspect.stack()[0][3], plugin=self.dockwidget)