Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix python data transfer #71

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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