Loading autocnet/fileio/io_controlnetwork.py +23 −17 Original line number Diff line number Diff line Loading @@ -82,7 +82,8 @@ def to_isis(path, C, mode='w', version=VERSION, store.write(header) import os print(os.path.abspath(path)) class IsisStore(object): """ Class to manage IO of an ISIS3 control network (version 2). Loading Loading @@ -261,12 +262,13 @@ class IsisStore(object): points_start_byte = HEADERSTARTBYTE + buffer_header_size header = pvl.PVLModule([ ('Protobuffer', {'Core':{'HeaderStartByte':headerstartbyte, ('ProtoBuffer', ({'Core':{'HeaderStartByte': headerstartbyte, 'HeaderBytes': header_bytes, 'PointsStartByte': points_start_byte, 'PointsBytes':points_bytes}}), ('ControlNetworkInfo',pvl.PVLGroup([ 'PointsBytes': points_bytes}, 'ControlNetworkInfo': pvl.PVLGroup([ ('NetworkId', networkid), ('TargetName', targetname), ('UserName', username), Loading @@ -276,8 +278,12 @@ class IsisStore(object): ('NumberOfPoints', cnet.n), ('NumberOfMeasures', cnet.m), ('Version', version) ])) ]) }), ) ]) return pvl.dumps(header, cls=encoder) def __enter__(self): Loading autocnet/fileio/tests/test_io_controlnetwork.py +4 −6 Original line number Diff line number Diff line import os from time import gmtime, strftime import unittest from unittest.mock import MagicMock import sys sys.path.insert(0, os.path.abspath('..')) Loading Loading @@ -36,7 +35,7 @@ class TestWriteIsisControlNetwork(unittest.TestCase): self.creation_time = strftime("%Y-%m-%d %H:%M:%S", gmtime()) cnet = C(data, index=multi_index, columns=columns) io_controlnetwork.to_isis('test.net', cnet, mode='wb') io_controlnetwork.to_isis('test.net', cnet, mode='wb', targetname='Moon') self.header_message_size = 83 self.point_start_byte = 65619 Loading @@ -50,7 +49,7 @@ class TestWriteIsisControlNetwork(unittest.TestCase): #Non-repeating self.assertEqual('None', header_protocol.networkId) self.assertEqual('None', header_protocol.targetName) self.assertEqual('Moon', header_protocol.targetName) self.assertEqual(io_controlnetwork.DEFAULTUSERNAME, header_protocol.userName) self.assertEqual(self.creation_time, Loading Loading @@ -91,7 +90,6 @@ class TestWriteIsisControlNetwork(unittest.TestCase): points_start_byte = find_in_dict(pvl_header, 'PointsStartByte') self.assertEqual(65619, points_start_byte) def tearDown(self): os.remove('test.net') No newline at end of file return #os.remove('test.net') No newline at end of file Loading
autocnet/fileio/io_controlnetwork.py +23 −17 Original line number Diff line number Diff line Loading @@ -82,7 +82,8 @@ def to_isis(path, C, mode='w', version=VERSION, store.write(header) import os print(os.path.abspath(path)) class IsisStore(object): """ Class to manage IO of an ISIS3 control network (version 2). Loading Loading @@ -261,12 +262,13 @@ class IsisStore(object): points_start_byte = HEADERSTARTBYTE + buffer_header_size header = pvl.PVLModule([ ('Protobuffer', {'Core':{'HeaderStartByte':headerstartbyte, ('ProtoBuffer', ({'Core':{'HeaderStartByte': headerstartbyte, 'HeaderBytes': header_bytes, 'PointsStartByte': points_start_byte, 'PointsBytes':points_bytes}}), ('ControlNetworkInfo',pvl.PVLGroup([ 'PointsBytes': points_bytes}, 'ControlNetworkInfo': pvl.PVLGroup([ ('NetworkId', networkid), ('TargetName', targetname), ('UserName', username), Loading @@ -276,8 +278,12 @@ class IsisStore(object): ('NumberOfPoints', cnet.n), ('NumberOfMeasures', cnet.m), ('Version', version) ])) ]) }), ) ]) return pvl.dumps(header, cls=encoder) def __enter__(self): Loading
autocnet/fileio/tests/test_io_controlnetwork.py +4 −6 Original line number Diff line number Diff line import os from time import gmtime, strftime import unittest from unittest.mock import MagicMock import sys sys.path.insert(0, os.path.abspath('..')) Loading Loading @@ -36,7 +35,7 @@ class TestWriteIsisControlNetwork(unittest.TestCase): self.creation_time = strftime("%Y-%m-%d %H:%M:%S", gmtime()) cnet = C(data, index=multi_index, columns=columns) io_controlnetwork.to_isis('test.net', cnet, mode='wb') io_controlnetwork.to_isis('test.net', cnet, mode='wb', targetname='Moon') self.header_message_size = 83 self.point_start_byte = 65619 Loading @@ -50,7 +49,7 @@ class TestWriteIsisControlNetwork(unittest.TestCase): #Non-repeating self.assertEqual('None', header_protocol.networkId) self.assertEqual('None', header_protocol.targetName) self.assertEqual('Moon', header_protocol.targetName) self.assertEqual(io_controlnetwork.DEFAULTUSERNAME, header_protocol.userName) self.assertEqual(self.creation_time, Loading Loading @@ -91,7 +90,6 @@ class TestWriteIsisControlNetwork(unittest.TestCase): points_start_byte = find_in_dict(pvl_header, 'PointsStartByte') self.assertEqual(65619, points_start_byte) def tearDown(self): os.remove('test.net') No newline at end of file return #os.remove('test.net') No newline at end of file