Uhrm, shouldn’t that be more something along the lines of:
APP_files=sys.argv[1].split('::::').strip('"')
Small typo?
Uhrm, shouldn’t that be more something along the lines of:
APP_files=sys.argv[1].split('::::').strip('"')
Small typo?
actually APP_files=sys.argv[1].strip(’"’).split(’::::’) would make sense, if it’s only 1 file (where the split would not be used)
but APP_files=sys.argv[1].split(’::::’).strip(’"’) does not work, because a list cant be stripped.
maybe some re is what we need?
or:
APP_files=sys.argv[1].strip('"').split('"::::"')
but this needs to be checked for platform type (as it seems to differ for osx & windows and maybe linux).
Don’t worry about it, guys. It’s not a problem at all.
I don’t think there is any OS allows these characters to be part of a filename : "*?/:<>|
Those paths are definitely free of quotes. The quotes serve only to pack the ::::-concat’ed paths, here in IDE_STARTER.startIDE :
the_files='"%s"'%'::::'.join(files)
It’s only to asure that all paths, which may contain whitespaces are properly packed as a single argument to python. If I leave this string passed over as is, it would be split to be some arguments :
/I am/pathTo/file 1.py::::/I am/pathTo/file 2.py::::/I am/pathTo/file 3.py
The quotes are just a packer :
“/I am/pathTo/file 1.py::::/I am/pathTo/file 2.py::::/I am/pathTo/file 3.py”
So, to extract the paths, first I have to strip those quotes, then split the result by ::::. I’ve tried that both on Windows and Linux, nothing is wrong. I don’t know about OS X’s packer though, I think quotes (both single and double) are universal.
If you guys want to worry, there is 1 more bad news
[x] on Windows, wx can store & retrieve clipboard text content without any problem, though I have to close it using Flush() to actually store it, so it’s available to the OS, since Close() doesn’t seem enough. Unfortunately, not even Flush() work on Linux, I don’t know why.
I thought that all those problems were caused by my a little dirty build. I have just done a clean build, but it still behaves the same. There must be something wrong somewhere else…
It could be me being so new to Linux…
[+] I’ve fixed the cross platforms EOL-delimiter. File loading now uses universal newline character read mode : ‘rU’.
For copy paste functions for most platforms you may want to check this functionality in the panda3d-interactive-console i wrote. It’s currently not downloadable, as my server went down, i’ll try to remember to upload it again soon (it’s too late for today).
I already have your old code lying around somewhere.
I’ve read this before, and finally tried it :
discourse.panda3d.org/viewtopic.php?t=2397
That solves the clipboard problem, but there are still a lot of critical warnings when spawning a dialog in separate thread. Sometimes, it even segfault. I’ll play around with it further.
Hypnos, did you mean to tell me that panda_function_lib_dir and currect_project_dir are at the same level ?
I tried it by copying /actor from P3D/direct/src to the parent directory of the test scene’s dir, and import it :
from actor import Actor # /actor is copied from P3D/direct/src
Python can’t find it unless I added the parent dir to the path (in the main test file) :
sys.path.append(os.pardir)
So, normally how do you do it ?
If you added the parent dir yourself, then it will always be found, no matter what the IDE is doing.
UPDATE :
Traceback (most recent call last):
File "IDE.py", line 3027, in IDE_safeRun
taskMgr.run()
File "linuxroot/usr/share/panda3d/direct/src/task/Task.py", line 939, in run
File "linuxroot/usr/share/panda3d/direct/src/task/Task.py", line 877, in step
File "linuxroot/usr/share/panda3d/direct/src/task/Task.py", line 776, in __stepThroughList
File "linuxroot/usr/share/panda3d/direct/src/task/Task.py", line 696, in __executeTask
TypeError: changeColor() takes exactly 1 argument (2 given)
i.e. due to incorrect arguments count.
The IDE now can locate the exact error position, unless you change the method and/or the class’ name, before it actually run.
Shots of it, see the difference if I change self.changeColor to changeColor ?
funny news :
How could Python spit Windows path on Linux ?
Look at the last path :
Traceback (most recent call last):
File "IDE.py", line 3018, in IDE_safeRun
taskMgr.run()
File "linuxroot/usr/share/panda3d/direct/src/task/Task.py", line 939, in run
File "linuxroot/usr/share/panda3d/direct/src/task/Task.py", line 877, in step
File "linuxroot/usr/share/panda3d/direct/src/task/Task.py", line 776, in __stepThroughList
File "linuxroot/usr/share/panda3d/direct/src/task/Task.py", line 696, in __executeTask
File "I:\PROGRAMMING\Panda3D\=coba IDE\jackClass.py", line 21, in changeColor
NameError: global name 'Task' is not defined
I’ve covered that too.
Yes
i have actually never tried to call a python class by spawn or exec using this structure. i would call the main.py script like this:
python currect_project_dir/main.py
so the root directory of this example would have to be in the pythonpath
So, how do you make this import work :
from panda_function_lib_dir import file1
Python doesn’t automatically walk up if you don’t tell it to. So, I think it’s your responsibility.
This is the way I tried it in dyn1.py :
import os
sys.path.append(os.pardir)
os.chdir(os.path.dirname(sys.argv[0]))
from actor import Actor
print Actor
IDE.py :
IDE_path=os.getcwd()
IDE_lastBrowsePath=os.path.dirname(APP_mainFile)
sys.path.insert(0,IDE_lastBrowsePath)
sys.argv[0]=APP_mainFile
Using “python /path/to/dyn1.py” command or started from the IDE work.
Both return <module ‘actor.Actor’ from ‘…/actor/Actor.pyc’>
i just think a workig directory might not be to bad. This not only affects the python imports, but also the panda3d path, where ‘.’ (the working/current directory) is usually in the config file.
to be sure we mean the same, i have put together a example which shows the structure:
http://www.nouser.org/~rspoerri/example.zip
if you dont want to do it, im fine It’s already great that you make this ide available.
Not sure, are you applying this to the way the ide is started?
I thought about defining a working directory for the script that is loaded, not the ide.
btw: i just tested the new version on osx, loading, selecting files, starting up works fine now, except line 16, which i needed to comment out.
os.chdir( os.path.dirname(sys.argv[0]) )
edit:
and one suggection, adding a log-output-window would be great (redirect sys.stdout and sys.stderr to some tab)
I tried your sample. It doesn’t work, right ?
ImportError: No module named lib.test
To make it work :
import os,sys
sys.path.append(os.pardir)
#________________________________
from lib.test import testClass
test = testClass()
test.echo()
And … I just saw the real problem. It’s simply due to my IDE’s dir and the test files’ dir were at the same level. Once I moved the IDE’s dir a bit deeper, I saw it, I saw it
Sorry, too late to realize that.
Alright then, just uncomment IDE.py line 94 :
os.chdir(IDE_lastBrowsePath)
Don’t tell me it’s not what you want
And what’s wrong with this :
os.chdir( os.path.dirname(sys.argv[0]) )
sys.argv[0] is IDE_STARTER.pyw path, how could it go wrong ?
Does it return something else on OS X ?
i actually thought of another selection you could make if you load a file.
like i want to load the file:
/home/rspoerri/project/src/main.py
but i want the working directory
/home/rspoerri/project/
Just make a list of the directories above the file to be loaded.
list would be:
/home/rspoerri/project/src/
/home/rspoerri/project/
/home/rspoerri/
/home/
then you can select one of these paths as working directory.
i actually dont like the fact that the ide must be in the same directory like the code i work on.
like this ?
ynjh.tk/P3D/OIDE/OnscreenIDEdynamic.zip
i havent got the time to check if it works correctly right now, but it does look like i wanted
I hope you also think the change was worth it. Thanks a lot
Of course. I believe there are a lot of unrevealed cases based on how we do things differently.
I have checked the sys.argv[0] error i mentioned a few posts earlier.
if i start IDE_STARTER.pyw from it’s own directory, sys.argv[0] is ‘IDE_STARTER.pyw’. If i start it from a directoy above it sys.argv[0] is ‘OnscreenIDEdynamic_Folder/IDE_STARTER.pyw’.
os.path.dirname( 'IDE_STARTER.pyw' )
-> '' (empty string)
os.path.dirname('OnscreenIDEdynamic_Folder/IDE_STARTER.pyw')
-> 'OnscreenIDEdynamic_Folder'
os.chdir does not work with a empty string.
try:
os.chdir( os.path.dirname(sys.argv[0]) )
except:
pass
should work afaik.
Yes, that’s one difference between you and me. I always supply absolute path to Python, while you like relative path.
No problem, actually there is a simple 1 line solution for both of us
Just need to combine the cwd and argv[0] :
absPath=os.path.dirname( joinPaths(os.getcwd(),sys.argv[0]) )
joinPaths is os.path.join
or simply sys.path[0], which is the absolute path to the script, set by Python by default.
UPDATE :
UPDATE :
UPDATE :