hi,
i’m trying to detect how the application is run.
run from python
p3d run locally
p3d run from webhost
because of a error i am experiencing when the application is run in the webhost (loading a non exisiting prc file seems to block it forever). also i’d need to get this information before directstart is called.
is there a way to figure this out? i’ve already looked into the apprunnner code, but i didnt find a function that gives me this information.
i am trying to load a prc file before directstart. this does not make sense for a p3d-web-application, but i want the same p3d file to be able to run directly, being configurable trough a config.prc in the same directory as the p3d file.
print "import"
from panda3d.core import *
print "load"
loadPrcFile('test.prc')
print "start"
from direct.directbase import DirectStart
print "done"
only prints to the log, when the test.prc does not exist:
import
load
(the javascript access also doesnt work well for me, as described in the other thread)
import
load
:util(error): Unable to open test.prc
start
DirectStart: Starting the game.
Maybe it’s a problem that’s been recently fixed? I am using my own build, not the official release, which lags behind a bit. I can try it again with the official release.
Though note that this won’t necessarily work anyway–the “current directory” is changed when running a p3d file to be the directory ~/Library/Caches/Panda3D/start, not the same directory that held the p3d file. This is intended to make the runtime environment more predictable. (You can add the -c keep_user_env=1 flag to keep the current directory the same as it was when the user launched the p3d file, which will probably be the user’s home directory. Or you can allow the user to specify the location of the prc file on the command line.)
i know that the working dir’s are changed. this is the reason i needed to figure out what way the p3d is called.
this is the current code i have to get the folder names.
import sys, os
from direct.showbase import AppRunnerGlobal
if AppRunnerGlobal.appRunner is None:
RUNTYPE = 'python'
else:
print "dom", AppRunnerGlobal.appRunner.dom
if AppRunnerGlobal.appRunner.dom:
RUNTYPE = 'website'
else:
RUNTYPE = 'local'
# location of the main.py
mainLocation = None
# location where the p3d resides if it is run from a p3d file (url or path)
p3dLocation = None
if RUNTYPE in ['python']:
mainLocation = '%s/' % os.path.dirname(sys.argv[0])
if RUNTYPE in ['local']:
mainLocation = '/mf/'
p3dLocation = '%s/' % os.path.dirname(sys.argv[0])
print "location", AppRunnerGlobal.appRunner.dom.location
if RUNTYPE in ['website']:
mainLocation = '/mf/'
p3dLocation = AppRunnerGlobal.appRunner.dom.location.href