How to use the panda3d.core.Filename function in Panda3D

To help you get started, we’ve selected a few Panda3D examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github panda3d / panda3d / direct / src / p3d / DeploymentTools.py View on Github external
def buildDEB(self, output, platform):
        """ Builds a .deb archive and stores it in the path indicated
        by the 'output' argument. It will be built for the architecture
        specified by the 'arch' argument.
        If 'output' is a directory, the deb file will be stored in it. """

        arch = platform.rsplit("_", 1)[-1]
        output = Filename(output)
        if output.isDirectory():
            output = Filename(output, "%s_%s_%s.deb" % (self.shortname.lower(), self.version, arch))
        Installer.notify.info("Creating %s..." % output)
        modtime = int(time.time())

        # Create a temporary directory and write the launcher and dependencies to it.
        tempdir, totsize = self.__buildTempLinux(platform)

        # Create a control file in memory.
        controlfile = BytesIO()
        if sys.version_info >= (3, 0):
            cout = TextIOWrapper(controlfile, encoding='utf-8', newline='')
        else:
            cout = StringIO()

        cout.write("Package: %s\n" % self.shortname.lower())
        cout.write("Version: %s\n" % self.version)
        cout.write("Maintainer: %s <%s>\n" % (self.authorname, self.authoremail))
github panda3d / panda3d / direct / src / p3d / ppatcher.py View on Github external
installDir = None
for opt, arg in opts:
    if opt == '-i':
        installDir = Filename.fromOsSpecific(arg)

    elif opt == '-h':
        usage(0)
    else:
        print('illegal option: ' + arg)
        sys.exit(1)

packageNames = args

if not installDir:
    installDir = Filename('install')

if not packageNames:
    # "None" means all packages.
    packageNames = None

pm = PatchMaker(installDir)
pm.buildPatches(packageNames = packageNames)

# An explicit call to exit() is required to exit the program, when
# this module is packaged in a p3d file.
sys.exit(0)
github hubertgrzeskowiak / Azure--Infinite-Skies / azure / controls / controlstate.py View on Github external
from ConfigParser import SafeConfigParser, NoSectionError

from direct.showbase.DirectObject import DirectObject
from panda3d.core import Filename
from panda3d.core import ExecutionEnvironment as EE
from direct.directnotify.DirectNotify import DirectNotify

# TODO: declare private attributes and outsource some functions
class ControlState(DirectObject):
    """Specific control state classes should inherit from this."""
    conf_parser = SafeConfigParser()
    f = Filename(EE.expandString("$MAIN_DIR/etc/keybindings.ini"))
    conf_parser.read(f.toOsSpecific())

    @classmethod
    def reloadKeybindings(cls, filenames="etc/keybindings.ini"):
        """Read the keybindings file again. Existing instances won't update
        until you call loadKeybindings() on them."""
        cls.conf_parser.read(filenames)

    def __init__(self):
        self.name = self.__class__.__name__
        self.paused = False
        self.active = False
        self.keymap = {}
        self.functionmap = {}
        self.requested_actions = set()
github panda3d / panda3d / direct / src / p3d / DeploymentTools.py View on Github external
plist.write('\t\n')
        plist.write('\tIFPkgDescriptionTitle\n')
        plist.write('\t%s\n' % self.fullname)
        plist.write('\n')
        plist.write('\n')
        plist.close()

        # OS X El Capitan no longer accepts .pax archives - it must be a CPIO archive named .pax.
        archive = gzip.open(Filename(output, "Contents/Archive.pax.gz").toOsSpecific(), 'wb')
        self.__ino = 0
        self.__writeCPIO(archive, appfn, appname)
        archive.write(b"0707070000000000000000000000000000000000010000000000000000000001300000000000TRAILER!!!\0")
        archive.close()

        # Put the .pkg into a zipfile
        zip_fn = Filename(output.getDirname(), "%s %s.pkg.zip" % (self.fullname, self.version))
        dir = Filename(output.getDirname())
        dir.makeAbsolute()
        zip = zipfile.ZipFile(zip_fn.toOsSpecific(), 'w')
        for root, dirs, files in self.os_walk(output.toOsSpecific()):
            for name in files:
                file = Filename.fromOsSpecific(os.path.join(root, name))
                file.makeAbsolute()
                file.makeRelativeTo(dir)
                zip.write(os.path.join(root, name), str(file))
        zip.close()

        return output
github panda3d / panda3d / direct / src / p3d / HostInfo.py View on Github external
# same hostname), there will be minimal redownloading.

        hashSize = 16
        keepHash = hashSize
        if hostname:
            hostDir += hostname + '_'

            # If we successfully got a hostname, we don't really need the
            # full hash.  We'll keep half of it.
            keepHash = keepHash / 2;

        md = HashVal()
        md.hashString(hostUrl)
        hostDir += md.asHex()[:keepHash * 2]

        hostDir = Filename(self.rootDir, hostDir)
        return hostDir
github tobspr / RenderPipeline / rpcore / mount_manager.py View on Github external
def convert_path(pth):
            return Filename.from_os_specific(pth).get_fullpath()
        vfs = VirtualFileSystem.get_global_ptr()
github panda3d / panda3d / direct / src / p3d / DeploymentTools.py View on Github external
# Add an image file to /usr/share/pixmaps/
        iconFile = None
        if self.icon is not None:
            iconImage = None
            if 48 in self.icon.images:
                iconImage = self.icon.images[48]
            elif 64 in self.icon.images:
                iconImage = self.icon.images[64]
            elif 32 in self.icon.images:
                iconImage = self.icon.images[32]
            else:
                Installer.notify.warning("No suitable icon image for Linux provided, should preferably be 48x48 in size")

            if iconImage is not None:
                iconFile = Filename(tempdir, "usr/share/pixmaps/%s.png" % self.shortname)
                iconFile.setBinary()
                iconFile.makeDir()
                if not iconImage.write(iconFile):
                    Installer.notify.warning("Failed to write icon file for Linux")
                    iconFile.unlink()
                    iconFile = None

        # Write a .desktop file to /usr/share/applications/
        desktopFile = Filename(tempdir, "usr/share/applications/%s.desktop" % self.shortname.lower())
        desktopFile.setText()
        desktopFile.makeDir()
        desktop = open(desktopFile.toOsSpecific(), 'w')
        desktop.write("[Desktop Entry]\n")
        desktop.write("Name=%s\n" % self.fullname)
        desktop.write("Exec=%s\n" % self.shortname.lower())
        if iconFile is not None:
github panda3d / panda3d / direct / src / showbase / VFSImporter.py View on Github external
# first.
        if hasattr(vfile, 'getMount') and \
           isinstance(vfile.getMount(), VirtualFileMountSystem):
            # It's a real file.
            filename = self.filename
        elif self.filename.exists():
            # It's a virtual file, but it's shadowing a real file in
            # the same directory.  Assume they're the same, and load
            # the real one.
            filename = self.filename
        else:
            # It's a virtual file with no real-world existence.  Dump
            # it to disk.  TODO: clean up this filename.
            filename = Filename.temporary('', self.filename.getBasenameWoExtension(),
                                          '.' + self.filename.getExtension(),
                                          type = Filename.TDso)
            filename.setExtension(self.filename.getExtension())
            filename.setBinary()
            sin = vfile.openReadFile(True)
            sout = OFileStream()
            if not filename.openWrite(sout):
                raise IOError
            if not copyStream(sin, sout):
                raise IOError
            vfile.closeReadFile(sin)
            del sout

        module = imp.load_module(fullname, None, filename.toOsSpecific(),
                                 self.desc)
        module.__file__ = self.filename.toOsSpecific()
        return module
github panda3d / panda3d / direct / src / p3d / FileSpec.py View on Github external
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 = st.st_mtime

        self.readHash(pathname)
github panda3d / panda3d / direct / src / p3d / DeploymentTools.py View on Github external
plist.write('\tpkmk-token-2\n')
        plist.write('\t\n')
        plist.write('\t\t\n')
        plist.write('\t\t\tidentifier\n')
        plist.write('\t\t\t%s.%s\n' % (self.authorid, self.shortname))
        plist.write('\t\t\tpath\n')
        plist.write('\t\t\t%s\n' % appname)
        plist.write('\t\t\tsearchPlugin\n')
        plist.write('\t\t\tCommonAppSearch\n')
        plist.write('\t\t\n')
        plist.write('\t\n')
        plist.write('\n')
        plist.write('\n')
        plist.close()

        plist = open(Filename(output, "Contents/Resources/en.lproj/Description.plist").toOsSpecific(), "w")
        plist.write('\n')
        plist.write('\n')
        plist.write('\n')
        plist.write('\n')
        plist.write('\tIFPkgDescriptionDescription\n')
        plist.write('\t\n')
        plist.write('\tIFPkgDescriptionTitle\n')
        plist.write('\t%s\n' % self.fullname)
        plist.write('\n')
        plist.write('\n')
        plist.close()

        # OS X El Capitan no longer accepts .pax archives - it must be a CPIO archive named .pax.
        archive = gzip.open(Filename(output, "Contents/Archive.pax.gz").toOsSpecific(), 'wb')
        self.__ino = 0
        self.__writeCPIO(archive, appfn, appname)