- Posts: 6
- Thank you received: 0
Relative path in Python HAL file
6 years 7 months ago #159533
by meloon
Relative path in Python HAL file was created 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.
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.
6 years 7 months ago #159544
by andypugh
Replied by andypugh on topic Relative path in Python HAL file
A relative path from the location of the INI file ought to work. Have you tried that?
Please Log in to join the conversation.
6 years 7 months ago #159547
by cmorley
Replied by cmorley on topic Relative path in Python HAL file
reference from the python file to the image directory :
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:
To see if the working directory is what you think.
Chris
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
