Beispiel #1
0
def main():
    layername="LROC NAC"

    parser = optparse.OptionParser()
    parser.add_option('--resume', action='store_true', dest='resume', default=False)
    (options, args) = parser.parse_args()

    print "Getting connection...",
    cms = layers.get_default_client()
    print "Done."
    if options.resume:
        print "RESUME MODE"
        layer = get_first_layer(cms, layername)
        (schema_id, template_id) = get_schema_and_template(cms, layer.id)
        exclude_set = get_already_loaded_set()
        upload_nac_entities(cms, layer, schema_id, template_id, exclude=exclude_set)

    else:
        print "Creating layer."
        #delete_existing_layers(cms, layername)
        layer = cms.Create('layer', name=layername, world='moon', return_interface=True)
        print "Creating Schema"
        (schema_id, template_id) = create_nac_schema(cms, layer)
        print "Loading observations."
        sys.stdout.flush()
        upload_nac_entities(cms, layer, schema_id, template_id)
 def __init__(self, layername=None, metadata_path=None, label='CUMINDEX.LBL', table='CUMINDEX.TAB'):
     if layername:
         self.layername = layername
     if metadata_path:
         self.metadata_path = metadata_path
     assert hasattr(self, 'layername')
     assert hasattr(self, 'metadata_path')
     self.layer_id = None
     self.labelfile = os.path.join(self.metadata_path, label)
     self.tablefile = os.path.join(self.metadata_path, table)
     self.cms = layers.get_default_client()
 def _delete_layers_by_name(klass, name, cms=None):
     """ Delete all layers in the cms that exactly match a name """
     if not cms: cms = layers.get_default_client()
     layer_ids = cms.List('layer')
     i = 0
     for lid in layer_ids:
         layer = cms.Query('layer', lid, lid, nocontents='true')
         if layer['name'] == name:
             cms.Delete('layer',lid)
             i += 1
     if i:
         print "Deleted %d existing layers." % i