Skip to content

Commit

Permalink
Fix python data transfer (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbiguenet authored Nov 28, 2023
1 parent 3bcde62 commit d24b073
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
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit d24b073

Please sign in to comment.