Skip to content

Commit

Permalink
Compression setting (#16)
Browse files Browse the repository at this point in the history
* Changed -m (new --mx) option to directly pass parameter to 7z.exe's -mx switch (0, 1, 3, 5, 7, 9)

* Updated
  • Loading branch information
phtnnz authored Oct 5, 2024
1 parent ab27073 commit d8b3fa7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ Supersedes nina-zip-ready-data and nina-zip-last-night.

```
usage: nina-zip-data [-h] [-v] [-d] [-n] [-l] [--ready] [--last] [--date DATE] [--subdir SUBDIR] [--targets TARGETS] [--hostname HOSTNAME]
[-t TIME_INTERVAL] [-m]
[-t TIME_INTERVAL] [-m MX]
Zip (7z) N.I.N.A data and upload
Expand All @@ -195,16 +195,16 @@ options:
-n, --no-action dry run
-l, --low-priority set process priority to low
--ready run in TARGET.ready mode
--last run in last night mode (2024-08-29)
--last run in last night mode (2024-10-05)
--date DATE run in archive data from DATE mode
--subdir SUBDIR search SUBDIR_YYYY-MM-DD in data dir for ready targets (--ready)
--targets TARGETS archive TARGET[,TARGET] only (--last / --date)
--hostname HOSTNAME load settings for HOSTNAME (default numenor)
-t TIME_INTERVAL, --time-interval TIME_INTERVAL
time interval for checking data directory (default 60s)
-m, --zip-max 7-zip max compression -mx7
-m MX, --mx MX 7-Zip compression setting -mx (default 5), 0=none, 1=fastest, 3=fast, 5=normal, 7=max, 9=ultra
Version 1.4 / 2024-08-29 / Martin Junius
Version 1.5 / 2024-10-05 / Martin Junius
```

### --ready / --subdir mode
Expand Down
14 changes: 8 additions & 6 deletions nina-zip-data.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
# Version 1.4 / 2024-08-29
# Added "zip sub" to config file, override of default "%Y/%m" for sub directory
# under zip dir
# Version 1.5 / 2024-10-05
# Changed -m (new --mx) Option to directly pass parameter to 7z.exe -mx switch

import os
import argparse
Expand All @@ -84,7 +86,7 @@

NAME = "nina-zip-data"
DESCRIPTION = "Zip (7z) N.I.N.A data and upload"
VERSION = "1.4 / 2024-08-29"
VERSION = "1.5 / 2024-10-05"
AUTHOR = "Martin Junius"

TIMER = 60
Expand Down Expand Up @@ -194,7 +196,7 @@ class Options:
zipprog = config.zip_prog()
rcloneprog= config.rclone_prog()
upload = config.upload_method() # False=move, True=rclone
zipmx = 5 # normal compression, -m --max => 7 = max compression
zipmx = 5 # Compression, 0=none, 1=fastest, 3=fast, 5=normal, 7=max, 9=ultra
run_ready = False
run_last = False
timer = TIMER
Expand Down Expand Up @@ -315,7 +317,7 @@ def create_zip_archive(target, datadir, zipfile):
# 7z.exe a -t7z -mx=7 -r -spf zipfile target
# a add files to archive
# -t7z set archive type to 7z
# -mx7 set compression level to maximum (5=normal, 7=maximum, 9=ultra)
# -mx5 set compression level to maximum (0=none, 3=fast, 5=normal (default), 7=maximum, 9=ultra)
# -r recurse subdirectories
# -spf use fully qualified file paths
args7z = [ Options.zipprog, "a", "-t7z", f"-mx{Options.zipmx}", "-r", "-spf", zipfile, target ]
Expand Down Expand Up @@ -459,7 +461,7 @@ def main():
arg.add_argument("--targets", help="archive TARGET[,TARGET] only (--last / --date)")
arg.add_argument("--hostname", help=f"load settings for HOSTNAME (default {ZipConfig.hostname})")
arg.add_argument("-t", "--time-interval", type=int, help=f"time interval for checking data directory (default {TIMER}s)")
arg.add_argument("-m", "--zip-max", action="store_true", help="7-zip max compression -mx7")
arg.add_argument("-m", "--mx", type=int, help=f"7-Zip compression setting -mx (default {Options.zipmx}), 0=none, 1=fastest, 3=fast, 5=normal, 7=max, 9=ultra")
args = arg.parse_args()

if args.verbose:
Expand All @@ -483,8 +485,8 @@ def main():
Options.rcloneprog= config.rclone_prog()
Options.upload = config.upload_method()

if args.zip_max:
Options.zipmx = 7
if args.mx:
Options.zipmx = args.mx
if args.time_interval:
Options.timer = args.time_interval
Options.run_ready = args.ready
Expand Down

0 comments on commit d8b3fa7

Please sign in to comment.