def list_(self, args): opts = utils.CommandOptions(args) client = YamcsClient(**opts.client_kwargs) archive = client.get_archive(opts.instance) rows = [['NAME']] for table in archive.list_tables(): rows.append([ table.name, ]) utils.print_table(rows)
def subscribe(self, args): def on_data(stream_data): print(stream_data._proto) #pylint: disable=protected-access opts = utils.CommandOptions(args) client = YamcsClient(**opts.client_kwargs) archive = client.get_archive(opts.instance) try: subscription = archive.create_stream_subscription(args.stream, on_data=on_data) subscription.result() except KeyboardInterrupt: pass
def load(self, args): opts = utils.CommandOptions(args) client = YamcsClient(**opts.client_kwargs) archive = client.get_archive(opts.instance) for table in args.tables: path = table + '.dump' if args.dir: path = os.path.join(args.dir, path) with gzip.open(path, 'rb') as f: stdout.write(table) stdout.flush() n = archive.load_table(table, data=f) stdout.write('\r{}: loaded {} rows'.format(table, n)) stdout.write('\n')
def load(self, args): opts = utils.CommandOptions(args) client = YamcsClient(**opts.client_kwargs) archive = client.get_archive(opts.instance) for table in args.tables: path = table + '.dump.gz' if args.gzip else table + '.dump' if args.dir: path = os.path.join(args.dir, path) if args.gzip: with gzip.open(path, 'rb') as f: self.read_dump(f, archive, table, path) else: with open(path, 'rb') as f: self.read_dump(f, archive, table, path)
def dump(self, args): if args.dir: if not os.path.exists(args.dir): os.makedirs(args.dir) opts = utils.CommandOptions(args) client = YamcsClient(**opts.client_kwargs) archive = client.get_archive(opts.instance) for table in args.tables: path = table + '.dump.gz' if args.gzip else table + '.dump' if args.dir: path = os.path.join(args.dir, path) if args.gzip: with gzip.open(path, 'wb', compresslevel=1) as f: self.write_dump(f, archive, table, path) else: with open(path, 'wb') as f: self.write_dump(f, archive, table, path)
def dump(self, args): if args.dir: if not os.path.exists(args.dir): os.makedirs(args.dir) opts = utils.CommandOptions(args) client = YamcsClient(**opts.client_kwargs) archive = client.get_archive(opts.instance) for table in args.tables: path = table + '.dump' if args.dir: path = os.path.join(args.dir, path) with gzip.open(path, 'wb') as f: size = 0 t1 = time.time() for chunk in archive.dump_table(table): size += f.write(chunk) t2 = time.time() rate = (size / 1024 / 1024) / (t2 - t1) stdout.write('\r{}: {} MB/s'.format(table, round(rate, 2))) stdout.flush() if size > 0: stdout.write('\n')
def describe(self, args): opts = utils.CommandOptions(args) client = YamcsClient(**opts.client_kwargs) archive = client.get_archive(opts.instance) table = archive.get_table(args.table) print(table._proto) #pylint: disable=protected-access
event_count += rec.count print(f" {source: <40} {event_count: >20}") def print_command_count(): """Print the number of commands grouped by name.""" mdb = client.get_mdb(instance="simulator") for command in mdb.list_commands(): total = 0 for group in archive.list_command_histogram(command.qualified_name): for rec in group.records: total += rec.count print(f" {command.qualified_name: <40} {total: >20}") if __name__ == "__main__": client = YamcsClient("localhost:8090") archive = client.get_archive(instance="simulator") print("Packets:") print_packet_count() print("\nProcessed Parameter Groups:") print_pp_groups() print("\nEvents:") print_event_count() print("\nCommands:") print_command_count()
start = now - timedelta(days=2) # Results are returned in records per 'group'. # A completeness group matches with a CCSDS APID. # We may receive multiple groups with the same APID # depending on how much data there is for the selected # range. # Combine all returned pages by APID records_by_apid = {} for group in archive.list_completeness_index(start=start, stop=now): if group.name not in records_by_apid: records_by_apid[group.name] = [] records_by_apid[group.name].extend(group.records) for apid, records in records_by_apid.iteritems(): print('APID:', apid) total = 0 for rec in records: print(' -', rec) total += rec.count print(' --> Total packets for {}: {}'.format(apid, total)) if __name__ == '__main__': client = YamcsClient('localhost:8090') archive = client.get_archive(instance='simulator') print_latest()
from yamcs.client import YamcsClient if __name__ == "__main__": client = YamcsClient("localhost:8090") archive = client.get_archive("simulator") results = archive.execute_sql(""" select * from tm limit 2 """) for i, row in enumerate(results): if i == 0: print(results.columns) print(row)
# fmt: off from yamcs.client import YamcsClient if __name__ == '__main__': client = YamcsClient('localhost:8090') archive = client.get_archive('simulator') results = archive.execute_sql(''' select * from tm limit 2 ''') for i, row in enumerate(results): if i == 0: print(results.columns) print(row)