protect from builds without net or openssl

This commit is contained in:
David Rose 2009-10-13 18:56:17 +00:00
parent 9b32060d7c
commit f17536da77
4 changed files with 50 additions and 25 deletions

View File

@ -28,11 +28,13 @@ else:
# Otherwise, we can import the VFSImporter normally. We have to # Otherwise, we can import the VFSImporter normally. We have to
# import PandaModules first, to get the funny renaming with # import PandaModules first, to get the funny renaming with
# pandaexpress. # pandaexpress.
import direct
from pandac import PandaModules from pandac import PandaModules
from direct.showbase import VFSImporter from direct.showbase import VFSImporter
from direct.showbase.DirectObject import DirectObject from direct.showbase.DirectObject import DirectObject
from pandac.PandaModules import VirtualFileSystem, Filename, Multifile, loadPrcFileData, unloadPrcFile, getModelPath, HTTPClient, Thread, WindowProperties, readXmlStream, ExecutionEnvironment, PandaSystem, URLSpec, Notify, StreamWriter, ConfigVariableString from pandac.PandaModules import VirtualFileSystem, Filename, Multifile, loadPrcFileData, unloadPrcFile, getModelPath, Thread, WindowProperties, ExecutionEnvironment, PandaSystem, Notify, StreamWriter, ConfigVariableString
from pandac import PandaModules
from direct.stdpy import file from direct.stdpy import file
from direct.task.TaskManagerGlobal import taskMgr from direct.task.TaskManagerGlobal import taskMgr
from direct.showbase.MessengerGlobal import messenger from direct.showbase.MessengerGlobal import messenger
@ -88,7 +90,10 @@ class AppRunner(DirectObject):
self.started = False self.started = False
self.windowOpened = False self.windowOpened = False
self.windowPrc = None self.windowPrc = None
self.http = HTTPClient.getGlobalPtr()
self.http = None
if hasattr(PandaModules, 'HTTPClient'):
self.http = PandaModules.HTTPClient.getGlobalPtr()
self.Undefined = Undefined self.Undefined = Undefined
self.ConcreteStruct = ConcreteStruct self.ConcreteStruct = ConcreteStruct
@ -332,8 +337,10 @@ class AppRunner(DirectObject):
# It's good, keep it. # It's good, keep it.
return True return True
assert self.http
# It's stale, get a new one. # It's stale, get a new one.
url = URLSpec(host.hostUrlPrefix + fileSpec.filename) url = PandaModules.URLSpec(host.hostUrlPrefix + fileSpec.filename)
print "Freshening %s" % (url) print "Freshening %s" % (url)
doc = self.http.getDocument(url) doc = self.http.getDocument(url)
if not doc.isValid(): if not doc.isValid():
@ -583,7 +590,7 @@ class AppRunner(DirectObject):
self.allowPythonDev = False self.allowPythonDev = False
i = mf.findSubfile('p3d_info.xml') i = mf.findSubfile('p3d_info.xml')
if i >= 0: if i >= 0 and hasattr(PandaModules, 'readXmlStream'):
stream = mf.openReadSubfile(i) stream = mf.openReadSubfile(i)
self.p3dInfo = readXmlStream(stream) self.p3dInfo = readXmlStream(stream)
mf.closeReadSubfile(stream) mf.closeReadSubfile(stream)

View File

@ -1,4 +1,5 @@
from pandac.PandaModules import TiXmlDocument, HashVal, Filename, PandaSystem, DocumentSpec, Ramfile from pandac.PandaModules import HashVal, Filename, PandaSystem, DocumentSpec, Ramfile
from pandac import PandaModules
from direct.p3d.PackageInfo import PackageInfo from direct.p3d.PackageInfo import PackageInfo
from direct.p3d.FileSpec import FileSpec from direct.p3d.FileSpec import FileSpec
import time import time
@ -78,24 +79,25 @@ class HostInfo:
# We've already got one. # We've already got one.
return True return True
url = self.hostUrlPrefix + 'contents.xml' if http:
# Append a uniquifying query string to the URL to force the url = self.hostUrlPrefix + 'contents.xml'
# download to go all the way through any caches. We use the # Append a uniquifying query string to the URL to force the
# time in seconds; that's unique enough. # download to go all the way through any caches. We use the
url += '?' + str(int(time.time())) # time in seconds; that's unique enough.
url += '?' + str(int(time.time()))
# We might as well explicitly request the cache to be disabled # We might as well explicitly request the cache to be disabled
# too, since we have an interface for that via HTTPChannel. # too, since we have an interface for that via HTTPChannel.
request = DocumentSpec(url) request = DocumentSpec(url)
request.setCacheControl(DocumentSpec.CCNoCache) request.setCacheControl(DocumentSpec.CCNoCache)
print "Downloading contents file %s" % (request) print "Downloading contents file %s" % (request)
rf = Ramfile() rf = Ramfile()
channel = http.makeChannel(False) channel = http.makeChannel(False)
channel.getDocument(request) channel.getDocument(request)
if not channel.downloadToRam(rf): if not channel.downloadToRam(rf):
print "Unable to download %s" % (url) print "Unable to download %s" % (url)
filename = Filename(self.hostDir, 'contents.xml') filename = Filename(self.hostDir, 'contents.xml')
filename.makeDir() filename.makeDir()
@ -150,7 +152,10 @@ class HostInfo:
filename = Filename(self.hostDir, 'contents.xml') filename = Filename(self.hostDir, 'contents.xml')
doc = TiXmlDocument(filename.toOsSpecific()) if not hasattr(PandaModules, 'TiXmlDocument'):
return False
doc = PandaModules.TiXmlDocument(filename.toOsSpecific())
if not doc.LoadFile(): if not doc.LoadFile():
return False return False

View File

@ -1,4 +1,5 @@
from pandac.PandaModules import Filename, URLSpec, DocumentSpec, Ramfile, TiXmlDocument, Multifile, Decompressor, EUOk, EUSuccess, VirtualFileSystem, Thread, getModelPath, Patchfile, ExecutionEnvironment from pandac.PandaModules import Filename, URLSpec, DocumentSpec, Ramfile, Multifile, Decompressor, EUOk, EUSuccess, VirtualFileSystem, Thread, getModelPath, ExecutionEnvironment
from pandac import PandaModules
from direct.p3d.FileSpec import FileSpec from direct.p3d.FileSpec import FileSpec
from direct.showbase import VFSImporter from direct.showbase import VFSImporter
import os import os
@ -221,7 +222,9 @@ class PackageInfo:
filename = Filename(self.packageDir, self.descFileBasename) filename = Filename(self.packageDir, self.descFileBasename)
doc = TiXmlDocument(filename.toOsSpecific()) if not hasattr(PandaModules, 'TiXmlDocument'):
return False
doc = PandaModules.TiXmlDocument(filename.toOsSpecific())
if not doc.LoadFile(): if not doc.LoadFile():
return False return False
@ -683,7 +686,7 @@ class PackageInfo:
result = Filename.temporary('', 'patch_') result = Filename.temporary('', 'patch_')
print "Patching %s with %s" % (origPathname, patchPathname) print "Patching %s with %s" % (origPathname, patchPathname)
p = Patchfile() # The C++ class p = PandaModules.Patchfile() # The C++ class
ret = p.initiate(patchPathname, origPathname, result) ret = p.initiate(patchPathname, origPathname, result)
if ret == EUSuccess: if ret == EUSuccess:

View File

@ -56,6 +56,16 @@ def parseSysArgs():
return [arg0] + args[1:] return [arg0] + args[1:]
def runPackedApp(pathname):
runner = AppRunner()
runner.gotWindow = True
try:
runner.setP3DFilename(pathname, tokens = [], argv = [],
instanceId = 0, interactiveConsole = False)
except ArgumentError, e:
print e.args[0]
sys.exit(1)
if __name__ == '__main__': if __name__ == '__main__':
runner = AppRunner() runner = AppRunner()
runner.gotWindow = True runner.gotWindow = True