-
Notifications
You must be signed in to change notification settings - Fork 32
🐛 unarchiving_utils are now based on 7zip cli #6959
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
Merged
Merged
Changes from 15 commits
Commits
Show all changes
74 commits
Select commit
Hold shift + click to select a range
97fd911
move archive to port instead of failing
29533e9
Merge remote-tracking branch 'upstream/master' into pr-osparc-deflate…
ca87d0b
using log context and rename
7f3e41e
Merge remote-tracking branch 'upstream/master' into pr-osparc-deflate…
be58b0c
refactor to use less generic error UnsupportedArchiveFormat
53e0728
renaming error
65b5291
replace unarchiver
e6d118d
remove unused
2a2f917
remove comment
56d7fe1
refactor 7zip
9c82bc5
fixed broken install
5a4cfb5
Merge remote-tracking branch 'upstream/master' into pr-osparc-deflate…
0f315e0
refactor
7ede41a
mypy
9d67dd1
added extra test
0f1642d
Merge remote-tracking branch 'upstream/master' into pr-osparc-deflate…
71adc5b
move to folder
01ce053
small enhancements in tests
79c1648
restructure package
02c9497
modules renaming
c01e35a
refactor
13c1485
fix refactor
653e168
added decompress progress
6dfcd95
fixed issues with parsing progress
c3b0c1c
restructure tests with common utils
56d1871
added notes to deprecate
30346af
Merge remote-tracking branch 'upstream/master' into pr-osparc-deflate…
a9145e2
remove unwanted code
46a0c29
remove unused
c04999c
removed unused feature
d48de81
refactor to drop relative_paths since it's always True
9ff2374
added tqdm progress
0364e8b
refactor common code
7205c2f
connected progressbar
79cc7e8
added dropin interface
e69bc9a
remove old unused interface
e282c95
Merge remote-tracking branch 'upstream/master' into pr-osparc-deflate…
7279155
removes unused repro-zipfile
571a411
refactor imports
da30d13
restructure model
9ca1090
simplify outputs parsing
97bdff1
install path is now fixed to avoid using old system versions
280b0d3
fixed 7z installation
6759dc7
enhanced 7zip interface
4a5a3a6
added arm64 target install
21c7f0a
fixed lines scanning parsing
a58849f
added edge case test
f5ae500
Merge remote-tracking branch 'upstream/master' into pr-osparc-deflate…
abc45ef
refactor
82413f1
refactor
cbf7533
rename
5739963
mypy
9495ac1
making flatter
d693eeb
revert change
7e5b967
adding missing
05ab2f1
remove unused
7041eee
remove useless
622bb66
rename
2ddc4df
refactor errors and re
d2de8be
replaced regex search with complied expressions
010fe01
feedback
09cc78b
human readable refacto
cfb5f6d
revert
e825e07
Merge remote-tracking branch 'upstream/master' into pr-osparc-deflate…
9d028bd
extract percentage via regex
f791538
only one log handler is supported
6d8c10a
rename
3881d18
Merge remote-tracking branch 'upstream/master' into pr-osparc-deflate…
3a9de60
remove meaningless comment
805bd9e
fixed parsing issue
fd58947
fixed issue with file listing
229b9aa
removing archive after download
8ec0c9f
Merge remote-tracking branch 'upstream/master' into pr-osparc-deflate…
b14d359
revert upgraded
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| #!/bin/bash | ||
| # | ||
| # Installs the latest version of 7zip plugin | ||
| # | ||
|
|
||
| # http://redsymbol.net/articles/unofficial-bash-strict-mode/ | ||
| set -o errexit # abort on nonzero exitstatus | ||
| set -o nounset # abort on unbound variable | ||
| set -o pipefail # don't hide errors within pipes | ||
| IFS=$'\n\t' | ||
|
|
||
| exec "$( dirname -- "$0"; )"/../../../scripts/install_7zip.bash |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| #!/bin/bash | ||
| # | ||
| # Installs 7zip | ||
| # | ||
|
|
||
| # http://redsymbol.net/articles/unofficial-bash-strict-mode/ | ||
| set -o errexit # abort on nonzero exitstatus | ||
| set -o nounset # abort on unbound variable | ||
| set -o pipefail # don't hide errors within pipes | ||
| IFS=$'\n\t' | ||
|
|
||
|
|
||
| SEVEN_ZIP_VERSION="2409" | ||
| ## 7z compression | ||
| echo "create install dir" | ||
| rm -rf /tmp/7zip | ||
| mkdir -p /tmp/7zip | ||
| cd /tmp/7zip | ||
|
|
||
| curl -LO https://www.7-zip.org/a/7z${SEVEN_ZIP_VERSION}-linux-x64.tar.xz | ||
GitHK marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| tar -xvf 7z${SEVEN_ZIP_VERSION}-linux-x64.tar.xz | ||
| cp 7zz /usr/bin/7z | ||
|
|
||
| echo "remove install dir" | ||
| rm -rf /tmp/7zip | ||
|
|
||
| echo "test installation" | ||
| 7z --help | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/modules/seven_zip_wrapper.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| import asyncio | ||
| import logging | ||
| import re | ||
| from pathlib import Path | ||
|
|
||
| from models_library.basic_types import IDStr | ||
| from servicelib.progress_bar import ProgressBarData | ||
|
|
||
| from ..core.errors import SevenZipError | ||
| from ..core.utils import async_command | ||
|
|
||
| _logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| async def _get_file_count(zip_path: Path) -> int: | ||
| result = await async_command(f"7z l {zip_path}") | ||
GitHK marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if not result.success: | ||
| raise SevenZipError(command=result.command, command_result=result.message) | ||
|
|
||
| match = re.search(r"\s*(\d+)\s*files", result.message) | ||
GitHK marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return int(match.group().replace("files", "").strip() if match else "0") | ||
|
|
||
|
|
||
| async def unarchive_zip_to( | ||
| zip_path: Path, | ||
| output_dir: Path, | ||
| progress_bar: ProgressBarData | None = None, | ||
| ) -> set[Path]: | ||
| if not progress_bar: | ||
| progress_bar = ProgressBarData( | ||
| num_steps=1, description=IDStr(f"extracting {zip_path.name}") | ||
| ) | ||
|
|
||
| file_count = await _get_file_count(zip_path) | ||
|
|
||
| command = f"7z x {zip_path} -o{output_dir} -bb1" | ||
GitHK marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| process = await asyncio.create_subprocess_shell( | ||
| command, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE | ||
| ) | ||
| assert process.stdout # nosec | ||
| assert process.stderr # nosec | ||
|
|
||
| async with progress_bar.sub_progress( | ||
| steps=file_count, description=IDStr("...") | ||
GitHK marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ) as sub_prog: | ||
|
|
||
| while True: | ||
| line = await process.stdout.readline() | ||
| if not line: | ||
| break | ||
|
|
||
| line_decoded = line.decode().strip() | ||
| if line_decoded.startswith("- "): # check file entry | ||
| await sub_prog.update(1) | ||
GitHK marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| await process.wait() | ||
| if process.returncode != 0: | ||
| stderr = await process.stderr.read() | ||
| raise SevenZipError(command=command, command_result=stderr.decode().strip()) | ||
|
|
||
| return {x for x in output_dir.rglob("*") if x.is_file()} | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.