Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def quad_info(name, quad, pretty):
'''Get information for a specific mosaic quad'''
cl = clientv1()
mosaic, = cl.get_mosaic_by_name(name).items_iter(1)
echo_json_response(call_and_wrap(cl.get_quad_by_id, mosaic, quad), pretty)
def get_feed_info(feed_id, pretty):
'''Get metadata for specific feed.'''
cl = clientv1()
feed_info = cl.get_feed_info(feed_id)
echo_json_response(feed_info, pretty)
def list_features(subscription_id, pretty, limit, rbox, bbox, time_range,
before, after):
'''Request feature list for a particular subscription, 100 at a time.'''
cl = clientv1()
bbox = bbox or rbox
features = cl.list_collection_features(subscription_id, bbox, time_range,
before, after)
echo_json_response(features, pretty, limit)
def cancel_order(order_id, pretty):
'''Cancel a running order by given order ID'''
cl = clientv1()
echo_json_response(call_and_wrap(cl.cancel_order, order_id), pretty)
def download(asset_type, dest, limit, sort, search_id, dry_run, activate_only,
quiet, **kw):
'''Activate and download'''
cl = clientv1()
page_size = min(limit or MAX_PAGE_SIZE, MAX_PAGE_SIZE)
asset_type = list(chain.from_iterable(asset_type))
# even though we're using functionality from click.Path, this was needed
# to detect inability to write on Windows in a read-only vagrant mount...
# @todo check/report upstream
if not activate_only and not check_writable(dest):
raise click.ClickException(
'download destination "%s" is not writable' % dest)
if search_id:
if dry_run:
raise click.ClickException(
'dry-run not supported with saved search')
if any(kw[s] for s in kw):
raise click.ClickException(
'search options not supported with saved search')
search, search_arg = cl.saved_search, search_id
def quad_contributions(name, quad, pretty):
'''Get contributing scenes for a mosaic quad'''
cl = clientv1()
mosaic, = cl.get_mosaic_by_name(name).items_iter(1)
quad = cl.get_quad_by_id(mosaic, quad).get()
response = call_and_wrap(cl.get_quad_contributions, quad)
echo_json_response(response, pretty)
def quick_search(limit, pretty, sort, **kw):
'''Execute a quick search.'''
req = search_req_from_opts(**kw)
cl = clientv1()
page_size = min(limit, MAX_PAGE_SIZE)
echo_json_response(call_and_wrap(
cl.quick_search, req, page_size=page_size, sort=sort
), pretty, limit)
def get_mosaic_list_for_collection(subscription_id):
'''List mosaics linked to feed'''
cl = clientv1()
sub_info = cl.get_subscription_info(subscription_id).get()
feed_info = cl.get_feed_info(sub_info['feedID']).get()
for type_ in ['target', 'source']:
feed_image_conf = feed_info.get(type_)
if feed_image_conf['type'] != 'mosaic':
msg_format = 'The {} for this feed is not a mosaic type.'
click.ClickException(msg_format.format(type_))
continue
mosaic_series = feed_image_conf['config']['series_id']
mosaics = cl.get_mosaics_for_series(mosaic_series)
click.echo('{} mosaics:'.format(type_))
def stats(pretty, **kw):
'''Get search stats'''
req = search_req_from_opts(**kw)
cl = clientv1()
echo_json_response(call_and_wrap(cl.stats, req), pretty)
def get_mosaic_list_for_subscription(subscription_id):
'''List mosaics linked to feed'''
cl = clientv1()
sub_info = cl.get_subscription_info(subscription_id).get()
feed_info = cl.get_feed_info(sub_info['feedID']).get()
for type_ in ['target', 'source']:
feed_image_conf = feed_info.get(type_)
if feed_image_conf['type'] != 'mosaic':
msg_format = 'The {} for this feed is not a mosaic type.'
click.ClickException(msg_format.format(type_))
continue
mosaic_series = feed_image_conf['config']['series_id']
mosaics = cl.get_mosaics_for_series(mosaic_series)
click.echo('{} mosaics:'.format(type_))