Relative path in Python HAL file

More
6 years 7 months ago #159533 by meloon
I was trying to use the relative path in python hal file.

CONTEXT:
We have a parent directory called `python` and it contains one python HAL file and one directory named `img`.

The directory tree structure is as follows:
/python
-python_hal
-img

I was trying to reference the img directory in the python hal file by doing either `./img` or `img`, but it doesn't seem to work. Does anyone know how to use the proper relative path in the python hal file? Currently, I'm using absolute path and that works fine. But I would prefer using the relative path.

Please Log in to join the conversation.

More
6 years 7 months ago #159544 by andypugh
A relative path from the location of the INI file ought to work. Have you tried that?

Please Log in to join the conversation.

More
6 years 7 months ago #159547 by cmorley
reference from the python file to the image directory :
Code:
path = 'image/SOME_IMAGE'

But Andy is on the right track - it depends on where the original program is run from.
You didn't give much context about the python program as it relates to linuxcnc.
try adding:
Code:
print os.getcwd()

To see if the working directory is what you think.

Chris

Please Log in to join the conversation.

Time to create page: 0.139 seconds
Powered by Kunena Forum