ppannuto / python-saleae

Python library to control a Saleae Logic Analyzer
Apache License 2.0
124 stars 55 forks source link

Path manipulation doesn't work when Logic is running on different OS than the Python module #62

Open mitbrooks opened 4 years ago

mitbrooks commented 4 years ago

Logic analyser running on a windows machine, From a linux machine:

import saleae
la = saleae.Saleae("hostname")
la.save_to_file('c:/test_file.logicdata')
la.load_from_file('c:/test_file.logicdata')

doesn't work. The same does work on a windows machine. I believe this is because in linux, os.path.abspath('c:/test_file.logicdata') returns /current/linux/working/directory/C:/test_file.logicdata

Would using os.path.normpath() work better here?

ppannuto commented 4 years ago

Not quite like that unfortunately. normpath alone is insufficient, it would need to be basically what's suggested in the python docs of normpath(join(os.getcwd(), path)).

The deeper problem here is that Logic doesn't support relative paths, so we have to convert to an absolute path. The rules for path manipulation will come from the os module where the Python script is running. If Logic is running on a different operating system, this module would have to be told that somehow (I don't believe there is a is an absolute path on any operating system function we can call).