Example #1
0
def metadata(req,scene=None,filename=None):
    """ show auxilliary metadata files for scenes """

    # init AWS module
    aws = AWS()
    aws.set_scene(scene)
    attr = aws.get_scene_attributes()

    # make sure that name of scene is valid
    if not aws.is_valid_scene_name(scene):
        return "Error: invalid scene requested."

    # make sure that filename is valid
    if not filename in aws.get_metadata_filenames():
        return "Error: invalid filename requested"

    # strip qi/ subdirectory from cloudmask
    filename = re.sub('qi/','',filename)

    # link original file to temporary directory and redirect
    in_path = "%s/%s/metadata/%s_%s" % (aws.get_basedir(),attr['tile'],scene,filename)
    out_path = "/home/institut/www/html/data/sentinel2/metatmp/%s_%s" % (scene,filename)
    out_url = re.sub('/home/institut/www/html','',out_path)

    if os.path.exists(in_path):
        if not os.path.exists(out_path):
            os.symlink(in_path,out_path)
        redirect(req,out_url)
    else:
        return "Error: File %s for scene %s does not exist." % (filename,scene)
Example #2
0
    # 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:
                print "removing %s/%s" % (aws.get_basedir(),args.tile)
            shutil.rmtree("%s/%s" % (aws.get_basedir(),args.tile))
        else:
            print "WARNING: tile %s already exists. Use --overwrite to force rebuilding" % args.tile
            sys.exit()

    # get metadata for all available scenes
    os.system("/usr/bin/python %s/02_aws_get_metadata.py --tiles=%s --rebuild %s" % (
        os.path.dirname(os.path.realpath(__file__)),
        args.tile,
        ('--quiet' if args.quiet else '')
    ))
Example #3
0
    # parse commandline arguments
    parser = argparse.ArgumentParser(description='remove all metadata, data and MongoDB description for a given Sentinel-2 tile')
    parser.add_argument('--tile', dest='tile', required=True, help='MGRS tilename(s) to remove (e.g. 32TPT)')
    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)

    # remove MongoDB tile description and metadata
    conn = MongoClient('localhost', 27017)
    mdb = conn.sentinel2
    mdb.aws_tilesMonitored.remove({'tile' : args.tile})
    mdb.aws_tileInfo.remove({'_name' : args.tile})

    if not args.quiet:
        print "DELETE sentinel2.tilesMonitored OK"
        print "DELETE sentinel2.aws_tileInfo OK"

    conn.close()

    # remove all metadata and data stored in the filesystem
    if os.path.exists("%s/%s" % (aws.get_basedir(),args.tile)):
        # remove existing content
        if not args.quiet:
            print "removing %s/%s" % (aws.get_basedir(),args.tile)
        shutil.rmtree("%s/%s" % (aws.get_basedir(),args.tile))