-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Getting the path of the currently running script #194
Comments
Hi the script is read into memory and executed so it does not have any connection the file when executed. I think the default path is the lib path or similar. I haven't touch the python bits in years I'm afraid. |
thanks for your answer! I checked the path and it seems like it's only reading from the pylib folder |
Problem is its the UI that loads the file and sends it off to the backend for exection. Needs some refactor for it to work. I might have time eventually, but if you want it done now you can branch freepie ;) |
If someone want a crack at this here is the place were the paths are beign loaded into the python egine
|
thanks @AndersMalmgren ! that seems simple enough. I'll try and see if I can do this one |
I'm using a fairly complex script across several modules and I solved this by creating a windows symlink in the FreePIE/pylib directory that points to the root of my own modules dir under my Documents. You'll also have trouble with file and line number errors which I work around by testing first under regular Windows Python to catch any syntax errors. (I check if You'll also notice that none of the special FreePIE globals are available in modules. I wrap them in a class object I call Also any "indexer" functions (filters) won't work inside a module. Easiest thing is to just not use them. They are easily implemented as dedicated variables/functions in your module's class and will be a bit faster too since they won't require a textual hash lookup, and it will also work with regular python. |
Maybe we should add a way to add extra paths using command line or config |
thanks @cjroehrig ! That's a really good idea! I never thought of linking the directory itself, just files before I have just sent a pull request related to this but it just adds the directory of the currently running file |
That would be nice, but I think it should also include an update to error handling so that the syntax/runtime errors can report the file and line number. I had a go at a patch a couple years ago but I don't think I ever got it working. The filename doesn't seem to be readily accessible in the IronPython Exception which looks to be designed around streams. Needs more digging... |
Hi! I have been a long time user and FreePIE and find it a really good program!
I have a script that is more complicated than usual and would like to separate it into a different library. At the moment, I'm doing this to be able to import libraries located in the FreePIE folder inside my home directory:
sys.path.append(os.path.expandvars(r'%USERPROFILE%\FreePIE'))
I would like instead to be able to replace the hardcoded directory to read from the same directory the currently executing script is located. I tried to use the
__file__
python variable but it seems to not have what I expected. Is there any way to do this? Thanks!The text was updated successfully, but these errors were encountered: