Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix python data transfer
Browse files Browse the repository at this point in the history
dbiguenet committed Nov 28, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 3bcde62 commit 52dffca
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions python/reality_apis/DataTransfer/reality_data_transfer.py
Original file line number Diff line number Diff line change
@@ -98,10 +98,8 @@ def _create_reality_data(
rootfile: str = "",
) -> ReturnValue[str]:
rd_dict = {
{
"displayName": name,
"type": data_type.value,
}
"displayName": name,
"type": data_type.value,
}
if iTwin_id != "":
rd_dict["iTwinId"] = iTwin_id
@@ -124,7 +122,7 @@ def _create_reality_data(
def _update_reality_data(
self, rd_id: str, update_dict: dict, iTwin_id: str = ""
) -> ReturnValue[str]:
rd_dict = {update_dict}
rd_dict = update_dict
if iTwin_id != "":
rd_dict["iTwinId"] = iTwin_id
json_data = json.dumps(rd_dict)
@@ -156,13 +154,14 @@ def _upload_data_to_container(self, data_path, rd_id, iTwin_id, rd_folder ="", d

# ask for the rd container
response = self._session.get(
"https://" + self._service_url + f"/reality-management/reality-data/{rd_id}/container?iTwinId={iTwin_id}&access=Write",
"https://" + self._service_url + f"/reality-management/reality-data/{rd_id}/writeaccess?iTwinId={iTwin_id}",
headers=self._get_header())
try:
data_json = response.json()
print(data_json)
if response.status_code < 200 or response.status_code >= 400:
return ReturnValue(value=False, error=self._error_msg(response.status_code, data_json))
sas_uri = data_json["container"]["_links"]["containerUrl"]["href"]
sas_uri = data_json["_links"]["containerUrl"]["href"]
except json.decoder.JSONDecodeError:
return ReturnValue(value=False, error=self._error_msg(response.status_code, {"error": {"message": response.text}}))
except KeyError as e:
@@ -397,14 +396,14 @@ def download_reality_data(
True if download was successful, and a potential error message.
"""
response = self._session.get(
"https://" + self._service_url + f"/reality-management/reality-data/{data_id}/container?iTwinId={iTwin_id}&access=Read",
"https://" + self._service_url + f"/reality-management/reality-data/{data_id}/readaccess?iTwinId={iTwin_id}",
headers=self._get_header())

try:
data_json = response.json()
if response.status_code < 200 or response.status_code >= 400:
return ReturnValue(value="", error=self._error_msg(response.status_code, data_json))
sas_uri = data_json["container"]["_links"]["containerUrl"]["href"]
sas_uri = data_json["_links"]["containerUrl"]["href"]
except json.decoder.JSONDecodeError:
return ReturnValue(value=False, error=self._error_msg(response.status_code, {"error": {"message": response.text}}))
except KeyError as e:

0 comments on commit 52dffca

Please sign in to comment.