def main(args): '''Retrieve all instrument deployment events, group them by array subsite, and print the response as a JSON object''' status = 1 # Create the UFrame instance if args.base_url: uframe = UFrame(base_url=args.base_url, timeout=args.timeout) else: uframe = UFrame(timeout=args.timeout) # Fetch the events request uframe.fetch_events() if not uframe.events: sys.stderr.write('No events requested: {:s}\n'.format(uframe)) sys.stdout.write('[]\n') return status # Get only the .DeploymentEvents deployment_events = uframe.search_events_by_type('.DeploymentEvent') if not deployment_events: sys.stderr.write('No .DeploymentEvents found: {:s}\n'.format(uframe)) sys.stdout.write('[]\n') return status # Create the grouping of instrument deployments organized by array subsite instruments = group_instrument_deployment_events_by_subsite(deployment_events) # JSON encode and print to STDOUT sys.stdout.write('{:s}\n'.format(json.dumps(instruments))) status = 0 return status
def main(args): '''Return the fully qualified reference designator list for all instruments producing the specified stream in the specified UFrame instance. The stream may be a partial or complete stream name''' status = 0 base_url = args.base_url if not base_url: if args.verbose: sys.stderr.write('No uframe_base specified. Checking UFRAME_BASE_URL environment variable\n') base_url = os.getenv('UFRAME_BASE_URL') if not base_url: sys.stderr.write('No UFrame instance specified') sys.stderr.flush() return 1 # Create a UFrame instance if args.verbose: sys.stderr.write('Creating UFrame API instance\n') uframe = UFrame(base_url=base_url, timeout=args.timeout, validate=args.validate_uframe) # Fetch the table of contents from UFrame if args.verbose: t0 = datetime.datetime.utcnow() sys.stderr.write('Fetching and creating UFrame table of contents...') uframe.fetch_toc() if args.verbose: t1 = datetime.datetime.utcnow() dt = t1 - t0 sys.stderr.write('Complete ({:d} seconds)\n'.format(dt.seconds)) if args.stream_name: instruments = uframe.stream_to_instrument(args.stream_name) else: instruments = uframe.streams if args.json: json.dumps(instruments) else: for instrument in instruments: sys.stdout.write('{:s}\n'.format(instrument)) return status
def main(args): '''Return the list of all arrays iin the UFrame instance if no partial or fully-qualified array is specified.''' status = 0 base_url = args.base_url if not base_url: if args.verbose: sys.stderr.write('No uframe_base specified. Checking UFRAME_BASE_URL environment variable\n') base_url = os.getenv('UFRAME_BASE_URL') if not base_url: sys.stderr.write('No UFrame instance specified') sys.stderr.flush() return 1 # Create a UFrame instance if args.verbose: sys.stderr.write('Creating UFrame API instance\n') uframe = UFrame(base_url=base_url, timeout=args.timeout, validate=args.validate_uframe) # Fetch the table of contents from UFrame if args.verbose: t0 = datetime.datetime.utcnow() sys.stderr.write('Fetching and creating UFrame table of contents...') uframe.fetch_toc() if args.verbose: t1 = datetime.datetime.utcnow() dt = t1 - t0 sys.stderr.write('Complete ({:d} seconds)\n'.format(dt.seconds)) if (args.array): arrays = uframe.search_arrays(args.array) else: arrays = uframe.arrays if args.json: json.dumps(arrays) else: for array in arrays: sys.stdout.write('{:s}\n'.format(array)) return status
def main(args): '''Return the fully qualified reference designator list for all instruments if no partial or fully-qualified reference_designator is specified. Specify the -s or --streams option to include metadata for all streams produced by the instrument(s)''' status = 0 base_url = args.base_url if not base_url: if args.verbose: sys.stderr.write('No uframe_base specified. Checking UFRAME_BASE_URL environment variable\n') base_url = os.getenv('UFRAME_BASE_URL') if not base_url: sys.stderr.write('No UFrame instance specified') sys.stderr.flush() return 1 # Create a UFrame instance if args.verbose: sys.stderr.write('Creating UFrame API instance\n') uframe = UFrame(base_url=base_url, timeout=args.timeout, validate=args.validate_uframe) # Fetch the table of contents from UFrame if args.verbose: t0 = datetime.datetime.utcnow() sys.stderr.write('Fetching and creating UFrame table of contents...') uframe.fetch_toc() if args.verbose: t1 = datetime.datetime.utcnow() dt = t1 - t0 sys.stderr.write('Complete ({:d} seconds)\n'.format(dt.seconds)) if args.reference_designator: if args.streams: instruments = uframe.instrument_to_streams(args.reference_designator) else: instruments = uframe.search_instruments(args.reference_designator) else: instruments = uframe.instruments if not instruments: sys.stderr.write('{:s}: No instrument matches found\n'.format(args.reference_designator)) return status if args.json: sys.stdout.write(json.dumps(instruments)) elif args.streams: csv_writer = csv.writer(sys.stdout) if args.metadata: cols = instruments[0].keys() cols.sort() else: cols = ['reference_designator', 'stream'] csv_writer.writerow(cols) for instrument in instruments: csv_writer.writerow([instrument[k] for k in cols]) else: for instrument in instruments: sys.stdout.write('{:s}\n'.format(instrument)) return status
def main(args): """Return the list of request urls that conform to the UFrame API for the partial or fully-qualified reference_designator and all telemetry types. The URLs request all stream L0, L1 and L2 dataset parameters over the entire time-coverage. The urls are printed to STDOUT. """ status = 0 base_url = args.base_url if not base_url: if args.verbose: sys.stderr.write("No uframe_base specified. Checking UFRAME_BASE_URL environment variable\n") base_url = os.getenv("UFRAME_BASE_URL") if not base_url: sys.stderr.write("No UFrame instance specified") sys.stderr.flush() return 1 # Create a UFrame instance if args.verbose: sys.stderr.write("Creating UFrame API instance\n") uframe = UFrame(base_url=base_url, timeout=args.timeout, validate=args.validate_uframe) # Fetch the table of contents from UFrame if args.verbose: t0 = datetime.datetime.utcnow() sys.stderr.write("Fetching and creating UFrame table of contents...") uframe.fetch_toc() if args.verbose: t1 = datetime.datetime.utcnow() dt = t1 - t0 sys.stderr.write("Complete ({:d} seconds)\n".format(dt.seconds)) if args.reference_designator: instruments = uframe.search_instruments(args.reference_designator) else: instruments = uframe.instruments if not instruments: sys.stderr.write("No instruments found for reference designator: {:s}\n".format(args.reference_designator)) sys.stderr.flush() urls = [] for instrument in instruments: request_urls = uframe.instrument_to_query( instrument, telemetry=args.telemetry, time_delta_type=args.time_delta_type, time_delta_value=args.time_delta_value, begin_ts=args.start_date, end_ts=args.end_date, time_check=args.time_check, exec_dpa=args.no_dpa, application_type=args.format, provenance=args.no_provenance, limit=args.limit, annotations=args.no_annotations, user=args.user, email=args.email, selogging=args.selogging, ) for request_url in request_urls: urls.append(request_url) for url in urls: sys.stdout.write("{:s}\n".format(url)) return status
def main(args): '''Return the list of request urls that conform to the UFrame API for the partial or fully-qualified reference_designator and all telemetry types. The start and end times for each query are set to the deployment start and end times taken from UFrame's asset management web-service API. The URLs request all stream L0, L1 and L2 dataset parameters over the entire time-coverage. The urls are printed to STDOUT. ''' status = 0 base_url = args.base_url if not base_url: if args.verbose: sys.stderr.write('No uframe_base specified. Checking UFRAME_BASE_URL environment variable\n') base_url = os.getenv('UFRAME_BASE_URL') if not base_url: sys.stderr.write('No UFrame instance specified') sys.stderr.flush() return 1 # Create a UFrame instance if args.verbose: sys.stderr.write('Creating UFrame API instance\n') uframe = UFrame(base_url=base_url, timeout=args.timeout, validate=args.validate_uframe) # Fetch the table of contents from UFrame if args.verbose: t0 = datetime.datetime.utcnow() sys.stderr.write('Fetching and creating UFrame table of contents...') # Fetch the UFrame table of contents uframe.fetch_toc() # Fetch the UFrame events uframe.fetch_events() # Set args.tense to None if not either 'past' or 'present' if args.tense.lower() not in ['past', 'present']: args.tense = None if args.verbose: t1 = datetime.datetime.utcnow() dt = t1 - t0 sys.stderr.write('Complete ({:d} seconds)\n'.format(dt.seconds)) if (args.reference_designator): instruments = uframe.search_instruments(args.reference_designator) else: instruments = uframe.instruments if not instruments: sys.stderr.write('No instruments found for reference designator: {:s}\n'.format(args.reference_designator)) sys.stderr.flush() urls = [] for instrument in instruments: request_urls = uframe.instrument_to_deployment_query(instrument, deployment_number = args.deployment_number, tense = args.tense, telemetry=args.telemetry, time_check=args.time_check, exec_dpa=args.no_dpa, application_type=args.format, provenance=args.no_provenance, limit=args.limit, annotations=args.no_annotations, user=args.user, email=args.email) for request_url in request_urls: urls.append(request_url) for url in urls: sys.stdout.write('{:s}\n'.format(url)) return status