def findNewsDir(self): if self.NewsOverHttp: return self.NewsStageDir else: searchPath = DSearchPath() if AppRunnerGlobal.appRunner: searchPath.appendDirectory( Filename.expandFrom('$TT_3_5_ROOT/phase_3.5/models/news')) else: basePath = os.path.expandvars('$TTMODELS') or './ttmodels' searchPath.appendDirectory( Filename.fromOsSpecific(basePath + '/built/' + self.NewsBaseDir)) searchPath.appendDirectory(Filename(self.NewsBaseDir)) pfile = Filename(self.NewsIndexFilename) found = vfs.resolveFilename(pfile, searchPath) if not found: self.notify.warning('findNewsDir - no path: %s' % self.NewsIndexFilename) self.setErrorMessage(TTLocalizer.NewsPageErrorDownloadingFile % self.NewsIndexFilename) return None self.notify.debug('found index file %s' % pfile) realDir = pfile.getDirname() return realDir
def cogExists(filePrefix): searchPath = DSearchPath() if AppRunnerGlobal.appRunner: searchPath.appendDirectory(Filename.expandFrom('$TT_3_5_ROOT/phase_3.5')) else: basePath = os.path.expandvars('$TTMODELS') or './ttmodels' searchPath.appendDirectory(Filename.fromOsSpecific(basePath + '/built/phase_3.5')) filePrefix = filePrefix.strip('/') pfile = Filename(filePrefix) found = vfs.resolveFilename(pfile, searchPath) if not found: return False return True
def makeBundle(startDir): fstartDir = Filename.fromOsSpecific(startDir) # Search for nppandad along $DYLD_LIBRARY_PATH. path = DSearchPath() if 'LD_LIBRARY_PATH' in os.environ: path.appendPath(os.environ['LD_LIBRARY_PATH']) if 'DYLD_LIBRARY_PATH' in os.environ: path.appendPath(os.environ['DYLD_LIBRARY_PATH']) nppanda3d = path.findFile('nppanda3d') if not nppanda3d: raise Exception("Couldn't find nppanda3d on path.") # Generate the bundle directory structure rootFilename = Filename(fstartDir, 'bundle') if os.path.exists(rootFilename.toOsSpecific()): shutil.rmtree(rootFilename.toOsSpecific()) bundleFilename = Filename(rootFilename, 'nppanda3d.plugin') plistFilename = Filename(bundleFilename, 'Contents/Info.plist') plistFilename.makeDir() exeFilename = Filename(bundleFilename, 'Contents/MacOS/nppanda3d') exeFilename.makeDir() resourceFilename = Filename(bundleFilename, 'Contents/Resources/nppanda3d.rsrc') resourceFilename.makeDir() # Compile the .r file to an .rsrc file. os.system('/Developer/Tools/Rez -useDF -o %s %s' % (resourceFilename.toOsSpecific(), Filename(fstartDir, "nppanda3d.r").toOsSpecific())) if not resourceFilename.exists(): raise IOError('Unable to run Rez') # Copy in Info.plist and the compiled executable. shutil.copyfile( Filename(fstartDir, "nppanda3d.plist").toOsSpecific(), plistFilename.toOsSpecific()) shutil.copyfile(nppanda3d.toOsSpecific(), exeFilename.toOsSpecific()) # All done! bundleFilename.touch() print(bundleFilename.toOsSpecific())
def findNewsDir(self): if self.NewsOverHttp: return self.NewsStageDir searchPath = DSearchPath() if AppRunnerGlobal.appRunner: searchPath.appendDirectory(Filename.expandFrom('$TT_3_5_ROOT/phase_3.5/models/news')) else: basePath = os.path.expandvars('$TTMODELS') or './ttmodels' searchPath.appendDirectory(Filename.fromOsSpecific(basePath + '/built/' + self.NewsBaseDir)) searchPath.appendDirectory(Filename(self.NewsBaseDir)) pfile = Filename(self.NewsIndexFilename) found = vfs.resolveFilename(pfile, searchPath) if not found: self.notify.warning('findNewsDir - no path: %s' % self.NewsIndexFilename) self.setErrorMessage(TTLocalizer.NewsPageErrorDownloadingFile % self.NewsIndexFilename) return None self.notify.debug('found index file %s' % pfile) realDir = pfile.getDirname() return realDir
def __init__(self, filePath, fileName): self.__filePath = filePath self.__fileName = fileName vfs = VirtualFileSystem.getGlobalPtr() filename = Filename(fileName) searchPath = DSearchPath() if __debug__: searchPath.appendDirectory(Filename.expandFrom('resources/%s' % filePath)) else: searchPath.appendDirectory(Filename.expandFrom(filePath)) found = vfs.resolveFilename(filename, searchPath) if not found: raise TileFileIOException('Unable to locate tiled file \"%s\"; File not found on %s' % (fileName, searchPath)) self.__fileData = json.loads(vfs.readFile(filename, 1)) self.__verifyData() self.__layers = self.__fileData['layers']
def makeBundle(startDir): fstartDir = Filename.fromOsSpecific(startDir) # Search for nppandad along $DYLD_LIBRARY_PATH. path = DSearchPath() if 'LD_LIBRARY_PATH' in os.environ: path.appendPath(os.environ['LD_LIBRARY_PATH']) if 'DYLD_LIBRARY_PATH' in os.environ: path.appendPath(os.environ['DYLD_LIBRARY_PATH']) nppanda3d = path.findFile('nppanda3d') if not nppanda3d: raise Exception("Couldn't find nppanda3d on path.") # Generate the bundle directory structure rootFilename = Filename(fstartDir, 'bundle') if os.path.exists(rootFilename.toOsSpecific()): shutil.rmtree(rootFilename.toOsSpecific()) bundleFilename = Filename(rootFilename, 'nppanda3d.plugin') plistFilename = Filename(bundleFilename, 'Contents/Info.plist') plistFilename.makeDir() exeFilename = Filename(bundleFilename, 'Contents/MacOS/nppanda3d') exeFilename.makeDir() resourceFilename = Filename(bundleFilename, 'Contents/Resources/nppanda3d.rsrc') resourceFilename.makeDir() # Compile the .r file to an .rsrc file. os.system('/Developer/Tools/Rez -useDF -o %s %s' % ( resourceFilename.toOsSpecific(), Filename(fstartDir, "nppanda3d.r").toOsSpecific())) if not resourceFilename.exists(): raise IOError('Unable to run Rez') # Copy in Info.plist and the compiled executable. shutil.copyfile(Filename(fstartDir, "nppanda3d.plist").toOsSpecific(), plistFilename.toOsSpecific()) shutil.copyfile(nppanda3d.toOsSpecific(), exeFilename.toOsSpecific()) # All done! bundleFilename.touch() print(bundleFilename.toOsSpecific())
def __loadCredits(self): self.creditsParent = NodePath('credits-parent') self.creditsParent.reparentTo(base.a2dTopRight) self.creditsParent.setPos(-1.2, 0, -0.75) vfs = VirtualFileSystem.getGlobalPtr() filename = Filename('credits.txt') searchPath = DSearchPath() if __debug__: searchPath.appendDirectory(Filename.expandFrom('resources/etc')) else: searchPath.appendDirectory(Filename.expandFrom('etc')) found = vfs.resolveFilename(filename, searchPath) if not found: self.notify.warning('Unable to load credits; credits.txt not found on %s' % searchPath) return self.creditsData = vfs.readFile(filename, 1).split('\n') self.creditsText = [] self.currentCreditIndex = 0 cyAxis = 0 firstPass = True for i in range(0, len(self.creditsData)): if i % 5 == 0 and i >= 5: firstPass = False cyAxis = 0 text = TextNode('credits-node-%s' % i) text.setText(self.creditsData[i]) self.creditsText.append(text) if not firstPass: text.setTextColor(255, 255, 255, 0) textNodePath = self.creditsParent.attachNewNode(text) textNodePath.setScale(0.07) textNodePath.setPos(0, 0, cyAxis) cyAxis -= 0.1 taskMgr.doMethodLater(5, self.__processCreditsTask, 'process-credits-task')
from direct.showbase.ShowBase import ShowBase from direct.task.Task import Task from pandac.PandaModules import WindowProperties from panda3d.core import loadPrcFile, loadPrcFileData, Filename, DSearchPath, VBase4 # thread coordination import framework.tickmodule import threading # network support import Queue import SocketServer print "done." print "Applying the engine configuration file/settings..." # load the selected engine configuration (studypath takes precedence over the SNAP root path) config_searchpath = DSearchPath() config_searchpath.appendDirectory(Filename.fromOsSpecific(opts.studypath)) config_searchpath.appendDirectory(Filename.fromOsSpecific('.')) loadPrcFile(config_searchpath.findFile(Filename.fromOsSpecific(opts.engineconfig))) # add a few more media search paths (in particular, media can be in the media directory, or in the studypath) loadPrcFileData('', 'model-path ' + opts.studypath + '/media') loadPrcFileData('', 'model-path ' + opts.studypath) loadPrcFileData('', 'model-path media') # override engine settings according to the command line arguments, if specified if opts.fullscreen is not None: loadPrcFileData('', 'fullscreen ' + opts.fullscreen) if opts.windowsize is not None: loadPrcFileData('', 'win-size ' + opts.windowsize.replace('x',' ')) if opts.windoworigin is not None:
from direct.showbase.ShowBase import ShowBase from direct.task.Task import Task from pandac.PandaModules import WindowProperties from panda3d.core import loadPrcFile, loadPrcFileData, Filename, DSearchPath, VBase4 # thread coordination import framework.tickmodule import threading # network support import Queue import SocketServer print "done." print "Applying the engine configuration file/settings..." # load the selected engine configuration (studypath takes precedence over the SNAP root path) config_searchpath = DSearchPath() config_searchpath.appendDirectory(Filename.fromOsSpecific(opts.studypath)) config_searchpath.appendDirectory(Filename.fromOsSpecific('.')) loadPrcFile( config_searchpath.findFile(Filename.fromOsSpecific(opts.engineconfig))) # add a few more media search paths (in particular, media can be in the media directory, or in the studypath) loadPrcFileData('', 'model-path ' + opts.studypath + '/media') loadPrcFileData('', 'model-path ' + opts.studypath) loadPrcFileData('', 'model-path media') # override engine settings according to the command line arguments, if specified if opts.fullscreen is not None: loadPrcFileData('', 'fullscreen ' + opts.fullscreen) if opts.windowsize is not None: loadPrcFileData('', 'win-size ' + opts.windowsize.replace('x', ' '))
def makeBundle(startDir): fstartDir = Filename.fromOsSpecific(startDir) # Search for panda3d_mac along $PATH. path = DSearchPath() if 'PATH' in os.environ: path.appendPath(os.environ['PATH']) path.appendPath(os.defpath) panda3d_mac = path.findFile('panda3d_mac') if not panda3d_mac: raise Exception("Couldn't find panda3d_mac on path.") # Construct a search path to look for the images. search = DSearchPath() # First on the path: an explicit $PLUGIN_IMAGES env var. if ExecutionEnvironment.hasEnvironmentVariable('PLUGIN_IMAGES'): search.appendDirectory(Filename.expandFrom('$PLUGIN_IMAGES')) # Next on the path: the models/plugin_images directory within the # current directory. search.appendDirectory('models/plugin_images') # Finally on the path: models/plugin_images within the model # search path. for dir in getModelPath().getDirectories(): search.appendDirectory(Filename(dir, 'plugin_images')) # Now find the icon file on the above search path. icons = search.findFile('panda3d.icns') if not icons: raise Exception("Couldn't find panda3d.icns on model-path.") # Generate the bundle directory structure rootFilename = Filename(fstartDir) bundleFilename = Filename(rootFilename, 'Panda3D.app') if os.path.exists(bundleFilename.toOsSpecific()): shutil.rmtree(bundleFilename.toOsSpecific()) plistFilename = Filename(bundleFilename, 'Contents/Info.plist') plistFilename.makeDir() exeFilename = Filename(bundleFilename, 'Contents/MacOS/panda3d_mac') exeFilename.makeDir() iconFilename = Filename(bundleFilename, 'Contents/Resources/panda3d.icns') iconFilename.makeDir() # Copy in Info.plist, the icon file, and the compiled executable. shutil.copyfile(Filename(fstartDir, "panda3d_mac.plist").toOsSpecific(), plistFilename.toOsSpecific()) shutil.copyfile(icons.toOsSpecific(), iconFilename.toOsSpecific()) print('%s %s' % (panda3d_mac, exeFilename)) shutil.copyfile(panda3d_mac.toOsSpecific(), exeFilename.toOsSpecific()) os.chmod(exeFilename.toOsSpecific(), 0o755) # All done! bundleFilename.touch() print(bundleFilename.toOsSpecific())
def makeBundle(startDir): fstartDir = Filename.fromOsSpecific(startDir) # Search for panda3d_mac along $PATH. path = DSearchPath() if 'PATH' in os.environ: path.appendPath(os.environ['PATH']) path.appendPath(os.defpath) panda3d_mac = path.findFile('panda3d_mac') if not panda3d_mac: raise Exception("Couldn't find panda3d_mac on path.") # Construct a search path to look for the images. search = DSearchPath() # First on the path: an explicit $PLUGIN_IMAGES env var. if ExecutionEnvironment.hasEnvironmentVariable('PLUGIN_IMAGES'): search.appendDirectory(Filename.expandFrom('$PLUGIN_IMAGES')) # Next on the path: the models/plugin_images directory within the # current directory. search.appendDirectory('models/plugin_images') # Finally on the path: models/plugin_images within the model # search path. for dir in getModelPath().getDirectories(): search.appendDirectory(Filename(dir, 'plugin_images')) # Now find the icon file on the above search path. icons = search.findFile('panda3d.icns') if not icons: raise Exception("Couldn't find panda3d.icns on model-path.") # Generate the bundle directory structure rootFilename = Filename(fstartDir) bundleFilename = Filename(rootFilename, 'Panda3D.app') if os.path.exists(bundleFilename.toOsSpecific()): shutil.rmtree(bundleFilename.toOsSpecific()) plistFilename = Filename(bundleFilename, 'Contents/Info.plist') plistFilename.makeDir() exeFilename = Filename(bundleFilename, 'Contents/MacOS/panda3d_mac') exeFilename.makeDir() iconFilename = Filename(bundleFilename, 'Contents/Resources/panda3d.icns') iconFilename.makeDir() # Copy in Info.plist, the icon file, and the compiled executable. shutil.copyfile( Filename(fstartDir, "panda3d_mac.plist").toOsSpecific(), plistFilename.toOsSpecific()) shutil.copyfile(icons.toOsSpecific(), iconFilename.toOsSpecific()) print('%s %s' % (panda3d_mac, exeFilename)) shutil.copyfile(panda3d_mac.toOsSpecific(), exeFilename.toOsSpecific()) os.chmod(exeFilename.toOsSpecific(), 0o755) # All done! bundleFilename.touch() print(bundleFilename.toOsSpecific())
def readFavIcon(self): vfs = VirtualFileSystem.getGlobalPtr() filename = Filename('favicon.ico') searchPath = DSearchPath() searchPath.appendDirectory(Filename('.')) searchPath.appendDirectory(Filename('etc')) searchPath.appendDirectory(Filename.fromOsSpecific(os.path.expandvars('$DIRECT/src/http'))) searchPath.appendDirectory(Filename.fromOsSpecific(os.path.expandvars('direct/src/http'))) searchPath.appendDirectory(Filename.fromOsSpecific(os.path.expandvars('direct/http'))) searchPath.appendDirectory(Filename('game/resources/http')) searchPath.appendDirectory(Filename('resources/http')) found = vfs.resolveFilename(filename,searchPath) if not found: raise Exception("Couldn't find direct/http/favicon.ico") return vfs.readFile(filename, 1)