Skip to content

Commit

Permalink
transport warning on receive; receive streams even without local acco…
Browse files Browse the repository at this point in the history
…unt on that server; read units properly on receive
  • Loading branch information
KatKatKateryna committed Dec 4, 2023
1 parent b47fadc commit 66251e7
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 23 deletions.
5 changes: 4 additions & 1 deletion speckle/converter/geometry/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
51 changes: 30 additions & 21 deletions speckle/utils/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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}'",
Expand Down
8 changes: 7 additions & 1 deletion speckle_qgis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 66251e7

Please sign in to comment.