Skip to content

Commit

Permalink
Use zipfile python library instead of unzip command in arkitscene (#…
Browse files Browse the repository at this point in the history
…1936)

* Use zipfile python library instead of `unzip` command in arkitscene
Windows doesn't have unzip!

* Nit: import sort order

---------

Co-authored-by: Nikolaus West <niko@rerun.io>
  • Loading branch information
Wumpf and nikolausWest committed Apr 20, 2023
1 parent b310010 commit a7ddf49
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions examples/python/arkitscenes/download_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import math
import os
import subprocess
import zipfile
from pathlib import Path
from typing import Final, List, Optional

Expand Down Expand Up @@ -121,9 +122,9 @@ def download_file(url: str, file_name: str, dst: Path) -> bool:
def unzip_file(file_name: str, dst: Path, keep_zip: bool = True) -> bool:
filepath = os.path.join(dst, file_name)
print(f"Unzipping zip file {filepath}")
command = f"unzip -oq {filepath} -d {dst}"
try:
subprocess.check_call(command, shell=True)
with zipfile.ZipFile(filepath, "r") as zip_ref:
zip_ref.extractall(dst)
except Exception as error:
print(f"Error unzipping {filepath}, error: {error}")
return False
Expand Down

0 comments on commit a7ddf49

Please sign in to comment.