Post Reply 
How to specify full directory path in Python
08-03-2021, 12:56 AM
Post: #1
How to specify full directory path in Python
Whenever I run something like

Code:
import uio

with uio.open('/Python.hpappdir/main.py', 'r') as mainPy:
    pass

it gives me OSError: 0, which from my experience translates to "file not found"

I was wondering how I am supposed to format a directory on the Prime.
Find all posts by this user
Quote this message in a reply
08-03-2021, 03:22 AM (This post was last modified: 08-03-2021 03:26 AM by Dougggg.)
Post: #2
RE: How to specify full directory path in Python
Reading from the file section of the python app I was able to use

with open("test.txt",'r',encoding = 'utf-8') as f:

and

with open("test.txt",'w',encoding = 'utf-8') as f:

wrote the file to the file section of the app

looks like the main.py is stored there to some maybe if you add "Files" to the path
Find all posts by this user
Quote this message in a reply
08-03-2021, 11:31 AM
Post: #3
RE: How to specify full directory path in Python
What if I want to open files from different apps, or if I want to access file in the root directory, like cas.hpesettings, or any of the PPL programs? How to I format the path for stuff like that?
Find all posts by this user
Quote this message in a reply
08-03-2021, 12:16 PM (This post was last modified: 08-03-2021 12:17 PM by Tim Wessman.)
Post: #4
RE: How to specify full directory path in Python
I was not involved with this part, but I am quite certain that the "root" directory for the python code will be considered to be inside the app... security concerns and stability being the primary drivers I would assume. Probably cannot access without some sort of path traversal bug.

TW

Although I work for HP, the views and opinions I post here are my own.
Find all posts by this user
Quote this message in a reply
08-22-2021, 04:49 PM
Post: #5
RE: How to specify full directory path in Python
Is it possible to access files from other apps using sys.path?
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)