Panda3D
Loading...
Searching...
No Matches
AppRunner Class Reference
Inheritance diagram for AppRunner:
DirectObject

Public Member Functions

 __init__ (self)
 
 addPackageInfo (self, name, platform, version, hostUrl, hostDir=None, recurse=False)
 
 checkDiskUsage (self)
 
 deletePackages (self, packages)
 
 dropObject (self, objectId)
 
 evalScript (self, expression, needsResponse=False)
 
 freshenFile (self, host, fileSpec, localPathname)
 
 getHost (self, hostUrl, hostDir=None)
 
 getHostWithAlt (self, hostUrl)
 
 getHostWithDir (self, hostDir)
 
 getPandaScriptObject (self)
 
 getToken (self, tokenName)
 
 getTokenBool (self, tokenName)
 
 getTokenFloat (self, tokenName)
 
 getTokenInt (self, tokenName)
 
 initPackedAppEnvironment (self)
 
 installPackage (self, packageName, version=None, hostUrl=None)
 
 loadMultifilePrcFiles (self, mf, root)
 
 notifyRequest (self, message)
 
 readConfigXml (self)
 
 rmtree (self, filename)
 
 run (self)
 
 scanInstalledPackages (self)
 
 scriptRequest (self, operation, object, propertyName='', value=None, needsResponse=True)
 
 sendRequest (self, request, *args)
 
 setBrowserScriptObject (self, dom)
 
 setInstanceInfo (self, rootDir, logDirectory, superMirrorUrl, verifyContents, main, respectPerPlatform)
 
 setP3DFilename (self, p3dFilename, tokens, argv, instanceId, interactiveConsole, p3dOffset=0, p3dUrl=None)
 
 setRequestFunc (self, func)
 
 setSessionId (self, sessionId)
 
 setupWindow (self, windowType, x, y, width, height, parent)
 
 stop (self)
 
 writeConfigXml (self)
 
- Public Member Functions inherited from DirectObject
 __init__ (self)
 
 accept (self, event, method, extraArgs=[])
 
 acceptOnce (self, event, method, extraArgs=[])
 
 addTask (self, *args, **kwargs)
 
 detectLeaks (self)
 
 doMethodLater (self, *args, **kwargs)
 
 getAllAccepting (self)
 
 ignore (self, event)
 
 ignoreAll (self)
 
 isAccepting (self, event)
 
 isIgnoring (self, event)
 
 removeAllTasks (self)
 
 removeTask (self, taskOrName)
 

Public Attributes

bool allowPythonDev = False
 
dict altHost = None
 
dict altHostMap = {}
 
 argv = argv
 
 ConcreteStruct = ConcreteStruct
 
list deferredEvals = []
 
 dom = None
 
list downloadingPackages = []
 
 downloadTask = None
 
bool dummy = False
 
 exceptionHandler = None
 
bool gotP3DFilename = False
 
bool gotWindow = False
 
bool guiApp = False
 
dict hosts = {}
 
 http = None
 
bool initialAppImport = False
 
list installedPackages = []
 
 instanceId = None
 
bool interactiveConsole = False
 
 logDirectory = None
 
 main = ScriptAttributes()
 
 multifileRoot = str(ExecutionEnvironment.getCwd())
 
int nextScriptId = 0
 
 p3dConfig = None
 
 p3dFilename = None
 
 p3dInfo = None
 
 p3dMultifile = mf
 
 p3dPackage = 'main'
 
 p3dUrl = None
 
bool packedAppEnvironmentInitialized = False
 
 pandaHostUrl = PandaSystem.getPackageHostUrl()
 
 requestFunc = defaultRequestFunc
 
 respectPerPlatform = None
 
 rootDir = None
 
int sessionId = 0
 
bool started = False
 
 superMirrorUrl = None
 
dict tokenDict = {}
 
 tokens = tokens
 
bool trueFileIO = False
 
 Undefined = Undefined
 
int verifyContents = self.P3DVCNone
 
bool windowOpened = False
 
 windowPrc = None
 
 windowProperties = None
 

Static Public Attributes

str ConfigBasename = 'config.xml'
 
int maxDiskUsage = 2048 * 1048576
 
 notify = directNotify.newCategory("AppRunner")
 
int P3D_CONTENTS_DEFAULT_MAX_AGE = 5
 
int P3DVCForce = 2
 
int P3DVCNever = 3
 
int P3DVCNone = 0
 
int P3DVCNormal = 1
 
- Static Public Attributes inherited from DirectObject
 accept_once = acceptOnce
 
 add_task = addTask
 
 detect_leaks = detectLeaks
 
 do_method_later = doMethodLater
 
 get_all_accepting = getAllAccepting
 
 ignore_all = ignoreAll
 
 is_accepting = isAccepting
 
 is_ignoring = isIgnoring
 
 remove_all_tasks = removeAllTasks
 
 remove_task = removeTask
 

Additional Inherited Members

- Protected Member Functions inherited from DirectObject
 _addTask (self, task)
 
 _clearTask (self, task)
 
- Protected Attributes inherited from DirectObject
dict _taskList = {}
 

Detailed Description

 This class is intended to be compiled into the Panda3D runtime
distributable, to execute a packaged p3d application.  It also
provides some useful runtime services while running in that
packaged environment.

It does not usually exist while running Python directly, but you
can use dummyAppRunner() to create one at startup for testing or
development purposes.  

Constructor & Destructor Documentation

◆ __init__()

__init__ ( self)

Member Function Documentation

◆ addPackageInfo()

addPackageInfo ( self,
name,
platform,
version,
hostUrl,
hostDir = None,
recurse = False )
 Called by the browser for each one of the "required"
packages that were preloaded before starting the application.
If for some reason the package isn't already downloaded, this
will download it on the spot.  Raises OSError on failure. 

◆ checkDiskUsage()

checkDiskUsage ( self)
 Checks the total disk space used by all packages, and
removes old packages if necessary. 

◆ deletePackages()

deletePackages ( self,
packages )
 Removes all of the indicated packages from the disk,
uninstalling them and deleting all of their files.  The
packages parameter must be a list of one or more PackageInfo
objects, for instance as returned by getHost().getPackage().
Returns the list of packages that were NOT found. 

◆ dropObject()

dropObject ( self,
objectId )
 Inform the parent process that we no longer have an
interest in the P3D_object corresponding to the indicated
objectId.  Not intended to be called by user code. 

◆ evalScript()

evalScript ( self,
expression,
needsResponse = False )
 Evaluates an arbitrary JavaScript expression in the global
DOM space.  This may be deferred if necessary if needsResponse
is False and self.dom has not yet been assigned.  If
needsResponse is true, this waits for the value and returns
it, which means it cannot be deferred. 

◆ freshenFile()

freshenFile ( self,
host,
fileSpec,
localPathname )
 Ensures that the localPathname is the most current version
of the file defined by fileSpec, as offered by host.  If not,
it downloads a new version on-the-spot.  Returns true on
success, false on failure. 

◆ getHost()

getHost ( self,
hostUrl,
hostDir = None )
 Returns a new HostInfo object corresponding to the
indicated host URL.  If we have already seen this URL
previously, returns the same object.

This returns the literal referenced host.  To return the
mapped host, which is the one we should actually download
from, see getHostWithAlt().  

◆ getHostWithAlt()

getHostWithAlt ( self,
hostUrl )
 Returns a suitable HostInfo object for downloading
contents from the indicated URL.  This is almost always the
same thing as getHost(), except in the rare case when we have
an alt_host specified in the HTML tokens; in this case, we may
actually want to download the contents from a different URL
than the one given, for instance to download a version in
testing. 

◆ getHostWithDir()

getHostWithDir ( self,
hostDir )
 Returns the HostInfo object that corresponds to the
indicated on-disk host directory.  This would be used when
reading a host directory from disk, instead of downloading it
from a server.  Supply the full path to the host directory, as
a Filename.  Returns None if the contents.xml in the indicated
host directory cannot be read or doesn't seem consistent. 

◆ getPandaScriptObject()

getPandaScriptObject ( self)
 Called by the browser to query the Panda instance's
toplevel scripting object, for querying properties in the
Panda instance.  The attributes on this object are mapped to
document.pluginobject.main within the DOM. 

◆ getToken()

getToken ( self,
tokenName )
 Returns the value of the indicated web token as a string,
if it was set, or None if it was not. 

◆ getTokenBool()

getTokenBool ( self,
tokenName )
 Returns the value of the indicated web token as a boolean
value, if it was set, or None if it was not. 

◆ getTokenFloat()

getTokenFloat ( self,
tokenName )
 Returns the value of the indicated web token as a
floating-point value value, if it was set, or None if it was
not, or not a number. 

◆ getTokenInt()

getTokenInt ( self,
tokenName )
 Returns the value of the indicated web token as an integer
value, if it was set, or None if it was not, or not an
integer. 

◆ initPackedAppEnvironment()

initPackedAppEnvironment ( self)
 This function sets up the Python environment suitably for
running a packed app.  It should only run once in any given
session (and it includes logic to ensure this). 

◆ installPackage()

installPackage ( self,
packageName,
version = None,
hostUrl = None )
 Installs the named package, downloading it first if
necessary.  Returns true on success, false on failure.  This
method runs synchronously, and will block until it is
finished; see the PackageInstaller class if you want this to
happen asynchronously instead. 

◆ loadMultifilePrcFiles()

loadMultifilePrcFiles ( self,
mf,
root )
 Loads any prc files in the root of the indicated
Multifile, which is presumed to have been mounted already
under root. 

◆ notifyRequest()

notifyRequest ( self,
message )
 Delivers a notify request to the browser.  This is a "this
happened" type notification; it also triggers some JavaScript
code execution, if indicated in the HTML tags, and may also
trigger some internal automatic actions.  (For instance, the
plugin takes down the splash window when it sees the
onwindowopen notification. 

◆ readConfigXml()

readConfigXml ( self)
 Reads the config.xml file that may be present in the root
directory. 

◆ rmtree()

rmtree ( self,
filename )
 This is like shutil.rmtree(), but it can remove read-only
files on Windows.  It receives a Filename, the root directory
to delete. 

◆ run()

run ( self)
 This method calls taskMgr.run(), with an optional
exception handler.  This is generally the program's main loop
when running in a p3d environment (except on unusual platforms
like the iPhone, which have to hand the main loop off to the
OS, and don't use this interface). 

◆ scanInstalledPackages()

scanInstalledPackages ( self)
 Scans the hosts and packages already installed locally on
the system.  Returns a list of InstalledHostData objects, each
of which contains a list of InstalledPackageData objects. 

◆ scriptRequest()

scriptRequest ( self,
operation,
object,
propertyName = '',
value = None,
needsResponse = True )
 Issues a new script request to the browser.  This queries
or modifies one of the browser's DOM properties.  This is a
low-level method that user code should not call directly;
instead, just operate on the Python wrapper objects that
shadow the DOM objects, beginning with appRunner.dom.

operation may be one of [ 'get_property', 'set_property',
'call', 'evaluate' ].

object is the browser object to manipulate, or the scope in
which to evaluate the expression.

propertyName is the name of the property to manipulate, if
relevant (set to None for the default method name).

value is the new value to assign to the property for
set_property, or the parameter list for call, or the string
expression for evaluate.

If needsResponse is true, this method will block until the
return value is received from the browser, and then it returns
that value.  Otherwise, it returns None immediately, without
waiting for the browser to process the request.

◆ sendRequest()

sendRequest ( self,
request,
* args )
 Delivers a request to the browser via self.requestFunc.
This low-level function is not intended to be called directly
by user code. 

◆ setBrowserScriptObject()

setBrowserScriptObject ( self,
dom )
 Called by the browser to supply the browser's toplevel DOM
object, for controlling the JavaScript and the document in the
same page with the Panda3D plugin. 

◆ setInstanceInfo()

setInstanceInfo ( self,
rootDir,
logDirectory,
superMirrorUrl,
verifyContents,
main,
respectPerPlatform )
 Called by the browser to set some global information about
the instance. 

◆ setP3DFilename()

setP3DFilename ( self,
p3dFilename,
tokens,
argv,
instanceId,
interactiveConsole,
p3dOffset = 0,
p3dUrl = None )
 Called by the browser to specify the p3d file that
contains the application itself, along with the web tokens
and/or command-line arguments.  Once this method has been
called, the application is effectively started. 

◆ setRequestFunc()

setRequestFunc ( self,
func )
 This method is called by the browser at startup to supply a
function that can be used to deliver requests upstream, to the
core API, and thereby to the browser. 

◆ setSessionId()

setSessionId ( self,
sessionId )
 This message should come in at startup. 

◆ setupWindow()

setupWindow ( self,
windowType,
x,
y,
width,
height,
parent )
 Applies the indicated window parameters to the prc
settings, for future windows; or applies them directly to the
main window if the window has already been opened.  This is
called by the browser. 

◆ stop()

stop ( self)
 This method can be called by JavaScript to stop the
application. 

◆ writeConfigXml()

writeConfigXml ( self)
 Rewrites the config.xml to the root directory.  This isn't
called automatically; an application may call this after
adjusting some parameters (such as self.maxDiskUsage). 

Member Data Documentation

◆ allowPythonDev

bool allowPythonDev = False

◆ altHost

dict altHost = None

◆ altHostMap

dict altHostMap = {}

◆ argv

argv = argv

◆ ConcreteStruct

◆ ConfigBasename

str ConfigBasename = 'config.xml'
static

◆ deferredEvals

list deferredEvals = []

◆ dom

dom = None

◆ downloadingPackages

list downloadingPackages = []

◆ downloadTask

downloadTask = None

◆ dummy

bool dummy = False

◆ exceptionHandler

exceptionHandler = None

◆ gotP3DFilename

bool gotP3DFilename = False

◆ gotWindow

bool gotWindow = False

◆ guiApp

bool guiApp = False

◆ hosts

dict hosts = {}

◆ http

http = None

◆ initialAppImport

bool initialAppImport = False

◆ installedPackages

list installedPackages = []

◆ instanceId

instanceId = None

◆ interactiveConsole

bool interactiveConsole = False

◆ logDirectory

logDirectory = None

◆ main

main = ScriptAttributes()

◆ maxDiskUsage

maxDiskUsage = 2048 * 1048576
static

◆ multifileRoot

multifileRoot = str(ExecutionEnvironment.getCwd())

◆ nextScriptId

int nextScriptId = 0

◆ notify

notify = directNotify.newCategory("AppRunner")
static

◆ P3D_CONTENTS_DEFAULT_MAX_AGE

int P3D_CONTENTS_DEFAULT_MAX_AGE = 5
static

◆ p3dConfig

p3dConfig = None

◆ p3dFilename

p3dFilename = None

◆ p3dInfo

p3dInfo = None

◆ p3dMultifile

p3dMultifile = mf

◆ p3dPackage

p3dPackage = 'main'

◆ p3dUrl

p3dUrl = None

◆ P3DVCForce

int P3DVCForce = 2
static

◆ P3DVCNever

int P3DVCNever = 3
static

◆ P3DVCNone

int P3DVCNone = 0
static

◆ P3DVCNormal

int P3DVCNormal = 1
static

◆ packedAppEnvironmentInitialized

bool packedAppEnvironmentInitialized = False

◆ pandaHostUrl

pandaHostUrl = PandaSystem.getPackageHostUrl()

◆ requestFunc

requestFunc = defaultRequestFunc

◆ respectPerPlatform

respectPerPlatform = None

◆ rootDir

rootDir = None

◆ sessionId

int sessionId = 0

◆ started

bool started = False

◆ superMirrorUrl

superMirrorUrl = None

◆ tokenDict

dict tokenDict = {}

◆ tokens

tokens = tokens

◆ trueFileIO

bool trueFileIO = False

◆ Undefined

Undefined = Undefined

◆ verifyContents

int verifyContents = self.P3DVCNone

◆ windowOpened

bool windowOpened = False

◆ windowPrc

windowPrc = None

◆ windowProperties

windowProperties = None