Skip to content

Commit fa9be16

Browse files
catilepticsimonwoerpel
authored andcommitted
Replace 7z binary call with a python lib: py7zr. Fix symlink index issue.
1 parent f2dc1a5 commit fa9be16

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

ingestors/packages/__init__.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import bz2
22
import gzip
3+
import py7zr
34
import shutil
45
import tarfile
56
from pathlib import PurePath
7+
from py7zr.exceptions import ArchiveError
68

79
from ingestors.ingestor import Ingestor
810
from ingestors.support.package import PackageSupport
@@ -24,9 +26,11 @@ def unpack(self, file_path, entity, temp_dir):
2426
*pure_file_path.parts[1:-1], reconstructed_filename
2527
)
2628

27-
self.exec_command(
28-
"7z", "x", str(pure_file_path), "-y", "-r", "-bb0", "-bd", f"-oc:{temp_dir}"
29-
)
29+
try:
30+
with py7zr.SevenZipFile(str(pure_file_path), mode='r') as extractor:
31+
extractor.extractall(path=temp_dir)
32+
except ArchiveError as e:
33+
raise ProcessingException(f"Error: {e}")
3034

3135

3236
class SingleFilePackageIngestor(PackageSupport, Ingestor):

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ dependencies = [
5050
# servicelayer extras requirements
5151
"boto3 (>=1.11.9,<2.0.0)",
5252
"grpcio (>=1.32.0,<2.0.0)",
53-
"google-cloud-storage (>=1.31.0,<3.0.0)"
53+
"google-cloud-storage (>=1.31.0,<3.0.0)",
54+
"py7zr (==1.0.0)",
5455
]
5556

5657
[project.scripts]

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fingerprints==1.2.3
1515
fasttext==0.9.2
1616
pika==1.3.2
1717
nomenklatura==3.15.2
18-
18+
py7zr==1.0.0
1919
# Development
2020
pytest==8.2.0
2121
pytest-cov==5.0.0

0 commit comments

Comments
 (0)