예제 #1
0
def main():
    """The transcoder"""

    with can.LogReader(sys.argv[1]) as reader:
        with can.Logger(sys.argv[2]) as writer:

            for msg in reader:  # pylint: disable=not-an-iterable
                writer.on_message_received(msg)
예제 #2
0
def main():
    """The transcoder"""

    with can.LogReader(sys.argv[1]) as reader:
        with can.Logger(sys.argv[2]) as writer:

            for msg in reader:
                writer.on_message_received(msg)
        def test_filetype_to_instance(extension, klass):
            print("testing: {}".format(extension))
            try:
                if extension == ".blf":
                    delete = False
                    file_handler = open(join(dirname(__file__), "data/logfile.blf"))
                else:
                    delete = True
                    file_handler = tempfile.NamedTemporaryFile(suffix=extension, delete=False)

                with file_handler as my_file:
                    filename = my_file.name
                with can.LogReader(filename) as reader:
                    self.assertIsInstance(reader, klass)
            finally:
                if delete:
                    os.remove(filename)
예제 #4
0
 def test_extension_matching(self):
     for suffix, (writer,
                  reader) in self.message_writers_and_readers.items():
         suffix_variants = [
             suffix.upper(),
             suffix.lower(),
             "".join(
                 [c.upper() if i % 2 else c for i, c in enumerate(suffix)]),
         ]
         for suffix_variant in suffix_variants:
             tmp_file = tempfile.NamedTemporaryFile(suffix=suffix_variant,
                                                    delete=False)
             tmp_file.close()
             try:
                 with can.Logger(tmp_file.name) as logger:
                     assert type(logger) == writer
                 if reader is not None:
                     with can.LogReader(tmp_file.name) as player:
                         assert type(player) == reader
             finally:
                 os.remove(tmp_file.name)
예제 #5
0
 def testPlayerTypeResolutionUnsupportedFileTypes(self):
     for should_fail_with in ["", ".", ".some_unknown_extention_42"]:
         with self.assertRaises(ValueError):
             with can.LogReader(
                     should_fail_with):  # make sure we close it anyways
                 pass
예제 #6
0
 def test_filetype_to_instance(extension, klass):
     can_player = can.LogReader("test.{}".format(extension))
     self.assertIsInstance(can_player, klass)
     if hasattr(can_player, "stop"):
         can_player.stop()