Skip to content

Commit

Permalink
Merge pull request #11 from MGlants/check_outfolder
Browse files Browse the repository at this point in the history
Add check for output folder existence
  • Loading branch information
vm03 authored Sep 8, 2020
2 parents 78e70fe + bc707bc commit 6fffb9e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions payload_dumper.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import argparse
import bsdiff4
import io

import os
try:
import lzma
except ImportError:
Expand Down Expand Up @@ -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)')
Expand All @@ -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'

Expand Down Expand Up @@ -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)
dump_part(part)

0 comments on commit 6fffb9e

Please sign in to comment.