Adding output dir as script input
This commit is contained in:
parent
41d7a6848e
commit
687513725c
@ -68,8 +68,8 @@ STATE_FILE = Path("last_run.txt")
|
|||||||
MAX_RUN_TIME = 2 * 60 * 60 # 2 hours in seconds
|
MAX_RUN_TIME = 2 * 60 * 60 # 2 hours in seconds
|
||||||
|
|
||||||
# Ensure the output directories exist
|
# Ensure the output directories exist
|
||||||
IMG_DIR.mkdir(exist_ok=True)
|
IMG_DIR.mkdir(parents=True, exist_ok=True)
|
||||||
META_DIR.mkdir(exist_ok=True)
|
META_DIR.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
@ -88,6 +88,12 @@ def parse_args() -> argparse.Namespace:
|
|||||||
type=str,
|
type=str,
|
||||||
help="End date (YYYY-MM-DD). Defaults to today.",
|
help="End date (YYYY-MM-DD). Defaults to today.",
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--output",
|
||||||
|
type=str,
|
||||||
|
default=".",
|
||||||
|
help="Base directory where images/ and metadata/ folders will be created. Default is the current working directory.",
|
||||||
|
)
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
@ -181,6 +187,15 @@ def save_metadata(item: Dict, dest: Path) -> None:
|
|||||||
def main() -> None:
|
def main() -> None:
|
||||||
args = parse_args()
|
args = parse_args()
|
||||||
|
|
||||||
|
# Resolve output base directory and override global paths
|
||||||
|
base_dir = Path(args.output).resolve()
|
||||||
|
global IMG_DIR, META_DIR, STATE_FILE
|
||||||
|
IMG_DIR = base_dir / "images"
|
||||||
|
META_DIR = base_dir / "metadata"
|
||||||
|
STATE_FILE = base_dir / "last_run.txt"
|
||||||
|
IMG_DIR.mkdir(parents=True, exist_ok=True)
|
||||||
|
META_DIR.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
start_date = (
|
start_date = (
|
||||||
datetime.datetime.strptime(args.start, "%Y-%m-%d")
|
datetime.datetime.strptime(args.start, "%Y-%m-%d")
|
||||||
if args.start
|
if args.start
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user