Beispiel #1
0
def main():


    log = setup_logging("sentinal.log")

    parser = argparse.ArgumentParser(description='Grabs sentinal images from the ESA stite',
                                     epilog='-h for help',
                                     formatter_class=argparse.RawTextHelpFormatter)

    parser.add_argument('-c', action="store_true", help='create db table only', dest='create_db') 
    parser.add_argument('-C', type=str, help='path to the configuration file', dest='configuration_file') 
    parser.add_argument('-f', action="store_true", help='force', dest='force')
    parser.add_argument('-v', action="store_true", help='run verbosely', dest='verbose')
    parser.add_argument('-o', action="store_true", help='overwrite data .zip file even if it exists', dest='overwrite')

    args = parser.parse_args()

    db = Database(args)

    if args.create_db: 
        db.createDb(args.verbose)
        sys.exit(0)

    config = ConfigManager(args.configuration_file,log)

    auth = config.getAuth()
    if not len(auth):
        log.error('Missing ESA SCIHUB authentication information')
        sys.exit(7)

    types = config.getTypes()
    polygons = config.getPolygons()
    if len(types) != len(polygons):
        log.error( 'Incorrect number of polygons and types in configuration file' )
        sys.exit(6)

    downloader = Downloader(args, config, db, log)
    downloader.getProducts()
    downloader.downloadProducts()