Relative path in Python HAL file
- meloon
- Topic Author
- Offline
- New Member
Less
More
- Posts: 6
- Thank you received: 0
08 Mar 2020 23:54 #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 or Create an account to join the conversation.
- andypugh
- Offline
- Moderator
Less
More
- Posts: 23178
- Thank you received: 4861
09 Mar 2020 00:44 #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 or Create an account to join the conversation.
- cmorley
- Offline
- Moderator
Less
More
- Posts: 7780
- Thank you received: 2075
09 Mar 2020 01:35 #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
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:
print os.getcwd()
To see if the working directory is what you think.
Chris
Please Log in or Create an account to join the conversation.
Time to create page: 0.096 seconds