diff --git a/edosl0util/jpssrdr.py b/edosl0util/jpssrdr.py index 4062c741a1b9048fa709acbb6bb8fac8b8148b36..960131446706ea4ca108fdcf62f9ae15d859e1ae 100644 --- a/edosl0util/jpssrdr.py +++ b/edosl0util/jpssrdr.py @@ -9,9 +9,9 @@ Code for reading/writing/manipulating JPSS Common RDR files as documented in: """ __copyright__ = "Copyright (C) 2015 University of Wisconsin SSEC. All rights reserved." -import os -import logging import ctypes as c +import logging +import os from collections import namedtuple import numpy as np @@ -73,6 +73,7 @@ def _make_packet_impl(size): """ # size minus the CCSDS primary header size data_size = size - 6 + class PktImpl(BaseStruct): # noqa _fields_ = [ ('version', c.c_uint8, 3), @@ -84,6 +85,7 @@ def _make_packet_impl(size): ('length_minus1', c.c_uint16), ('data', c.c_uint8 * data_size) ] + return PktImpl @@ -272,8 +274,8 @@ def write_rdr_datasets(filepath, ancillary=False, skipfill=False): for apid, pkts in packets.items(): LOG.debug( 'writing ancillary gran %d %s-%s-%s %d', - idx, rdr.header.satellite, rdr.header.sensor, - rdr.header.type_id, apid) + idx, rdr.header.satellite.decode(), rdr.header.sensor.decode(), + rdr.header.type_id.decode(), apid) pktfile = '{}.{}{}.pkts'.format(rdrname, typekey, apid) with open(pktfile, 'ab') as dest: _write_packets(pkts, dest, skipfill) @@ -284,6 +286,7 @@ def write_rdr_datasets(filepath, ancillary=False, skipfill=False): for idx, rdr in enumerate(rdrs[typekey]): LOG.debug( '... %s gran %d %s-%s-%s', typekey, - idx, rdr.header.satellite, rdr.header.sensor, rdr.header.type_id) + idx, rdr.header.satellite.decode(), rdr.header.sensor.decode(), + rdr.header.type_id.decode()) _write_packets(rdr.packets(), dest, skipfill) return rdrs diff --git a/tests/test_merge.py b/tests/test_merge.py index 572daed9ecc91854780c204764de99a62eb47231..d4e54c1220be06293b3ea0c165dd0eac8dde17ac 100644 --- a/tests/test_merge.py +++ b/tests/test_merge.py @@ -3,7 +3,7 @@ from operator import eq, lt, gt import pytest -from edosl0util import merge, headers +from edosl0util import merge class Test_Ptr: diff --git a/tests/test_rdrgen.py b/tests/test_rdrgen.py index 2fee2b70f654c0fd5a42b2ad20edd329a89dccad..231449aa5dab2fb7fea1c4008d99641857cfbcda 100644 --- a/tests/test_rdrgen.py +++ b/tests/test_rdrgen.py @@ -114,7 +114,8 @@ def test_can_reproduce_rdr_from_class(): ['h5diff', '-c', '-p', '1e-6', class_rdr_path, os.path.join(tmp_dir, writer.file_name)], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - assert p.communicate()[0] == '' + stdout, _ = p.communicate() + assert stdout.decode() == '' assert p.returncode == 0