Commit 2cefd271 authored by Pedro Alfonso Ramirez's avatar Pedro Alfonso Ramirez

Add unzip

parent 9f209e69
......@@ -35,7 +35,7 @@ Functions:
from argparse import ArgumentParser
import os
import os,sys
import zipfile
from collections import OrderedDict
......@@ -84,13 +84,18 @@ SENTINEL_UNZIP_ARGUMENTS.add_argument("product_type", help="sentinel product typ
def find_files(args):
check_existing_directory(args.folder, 2)
folder = args.folder
satelite = args.plattform
files = os.listdir(folder)
if(satelite=="Sentinel-1"):
if(satelite!="Sentinel-1")or(satelite!="sentinel-1")or(satelite=="Sentinel-2")or(satelite=="sentinel-2"):
print satelite + " not exist"
sys.exit()
else:
if(satelite=="Sentinel-1")or(satelite=="sentinel-1"):
namfil1 = 'S1A_'+ args.product_type
namfil2 = 'S1B_'+ args.product_type
if(satelite=="Sentinel-2"):
if(satelite=="Sentinel-2")or(satelite=="sentinel-2"):
namfil1 = 'S2A_'+ args.product_type
namfil2 = 'S2B_'+ args.product_type
files = [f for f in files if f.startswith(namfil1) or f.startswith(namfil2)]
......@@ -106,13 +111,19 @@ def unzip(list_files,args):
zip_ref.extractall(args.folder) # extract file to dir
zip_ref.close() # close file
def check_existing_directory(folder) :
def check_existing_directory(folder,flag):
if(flag==1):
if not os.path.exists(folder):
os.makedirs(folder)
print folder + " was created"
else:
print folder + " exists "
if(flag == 2):
if not os.path.exists(folder):
print folder + " not exist"
sys.exit()
def select_products( products_list , products_df, user_footprint, threshold ) :
......@@ -144,7 +155,7 @@ def select_products( products_list , products_df, user_footprint, threshold ) :
def download_sentinel_mages(args):
check_existing_directory(args.output_folder)
check_existing_directory(args.output_folder,1)
products = SentinelData()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment