saleae / logic2-automation

Logic2 Automation API
https://saleae.github.io/logic2-automation/
Apache License 2.0
19 stars 8 forks source link

export functions should accept pathlib.Path as a parameter #16

Open Yinameah opened 1 year ago

Yinameah commented 1 year ago

Hello,

First, congrats for this new automation library, I've been looking at it for quite some times, and now I'have had the opportunity to play a bit with, and it's really cool.

I have a minor issue (more of an inconvenience, really).

I think capture.savecapture(), capture.export.....() functions should accept pathlib.Path object as parameter, since it is part of the standard library.

my_path = pathlib.Path(os.getcwd()).parent.absolute() # handy
capture = manager.start_capture( ..... )
capture.wait()
capture.save_capture(my_path)

This gives a TypeError: bad argument type for built-in operation (which by the way is not the most clear error ever. . .)

Obviously, the fix could be straightforward :

    def save_capture(self, filepath: str|pathlib.Path):
        """
        Saves the capture to a .sal file, which can be loaded later either through the UI or with the load_capture() function.

        :param filepath: path to the .sal file. Can be absolute, or relative to the Logic 2 software current working directory.
        """
        request = saleae_pb2.SaveCaptureRequest(
            capture_id=self.capture_id, filepath=str(filepath)
        )

Best regards.

timreyes commented 1 year ago

Thanks for the feedback and for providing a snippet of the fix! We'll have this reviewed by the software team here.