Skip to content

Commit 859df55

Browse files
author
Scisco
committed
add --force-unzip flag
1 parent 81a286e commit 859df55

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

landsat/landsat.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@
8686
8787
--region URL to S3 region e.g. s3-us-west-2.amazonaws.com
8888
89+
--force-unzip Force unzip tar file
90+
8991
Process:
9092
landsat.py process path [-h] [-b --bands] [-p --pansharpen]
9193
@@ -115,6 +117,8 @@
115117
--bucket Bucket name (required if uploading to s3)
116118
117119
--region URL to S3 region e.g. s3-us-west-2.amazonaws.com
120+
121+
--force-unzip Force unzip tar file
118122
"""
119123

120124

@@ -179,6 +183,7 @@ def args_options():
179183
'as Environment Variables)')
180184
parser_download.add_argument('--bucket', help='Bucket name (required if uploading to s3)')
181185
parser_download.add_argument('--region', help='URL to S3 region e.g. s3-us-west-2.amazonaws.com')
186+
parser_download.add_argument('--force-unzip', help='Force unzip tar file', action='store_true')
182187

183188
parser_process = subparsers.add_parser('process', help='Process Landsat imagery')
184189
parser_process.add_argument('path',
@@ -198,6 +203,7 @@ def args_options():
198203
'as Environment Variables)')
199204
parser_process.add_argument('--bucket', help='Bucket name (required if uploading to s3)')
200205
parser_process.add_argument('--region', help='URL to S3 region e.g. s3-us-west-2.amazonaws.com')
206+
parser_process.add_argument('--force-unzip', help='Force unzip tar file', action='store_true')
201207

202208
return parser
203209

@@ -221,9 +227,11 @@ def main(args):
221227
v = VerbosityMixin()
222228

223229
if args:
230+
224231
if args.subs == 'process':
225232
verbose = True if args.verbose else False
226-
stored = process_image(args.path, args.bands, verbose, args.pansharpen)
233+
force_unzip = True if args.force_unzip else False
234+
stored = process_image(args.path, args.bands, verbose, args.pansharpen, force_unzip)
227235

228236
if args.upload:
229237
u = Uploader(args.key, args.secret, args.region)
@@ -272,6 +280,7 @@ def main(args):
272280
downloaded = d.download(args.scenes, convert_to_integer_list(args.bands))
273281

274282
if args.process:
283+
force_unzip = True if args.force_unzip else False
275284
for scene, src in downloaded.iteritems():
276285
if args.dest:
277286
path = join(args.dest, scene)
@@ -282,7 +291,7 @@ def main(args):
282291
if src == 'google':
283292
path = path + '.tar.bz'
284293

285-
stored = process_image(path, args.bands, False, args.pansharpen)
294+
stored = process_image(path, args.bands, False, args.pansharpen, force_unzip)
286295

287296
if args.upload:
288297
try:
@@ -302,7 +311,7 @@ def main(args):
302311
return ['The SceneID provided was incorrect', 1]
303312

304313

305-
def process_image(path, bands=None, verbose=False, pansharpen=False):
314+
def process_image(path, bands=None, verbose=False, pansharpen=False, force_unzip=None):
306315
""" Handles constructing and image process.
307316
308317
:param path:
@@ -327,7 +336,7 @@ def process_image(path, bands=None, verbose=False, pansharpen=False):
327336
"""
328337
try:
329338
bands = convert_to_integer_list(bands)
330-
p = Process(path, bands=bands, verbose=verbose)
339+
p = Process(path, bands=bands, verbose=verbose, force_unzip=force_unzip)
331340
except IOError:
332341
exit("Zip file corrupted", 1)
333342
except FileDoesNotExist as e:

0 commit comments

Comments
 (0)