def list_(ctx): """List all instruments""" for c in get_metadata(Instrument): descriptor = ' '.join([c.name, c.model, c.serial]) station = '{}{}'.format(c.station.station_type, c.station_id) click.echo('{} - {}, {}'.format(descriptor.ljust(30), station, c.dataset_id))
def update(ctx, identifier, station, dataset, contributor, name, model, serial, geometry): """Update instrument information""" instrument_ = {} if station: instrument_['station_id'] = station if dataset: instrument_['dataset_id'] = dataset if station or contributor: if station and (not contributor): inst = get_metadata(Instrument, identifier) cbtr = inst[0].deployment.contributor_id instrument_['deployment_id'] = ':'.join([station, cbtr]) elif contributor and (not station): inst = get_metadata(Instrument, identifier) stn = inst[0].station_id instrument_['deployment_id'] = ':'.join([stn, contributor]) elif contributor and station: instrument_['deployment_id'] = ':'.join([station, contributor]) if name: instrument_['name'] = name if model: instrument_['model'] = model if serial: instrument_['serial'] = serial if geometry: geom_tokens = geometry.split(',') if len(geom_tokens) == 2: geom_tokens.append(None) instrument_['x'] = geom_tokens[1] instrument_['y'] = geom_tokens[0] instrument_['z'] = geom_tokens[2] if len(instrument_.keys()) == 0: click.echo('No updates specified') return update_metadata(Instrument, identifier, instrument_, save_to_registry, save_to_index) click.echo('Instrument {} updated'.format(identifier))
def show(ctx, identifier): """Show deployment details""" r = get_metadata(Deployment, identifier) if len(r) == 0: click.echo('Deployment not found') return click.echo( json.dumps(r[0].__geo_interface__, indent=4, default=json_serial))
def show(ctx, identifier): """Show contributor details""" r = get_metadata(Contributor, identifier) if len(r) == 0: click.echo('Contributor not found') return click.echo(json.dumps(r[0].__geo_interface__, indent=4, default=json_serial))
def show(ctx, identifier): """Show news notification details""" r = get_metadata(Notification, identifier) if len(r) == 0: click.echo('Notification not found') return click.echo( json.dumps(r[0].__geo_interface__, indent=4, default=json_serial))
def delete(ctx, identifier): """Delete a station""" if len(get_metadata(Station, identifier)) == 0: click.echo('Station not found') return q = 'Are you sure you want to delete station {}?'.format(identifier) if click.confirm(q): # noqa delete_metadata(Station, identifier) click.echo('Station {} deleted'.format(identifier))
def delete(ctx, identifier): """Delete a contributor""" if len(get_metadata(Contributor, identifier)) == 0: click.echo('Contributor not found') return q = 'Are you sure you want to delete contributor {}?'.format(identifier) if click.confirm(q): # noqa delete_metadata(Contributor, identifier) click.echo('Contributor {} deleted'.format(identifier))
def delete(ctx, identifier): """Delete an instrument""" if len(get_metadata(Instrument, identifier)) == 0: click.echo('Instrument not found') return q = 'Are you sure you want to delete instrument {}?'.format(identifier) if click.confirm(q): # noqa delete_metadata(Instrument, identifier, save_to_registry, save_to_index) click.echo('Instrument {} deleted'.format(identifier))
def delete(ctx, identifier): """Delete a station""" if len(get_metadata(Notification, identifier)) == 0: click.echo('Station not found') return q = 'Are you sure you want to delete news notification {}?' \ .format(identifier) if click.confirm(q): # noqa delete_metadata(Notification, identifier, save_to_registry, save_to_index) click.echo('News notification {} deleted'.format(identifier))
def list_(ctx): """List all deployments""" for c in get_metadata(Deployment): click.echo('{} @ {}'.format(c.contributor_id.ljust(20), c.station_id))
def list_(ctx): """List all stations""" for c in get_metadata(Station): click.echo('{} {}'.format(c.identifier.ljust(3), c.name))
def list_(ctx): """List all contributors""" for c in get_metadata(Contributor): click.echo('{} {}'.format(c.identifier.ljust(15), c.name))
def list_(ctx): """List all stations""" for c in get_metadata(Station): click.echo('{} {}'.format(c.station_id.ljust(3), c.station_name.name))
def list_(ctx): """List all news notifications""" for c in get_metadata(Notification): click.echo('{} {}'.format(c.published_date, c.title_en))
def list_(ctx): """List all contributors""" for c in get_metadata(Contributor): click.echo('{} {}'.format(c.contributor_id.ljust(24), c.name))