Go to the documentation of this file. 1 """Main method of the module.
3 This is called with `python -m ccsdspy`
6 __author__ =
"Daniel da Silva <mail@danieldasilva.org>"
12 from .utils
import split_by_apid
16 """Main method of the module, run with `python -m ccsdspy [..]"""
18 parser = argparse.ArgumentParser()
20 subparser = parser.add_subparsers(dest=
"command")
21 split_parser = subparser.add_parser(
24 "Subcommand to run. Currently only split is supported. Use "
25 "split to split mixed APID stream and write files to the "
29 split_parser.add_argument(
"file")
30 split_parser.add_argument(
"--valid-apids", help=
"Valid APIDs seperated by comma")
32 args = parser.parse_args(argv[1:])
36 if args.command ==
"split":
38 toks = args.valid_apids.split(
",")
39 valid_apids = [
int(apid)
for apid
in toks]
43 stream_by_apid =
split_by_apid(args.file, valid_apids=valid_apids)
45 print(
"Parsing done!")
47 for apid
in sorted(stream_by_apid):
48 if valid_apids
and apid
not in valid_apids:
51 out_file_name = f
"{cwd}/apid{apid:05d}.tlm"
52 print(f
"Writing {out_file_name}")
54 with open(out_file_name,
"wb")
as file_out:
55 file_out.write(stream_by_apid[apid].read())
58 if __name__ ==
"__main__":
def split_by_apid(mixed_file, valid_apids=None)
void print(std::ostream &stream, const char *format)
def module_main(argv=sys.argv, cwd=os.getcwd())