Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/package/deposit/loader.py
Show First 20 Lines • Show All 165 Lines • ▼ Show 20 Lines | def load(self) -> Dict: | ||||
# update the deposit's status to success with its | # update the deposit's status to success with its | ||||
# revision-id and directory-id | # revision-id and directory-id | ||||
self.client.status_update( | self.client.status_update( | ||||
self.deposit_id, | self.deposit_id, | ||||
status="done", | status="done", | ||||
revision_id=hash_to_hex(rev_id), | revision_id=hash_to_hex(rev_id), | ||||
directory_id=hash_to_hex(dir_id), | directory_id=hash_to_hex(dir_id), | ||||
snapshot_id=r["snapshot_id"], | |||||
origin_url=self.url, | origin_url=self.url, | ||||
) | ) | ||||
except Exception: | except Exception: | ||||
logger.exception("Problem when trying to update the deposit's status") | logger.exception("Problem when trying to update the deposit's status") | ||||
return {"status": "failed"} | return {"status": "failed"} | ||||
return r | return r | ||||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | def metadata_get(self, deposit_id: Union[int, str]) -> Dict[str, Any]: | ||||
raise ValueError(msg) | raise ValueError(msg) | ||||
def status_update( | def status_update( | ||||
self, | self, | ||||
deposit_id: Union[int, str], | deposit_id: Union[int, str], | ||||
status: str, | status: str, | ||||
revision_id: Optional[str] = None, | revision_id: Optional[str] = None, | ||||
directory_id: Optional[str] = None, | directory_id: Optional[str] = None, | ||||
snapshot_id: Optional[str] = None, | |||||
origin_url: Optional[str] = None, | origin_url: Optional[str] = None, | ||||
): | ): | ||||
"""Update deposit's information including status, and persistent | """Update deposit's information including status, and persistent | ||||
identifiers result of the loading. | identifiers result of the loading. | ||||
""" | """ | ||||
url = f"{self.base_url}/{deposit_id}/update/" | url = f"{self.base_url}/{deposit_id}/update/" | ||||
payload = {"status": status} | payload = {"status": status} | ||||
if revision_id: | if revision_id: | ||||
payload["revision_id"] = revision_id | payload["revision_id"] = revision_id | ||||
if directory_id: | if directory_id: | ||||
payload["directory_id"] = directory_id | payload["directory_id"] = directory_id | ||||
if snapshot_id: | |||||
payload["snapshot_id"] = snapshot_id | |||||
if origin_url: | if origin_url: | ||||
payload["origin_url"] = origin_url | payload["origin_url"] = origin_url | ||||
self.do("put", url, json=payload) | self.do("put", url, json=payload) |