From bc707bccadb96c22ea759df8fa2309b1852fae0e Mon Sep 17 00:00:00 2001 From: Mark Glants Date: Mon, 31 Aug 2020 01:28:29 +0300 Subject: [PATCH] Add check for output folder existence --- payload_dumper.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/payload_dumper.py b/payload_dumper.py index 5d9aa70..d593ecb 100644 --- a/payload_dumper.py +++ b/payload_dumper.py @@ -6,7 +6,7 @@ import argparse import bsdiff4 import io - +import os try: import lzma except ImportError: @@ -114,7 +114,7 @@ def dump_part(part): parser = argparse.ArgumentParser(description='OTA payload dumper') -parser.add_argument('payloadfile', type=argparse.FileType('rb'), +parser.add_argument('payloadfile', type=argparse.FileType('rb'), help='payload file name') parser.add_argument('--out', default='output', help='output directory (defaul: output)') @@ -124,6 +124,10 @@ def dump_part(part): help='directory with original images for differential OTA (defaul: old)') args = parser.parse_args() +#Check for --out directory exists +if not os.path.exists(args.out): + os.makedirs(args.out) + magic = args.payloadfile.read(4) assert magic == b'CrAU' @@ -154,4 +158,4 @@ def dump_part(part): # extents = flatten([op.dst_extents for op in part.operations]) # assert verify_contiguous(extents), 'operations do not span full image' - dump_part(part) \ No newline at end of file + dump_part(part)