(self, har_id: str)
| 245 | await self._export_har(har_id) |
| 246 | |
| 247 | async def _export_har(self, har_id: str) -> None: |
| 248 | params = self._har_recorders.pop(har_id, None) |
| 249 | if not params: |
| 250 | return |
| 251 | is_local = not self._connection.is_remote |
| 252 | is_zip = params["path"].endswith(".zip") |
| 253 | |
| 254 | if is_local: |
| 255 | result = await self._channel.send_return_as_dict( |
| 256 | "harExport", None, {"harId": har_id, "mode": "entries"} |
| 257 | ) |
| 258 | if not is_zip: |
| 259 | # Server wrote HAR and resources to the user's chosen paths. |
| 260 | return |
| 261 | await self._connection.local_utils.zip( |
| 262 | { |
| 263 | "zipFile": params["path"], |
| 264 | "entries": result["entries"], |
| 265 | "mode": "write", |
| 266 | "includeSources": False, |
| 267 | } |
| 268 | ) |
| 269 | return |
| 270 | |
| 271 | result = await self._channel.send_return_as_dict( |
| 272 | "harExport", None, {"harId": har_id, "mode": "archive"} |
| 273 | ) |
| 274 | artifact = cast(Artifact, from_channel(result["artifact"])) |
| 275 | if is_zip: |
| 276 | await artifact.save_as(params["path"]) |
| 277 | await artifact.delete() |
| 278 | return |
| 279 | # Uncompressed har is not supported in thin clients |
| 280 | await artifact.save_as(params["path"] + ".tmp") |
| 281 | await artifact.delete() |
no test coverage detected