Panda3D

- Main Page
- Packages
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Public Attributes | Static Public Attributes

# AppRunner Class Reference

Inherits direct::showbase::DirectObject::DirectObject.

List of all members.

## Public Member Functions
def | __init__
def | addPackageInfo
def | checkDiskUsage
def | deletePackages
def | dropObject
def | evalScript
def | freshenFile
def | getHost
def | getHostWithAlt
def | getHostWithDir
def | getPandaScriptObject
def | getToken
def | getTokenBool
def | getTokenFloat
def | getTokenInt
def | initPackedAppEnvironment
def | installPackage
def | loadMultifilePrcFiles
def | notifyRequest
def | readConfigXml
def | rmtree
def | run
def | scanInstalledPackages
def | scriptRequest
def | sendRequest
def | setBrowserScriptObject
def | setInstanceInfo
def | setP3DFilename
def | setRequestFunc
def | setSessionId
def | setupWindow
def | stop
def | writeConfigXml
## Public Attributes
| allowPythonDev
| altHost
| altHostMap
| argv
| ConcreteStruct
| deferredEvals
| dom
| downloadingPackages
| downloadTask
| dummy
| exceptionHandler
| gotP3DFilename
| gotWindow
| guiApp
| hosts
| http
| initialAppImport
| installedPackages
| instanceId
| interactiveConsole
| logDirectory
| main
| maxDiskUsage
| multifileRoot
| nextScriptId
| p3dConfig
| p3dFilename
| p3dInfo
| p3dPackage
| p3dUrl
| packedAppEnvironmentInitialized
| pandaHostUrl
| requestFunc
| rootDir
| sessionId
| started
| superMirrorUrl
| tokenDict
| tokens
| trueFileIO
| Undefined
| verifyContents
| windowOpened
| windowPrc
| windowProperties
## Static Public Attributes
string | ConfigBasename = 'config.xml'
int | maxDiskUsage = 2048
tuple | notify = directNotify.newCategory("AppRunner")
int | P3D_CONTENTS_DEFAULT_MAX_AGE = 5
int | P3DVCForce = 2
int | P3DVCNever = 3
int | P3DVCNone = 0
int | P3DVCNormal = 1

## 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

def __init__ | ( |  | self | ) |

## Member Function Documentation

def 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.

def checkDiskUsage | ( |  | self | ) |

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

def 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.

def 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.

def 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.

def 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.

def 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().

def 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.

def 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.

def 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.

def getToken | ( |  | self,
|  |  | tokenName
| ) |  |

    Returns the value of the indicated web token as a string,
    if it was set, or None if it was not.

def 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.

def 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.

def 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.

def 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).

def 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.

def 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.

def 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.

def readConfigXml | ( |  | self | ) |

    Reads the config.xml file that may be present in the root
    directory.

def 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.

def 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).

def 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.

def 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.

def 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.

def 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.

def setInstanceInfo | ( |  | self,
|  |  | rootDir,
|  |  | logDirectory,
|  |  | superMirrorUrl,
|  |  | verifyContents,
|  |  | main
| ) |  |

    Called by the browser to set some global information about
    the instance.

def 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.

def 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.

def setSessionId | ( |  | self,
|  |  | sessionId
| ) |  |

    This message should come in at startup.

def 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.

def stop | ( |  | self | ) |

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

def 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

altHost

altHostMap

argv

ConcreteStruct

string ConfigBasename = 'config.xml'`[static]`

deferredEvals

dom

downloadingPackages

downloadTask

dummy

exceptionHandler

gotP3DFilename

gotWindow

guiApp

hosts

http

initialAppImport

installedPackages

instanceId

interactiveConsole

logDirectory

main

maxDiskUsage

int maxDiskUsage = 2048`[static]`

multifileRoot

nextScriptId

tuple notify = directNotify.newCategory("AppRunner")`[static]`

int P3D_CONTENTS_DEFAULT_MAX_AGE = 5`[static]`

p3dConfig

p3dFilename

p3dInfo

p3dPackage

p3dUrl

int P3DVCForce = 2`[static]`

int P3DVCNever = 3`[static]`

int P3DVCNone = 0`[static]`

int P3DVCNormal = 1`[static]`

packedAppEnvironmentInitialized

pandaHostUrl

requestFunc

rootDir

sessionId

started

superMirrorUrl

tokenDict

tokens

trueFileIO

Undefined

verifyContents

windowOpened

windowPrc

windowProperties

All Classes Namespaces Functions Variables Enumerations Enumerator Properties