当前位置: 首页>>代码示例>>Python>>正文


Python core.VirtualFileSystem类代码示例

本文整理汇总了Python中panda3d.core.VirtualFileSystem的典型用法代码示例。如果您正苦于以下问题:Python VirtualFileSystem类的具体用法?Python VirtualFileSystem怎么用?Python VirtualFileSystem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了VirtualFileSystem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: load

    def load(self, filename):
        """ Loads a profile from a given filename """

        # Make filename unique

        fname = Filename.from_os_specific(filename)
        if not VirtualFileSystem.get_global_ptr().resolve_filename(fname, get_model_path().get_value(), "ies"):
            self.error("Could not resolve", filename)
            return -1
        fname = fname.get_fullpath()

        # Check for cache entries
        if fname in self._entries:
            return self._entries.index(fname)

        # Check for out of bounds
        if len(self._entries) >= self._max_entries:
            # TODO: Could remove unused profiles here or regenerate texture
            self.warn("Cannot load IES Profile, too many loaded! (Maximum: 32)")

        # Try loading the dataset, and see what happes
        try:
            dataset = self._loader.load(fname)
        except IESLoaderException as msg:
            self.warn("Failed to load profile from", filename, ":", msg)
            return -1

        if not dataset:
            return -1

        # Dataset was loaded successfully, now copy it
        dataset.generate_dataset_texture_into(self._storage_tex, len(self._entries))
        self._entries.append(fname)

        return len(self._entries) - 1
开发者ID:wdmwdm,项目名称:RenderPipeline,代码行数:35,代码来源:IESProfileManager.py

示例2: reloadTextures

def reloadTextures(textureName=""):
    """
    Artfart command to reload all of the textures.

    TODO: A panel that says "Reloading textures... Please wait!"
    ...though it's not important since it's a staff command and
    only staff will see it.

    Stolen from ToontownStart.py
    Remount all phase files. This maybe might work? Idk. Lets see
    if Panda craps itself.

    Place raw files in /resources/non-mf/phase_*/ and they will be
    mounted without needing to multify!
    """

    # Lock ...
    vfs = VirtualFileSystem.getGlobalPtr()
    for file in glob.glob("resources/non-mf/phase_*/"):
        # Slightly hacky. We remove the trailing slash so we have a tail,
        # and select the tail value from the returned tuple. Finally we
        # prepend a slash for the mount point.
        mount_point = "/" + str(os.path.split(file[:-1])[1])
        vfs.mount(Filename(file), Filename(mount_point), 0)

    # ... and load.
    if textureName:
        pool = TexturePool.findAllTextures("*" + textureName + "*")
    else:
        pool = TexturePool.findAllTextures()
    for texture in pool:
        texture.reload()
    if textureName:
        return "Reloaded all textures matching '%s'" % textureName
    return "Reloaded all of the textures!"
开发者ID:TLOTT-PS,项目名称:ttr-src,代码行数:35,代码来源:OTPBase.py

示例3: dummyAppRunner

def dummyAppRunner(tokens = [], argv = None):
    """ This function creates a dummy global AppRunner object, which
    is useful for testing running in a packaged environment without
    actually bothering to package up the application.  Call this at
    the start of your application to enable it.

    It places the current working directory under /mf, as if it were
    mounted from a packed multifile.  It doesn't convert egg files to
    bam files, of course; and there are other minor differences from
    running in an actual packaged environment.  But it can be a useful
    first-look sanity check. """

    if AppRunnerGlobal.appRunner:
        print("Already have AppRunner, not creating a new one.")
        return AppRunnerGlobal.appRunner

    appRunner = AppRunner()
    appRunner.dummy = True
    AppRunnerGlobal.appRunner = appRunner

    platform = PandaSystem.getPlatform()
    version = PandaSystem.getPackageVersionString()
    hostUrl = PandaSystem.getPackageHostUrl()

    if platform.startswith('win'):
        rootDir = Filename(Filename.getUserAppdataDirectory(), 'Panda3D')
    elif platform.startswith('osx'):
        rootDir = Filename(Filename.getHomeDirectory(), 'Library/Caches/Panda3D')
    else:
        rootDir = Filename(Filename.getHomeDirectory(), '.panda3d')

    appRunner.rootDir = rootDir
    appRunner.logDirectory = Filename(rootDir, 'log')

    # Of course we will have the panda3d application loaded.
    appRunner.addPackageInfo('panda3d', platform, version, hostUrl)

    appRunner.tokens = tokens
    appRunner.tokenDict = dict(tokens)
    if argv is None:
        argv = sys.argv
    appRunner.argv = argv
    appRunner.altHost = appRunner.tokenDict.get('alt_host', None)

    appRunner.p3dInfo = None
    appRunner.p3dPackage = None

    # Mount the current directory under the multifileRoot, as if it
    # were coming from a multifile.
    cwd = ExecutionEnvironment.getCwd()
    vfs = VirtualFileSystem.getGlobalPtr()
    vfs.mount(cwd, appRunner.multifileRoot, vfs.MFReadOnly)

    appRunner.initPackedAppEnvironment()

    return appRunner
开发者ID:Just-D,项目名称:panda3d,代码行数:56,代码来源:AppRunner.py

示例4: loadText

 def loadText(self):
     # Load database
     vfs = VirtualFileSystem.getGlobalPtr()
     #print "Virtual fs" ,vfs.lsAll('/mf')
     path = vfs.findFile('TXT_UI_Common.yaml', '.')
     if not path:
         path = vfs.findFile('TXT_UI_Common.yaml', '/mf')
     stream = vfs.readFile(path.getFilename(), True)
     textDictionary = yaml.load(stream)
     for key in textDictionary:
         self.database[key] = textDictionary[key]
开发者ID:croxis,项目名称:CityMania,代码行数:11,代码来源:gui.py

示例5: __init__

    def __init__(self, filepath):
        self.filepath = filepath

        self.vfs = VirtualFileSystem.getGlobalPtr()

        if __debug__:
            self.mountPoint = "../resources"
        else:
            self.mountPoint = "/"

        self.sortOrder = []
开发者ID:RandomToon,项目名称:Toontown-2,代码行数:11,代码来源:ContentPacksManager.py

示例6: __init__

    def __init__(self, filepath='contentpacks/', sortFilename='sort.yaml'):
        self.filepath = filepath
        self.sortFilename = os.path.join(self.filepath, sortFilename)

        if __debug__:
            self.mountPoint = '../resources'
        else:
            self.mountPoint = '/'

        self.vfs = VirtualFileSystem.getGlobalPtr()

        self.sort = []
        self.ambience = {}
开发者ID:CalebSmith376,项目名称:src,代码行数:13,代码来源:ContentPacksManager.py

示例7: ReadResponse

    def ReadResponse(self, dataOut, bytesToRead, bytesReadOut, callback):
        if self.contents is None:
            self.contents = VirtualFileSystem.getGlobalPtr().readFile(self.filePath, False)

        if self.offset < len(self.contents):
            dataOut[0] = self.contents[self.offset:self.offset + bytesToRead]
            bytesReadOut[0] = bytesToRead

            self.offset += bytesToRead

            return True

        # We are done
        self.clientHandler._ReleaseStrongReference(self)
        return False
开发者ID:Tuxinet,项目名称:LoR,代码行数:15,代码来源:VFSResourceHandler.py

示例8: GetResponseHeaders

    def GetResponseHeaders(self, response, responseLengthOut, redirectUrlOut):
        """

        :type response: cefpython.PyResponse
        """
        response.SetMimeType(getMimeType(self.url))

        file = VirtualFileSystem.getGlobalPtr().getFile(self.filePath)

        if file is None:
            response.SetStatus(404)
            response.SetStatusText("File not found")

            return

        responseLengthOut[0] = file.getFileSize()
开发者ID:Tuxinet,项目名称:LoR,代码行数:16,代码来源:VFSResourceHandler.py

示例9: findAllModelFilesInVFS

def findAllModelFilesInVFS(phase_array):
    models = []
    vfs = VirtualFileSystem.getGlobalPtr()
    for phase in phase_array:
        fileList = vfs.scanDirectory(Filename(phase))
        for fileName in fileList:
            if fileName.get_filename().get_fullpath().endswith('.bam') or fileName.get_filename().get_fullpath().endswith('.egg') or fileName.get_filename().get_fullpath().endswith('.pz'):
                if fileName.get_filename().get_fullpath() not in models:
                    models.append(fileName.get_filename().get_fullpath())
            else:
                fileList2 = vfs.scanDirectory(Filename(fileName.get_filename().get_fullpath()))
                for fileName2 in fileList2:
                    if fileName2.get_filename().get_fullpath().endswith('.bam') or fileName2.get_filename().get_fullpath().endswith('.egg') or fileName2.get_filename().get_fullpath().endswith('.pz'):
                        if fileName2.get_filename().get_fullpath() not in models:
                            models.append(fileName2.get_filename().get_fullpath())

    return models
开发者ID:coginvasion,项目名称:src,代码行数:17,代码来源:FileUtility.py

示例10: load_3d_texture

    def load_3d_texture(cls, fname, tile_size_x, tile_size_y=None, num_tiles=None):
        """ Loads a texture from the given filename and dimensions. If only
        one dimensions is specified, the other dimensions are assumed to be
        equal. This internally loads the texture into ram, splits it into smaller
        sub-images, and then calls the load_3d_texture from the Panda loader """

        # Generate a unique name to prevent caching
        tempfile_name = "$$SliceLoaderTemp-" + str(time.time()) + "/"

        # For quaddratic textures
        tile_size_y = tile_size_x if tile_size_y is None else tile_size_y
        num_tiles = tile_size_x if num_tiles is None else num_tiles

        # Load sliced image from disk
        source = PNMImage(fname)
        width = source.get_x_size()

        # Find slice properties
        num_cols = width // tile_size_x
        temp = PNMImage(
            tile_size_x, tile_size_y, source.get_num_channels(), source.get_maxval())

        # Construct a ramdisk to write the files to
        vfs = VirtualFileSystem.get_global_ptr()
        ramdisk = VirtualFileMountRamdisk()
        vfs.mount(ramdisk, tempfile_name, 0)

        # Extract all slices and write them to the virtual disk
        for z_slice in range(num_tiles):
            slice_x = (z_slice % num_cols) * tile_size_x
            slice_y = (z_slice // num_cols) * tile_size_y
            temp.copy_sub_image(source, 0, 0, slice_x, slice_y, tile_size_x, tile_size_y)
            temp.write(tempfile_name + str(z_slice) + ".png")

        # Load the de-sliced texture from the ramdisk
        texture_handle = Globals.loader.load3DTexture(tempfile_name + "/#.png")

        # This should never trigger, but can't hurt to have
        assert texture_handle.get_x_size() == tile_size_x
        assert texture_handle.get_y_size() == tile_size_y
        assert texture_handle.get_z_size() == num_tiles

        # Finally unmount the ramdisk
        vfs.unmount(ramdisk)

        return texture_handle
开发者ID:wdmwdm,项目名称:RenderPipeline,代码行数:46,代码来源:SliceLoader.py

示例11: initPackedAppEnvironment

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

        if self.packedAppEnvironmentInitialized:
            return

        self.packedAppEnvironmentInitialized = True

        vfs = VirtualFileSystem.getGlobalPtr()

        # Now set up Python to import this stuff.
        VFSImporter.register()
        sys.path.append(self.multifileRoot)

        # Make sure that $MAIN_DIR is set to the p3d root before we
        # start executing the code in this file.
        ExecutionEnvironment.setEnvironmentVariable("MAIN_DIR", Filename(self.multifileRoot).toOsSpecific())

        # Put our root directory on the model-path, too.
        getModelPath().appendDirectory(self.multifileRoot)

        if not self.trueFileIO:
            # Replace the builtin open and file symbols so user code will get
            # our versions by default, which can open and read files out of
            # the multifile.
            builtins.open = file.open
            if sys.version_info < (3, 0):
                builtins.file = file.open
                builtins.execfile = file.execfile
            os.listdir = file.listdir
            os.walk = file.walk
            os.path.join = file.join
            os.path.isfile = file.isfile
            os.path.isdir = file.isdir
            os.path.exists = file.exists
            os.path.lexists = file.lexists
            os.path.getmtime = file.getmtime
            os.path.getsize = file.getsize
            sys.modules["glob"] = glob

        self.checkDiskUsage()
开发者ID:michaelcaoruiqing,项目名称:panda3d,代码行数:43,代码来源:AppRunner.py

示例12: fromFile

    def fromFile(self, packageDir, filename, pathname = None, st = None):
        """ Reads the file information from the indicated file.  If st
        is supplied, it is the result of os.stat on the filename. """

        vfs = VirtualFileSystem.getGlobalPtr()

        filename = Filename(filename)
        if pathname is None:
            pathname = Filename(packageDir, filename)

        self.filename = str(filename)
        self.basename = filename.getBasename()

        if st is None:
            st = os.stat(pathname.toOsSpecific())
        self.size = st.st_size
        self.timestamp = int(st.st_mtime)

        self.readHash(pathname)
开发者ID:Astron,项目名称:panda3d,代码行数:19,代码来源:FileSpec.py

示例13: mount

    def mount(self):
        """ Inits the VFS Mounts """

        self.debug("Setting up virtual filesystem.")
        vfs = VirtualFileSystem.getGlobalPtr()

        # Mount data and models
        vfs.mountLoop(join(self.basePath, 'Data'), 'Data', 0)
        vfs.mountLoop(join(self.basePath, 'Models'), 'Models', 0)
        vfs.mountLoop(join(self.basePath, 'Config'), 'Config', 0)

        # Ensure the pipeline write path exists, and if not, create it
        if not isdir(self.writePath):
            self.debug("Creating temp path, as it does not exist yet")
            try:
                os.makedirs(self.writePath, 0777)
            except Exception, msg:
                self.error("Failed to create temp path:",msg)
                import sys
                sys.exit(0)
开发者ID:croxis,项目名称:RenderPipeline,代码行数:20,代码来源:MountManager.py

示例14: load

    def load(self, filename):
        """ Loads a profile from a given filename and returns the internal
        used index which can be assigned to a light."""

        # Make sure the user can load profiles directly from the ies profile folder
        data_path = join("/$$rp/data/ies_profiles/", filename)
        if isfile(data_path):
            filename = data_path

        # Make filename unique
        fname = Filename.from_os_specific(filename)
        if not VirtualFileSystem.get_global_ptr().resolve_filename(
                fname, get_model_path().get_value(), "ies"):
            self.error("Could not resolve", filename)
            return -1
        fname = fname.get_fullpath()

        # Check for cache entries
        if fname in self._entries:
            return self._entries.index(fname)

        # Check for out of bounds
        if len(self._entries) >= self._max_entries:
            # TODO: Could remove unused profiles here or regenerate texture
            self.warn("Cannot load IES Profile, too many loaded! (Maximum: 32)")

        # Try loading the dataset, and see what happes
        try:
            dataset = self._load_and_parse_file(fname)
        except InvalidIESProfileException as msg:
            self.warn("Failed to load profile from", filename, ":", msg)
            return -1

        if not dataset:
            return -1

        # Dataset was loaded successfully, now copy it
        dataset.generate_dataset_texture_into(self._storage_tex, len(self._entries))
        self._entries.append(fname)

        return len(self._entries) - 1
开发者ID:ELMERzark,项目名称:RenderPipeline,代码行数:41,代码来源:ies_profile_loader.py

示例15: mount

    def mount(self):
        """ Inits the VFS Mounts """

        self.debug("Setting up virtual filesystem.")
        vfs = VirtualFileSystem.getGlobalPtr()

        # Mount shaders
        vfs.mountLoop(
            join(self.basePath, 'Shader'), 'Shader', 0)

        # Mount data
        vfs.mountLoop(join(self.basePath, 'Data'), 'Data', 0)

        # TODO: Mount core

        if not isdir(self.writePath):
            self.debug("Creating temp path, as it does not exist yet")
            try:
                makedirs(self.writePath)
            except Exception, msg:
                self.error("Failed to create temp path:",msg)
                import sys
                sys.exit(0)
开发者ID:Happy-Ferret,项目名称:RenderPipeline,代码行数:23,代码来源:MountManager.py


注:本文中的panda3d.core.VirtualFileSystem类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。