Skip to content

Commit

Permalink
fixes for 7z processor
Browse files Browse the repository at this point in the history
  • Loading branch information
jgstew committed Jul 7, 2024
1 parent 7951c68 commit 1057b3a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
3 changes: 2 additions & 1 deletion Mozilla/Firefox-Win.ChocolateyTemplate.recipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ Process:
# TODO create zip Firefox.nupkg
- Processor: com.github.jgstew.SharedProcessors/SevenZip
Arguments:
sevenzip_args: ["a -tzip firefox.nupkg ./tmp/*"]
sevenzip_args: ["a", "-tzip", "../firefox.nupkg", "*"]
relative_directory: tmp
19 changes: 14 additions & 5 deletions SharedProcessors/SevenZip.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ class SevenZip(Processor):
# "default": [],
"description": "Array of cmd args to pass to 7z executable.",
},
"relative_directory": {
"required": False,
"default": False,
"description": "relative directory.",
},
"ignore_errors": {
"required": False,
"default": True,
Expand All @@ -55,6 +60,7 @@ class SevenZip(Processor):
def main(self):
"""Execution starts here:"""
working_directory = self.env.get("RECIPE_CACHE_DIR")
relative_directory = self.env.get("relative_directory", False)
ignore_errors = self.env.get("ignore_errors", True)
sevenzip_args = self.env.get("sevenzip_args", [])
# verbosity = self.env.get("verbose", 0)
Expand All @@ -71,16 +77,19 @@ def main(self):
self.output(f"Using Path to 7zip: {sevenzip}")

# "-aoa" to always overwrite all files:
cmd = [sevenzip]
cmd = [sevenzip] + sevenzip_args

# if sevenzip_args and len(sevenzip_args) > 0:
# cmd.extend(sevenzip_args)

if sevenzip_args and len(sevenzip_args) > 0:
cmd.extend(sevenzip_args)
self.output(f"7zip cmd line to be executed: {cmd}", 1)

self.output(f"7zip cmd line to be executed: {cmd}", 3)
if relative_directory:
os.chdir(os.path.join(working_directory, relative_directory))

try:
cmd_output = subprocess.check_output(cmd).decode("utf-8")
self.output(f"Extraction Process Output: {cmd_output}", 4)
self.output(f"Extraction Process Output: {cmd_output}", 2)
except BaseException as err:
self.output(f"ERROR: {err}", 2)
if not ignore_errors:
Expand Down

0 comments on commit 1057b3a

Please sign in to comment.