conn.close() else: # split tiles on column tiles = args.tiles.split(',') # sort tiles, why not ;-) tiles.sort() # force overwrite switch when rebuilding all files if args.rebuild: args.overwrite = True for tile in tiles: # init AWS module for this tile aws = AWS(args.quiet) aws.set_tile(tile) # get all available tiles if none are present yet or forced rebuild is requested if not aws.tile_exists() or args.rebuild: # create a new tile directory aws.create_tiledir() # find all scenes for this tile by year, month, day, scene years = aws.parse_bucket() if len(years) > 0: for year in years: months = aws.parse_bucket(year) if len(months) > 0: for month in months: days = aws.parse_bucket(year,month) if len(days) > 0:
from Sat.sentinel2_aws import AWS if __name__ == '__main__': """ initialize a new tile for the Sentinel-2 metadata monitoring application """ # parse commandline arguments parser = argparse.ArgumentParser(description='initialize a new tile for the Sentinel-2 metadata monitoring application') parser.add_argument('--tile', dest='tile', required=True, help='MGRS tilename to find scenes for (e.g. 32TPT)') parser.add_argument('--description', dest='description', required=True, help='short tile description (e.g. "Alpen - Tirol West")') parser.add_argument('--overwrite', dest='overwrite', action="store_true", help='force overwriting of existing metadata') parser.add_argument('--quiet', dest='quiet', action="store_true", default=False, help='run quietly') args = parser.parse_args() # init AWS library aws = AWS(args.quiet) aws.set_tile(args.tile) # (re)add MongoDB tile description conn = MongoClient('localhost', 27017) mdb = conn.sentinel2 mdb.aws_tilesMonitored.remove({'tile' : args.tile}) mdb.aws_tilesMonitored.insert({'tile' : args.tile,'description' : args.description}) if not args.quiet: print "UPDATE sentinel2.tilesMonitored OK" conn.close() # remove existing content if needed if os.path.exists("%s/%s" % (aws.get_basedir(),args.tile)): if args.overwrite: # remove existing content if not args.quiet: