How to use the panda3d.core.Filename.fromOsSpecific 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 / pdeploy.py View on Github external
omitDefaultCheckboxes = False

try:
    opts, args = getopt.getopt(sys.argv[1:], 'n:N:v:o:t:P:csOl:L:a:A:e:i:h')
except getopt.error, msg:
    usage(1, msg or 'Invalid option')

for opt, arg in opts:
    if opt == '-n':
        shortname = arg.strip()
    elif opt == '-N':
        fullname = arg.strip()
    elif opt == '-v':
        version = arg.strip()
    elif opt == '-o':
        outputDir = Filename.fromOsSpecific(arg)
    elif opt == '-t':
        token = arg.strip().split("=", 1)
        tokens[token[0]] = token[1]
    elif opt == '-P':
        platforms.append(arg)
    elif opt == '-c':
        currentPlatform = True
    elif opt == '-s':
        includeRequires = True
    elif opt == '-O':
        omitDefaultCheckboxes = True
    elif opt == '-l':
        licensename = arg.strip()
    elif opt == '-L':
        licensefile = Filename.fromOsSpecific(arg)
    elif opt == '-a':
github panda3d / panda3d / direct / src / p3d / pmerge.py View on Github external
def usage(code, msg = ''):
    sys.stderr.write(usageText % {'prog' : os.path.split(sys.argv[0])[1]})
    sys.stderr.write(msg + '\n')
    sys.exit(code)

try:
    opts, args = getopt.getopt(sys.argv[1:], 'i:p:h')
except getopt.error as msg:
    usage(1, msg)

installDir = None
packageNames = []
for opt, arg in opts:
    if opt == '-i':
        installDir = Filename.fromOsSpecific(arg)
    elif opt == '-p':
        packageNames += arg.split(',')

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

if not packageNames:
    # No package names means allow all packages.
    packageNames = None

inputDirs = []
for arg in args:
    inputDirs.append(Filename.fromOsSpecific(arg))
github fireclawthefox / panda3d-tutorial / P3D Tutorial / game / main.py View on Github external
"audio-sfx-active": "#t" if ConfigVariableBool("audio-sfx-active").getValue() else "#f",
            # logging
            "notify-output": os.path.join(basedir, "game.log"),
            # window
            "framebuffer-multisample": "#t" if ConfigVariableBool("framebuffer-multisample").getValue() else "#f",
            "multisamples": str(ConfigVariableInt("multisamples", 8).getValue()),
            "texture-anisotropic-degree": str(ConfigVariableInt("texture-anisotropic-degree").getValue()),
            "textures-auto-power-2": "#t" if ConfigVariableBool("textures-auto-power-2", True).getValue() else "#f",
            }

        page = None
        # Check if we have an existing configuration file
        if os.path.exists(prcFile):
            # open the config file and change values according to current
            # application settings
            page = loadPrcFile(Filename.fromOsSpecific(prcFile))
            removeDecls = []
            for dec in range(page.getNumDeclarations()):
                # Check if our variables are given.
                # NOTE: This check has to be done to not loose our base or other
                #       manual config changes by the user
                if page.getVariableName(dec) in configVariables.keys():
                    removeDecls.append(page.modifyDeclaration(dec))
            for dec in removeDecls:
                page.deleteDeclaration(dec)
        else:
            # Create a config file and set default values
            cpMgr = ConfigPageManager.getGlobalPtr()
            page = cpMgr.makeExplicitPage("Application Config")

        # always write custom configurations
        for key, value in configVariables.items():
github panda3d / panda3d / direct / src / p3d / DeploymentTools.py View on Github external
nsi.write('!insertmacro MUI_UNPAGE_INSTFILES\n')
        nsi.write('!insertmacro MUI_UNPAGE_FINISH\n')
        nsi.write('!insertmacro MUI_LANGUAGE "English"\n')

        # This section defines the installer.
        nsi.write('Section "" SecCore\n')
        nsi.write('  SetOutPath "$INSTDIR"\n')
        nsi.write('  File "%s"\n' % exefile.toOsSpecific())
        if icofile is not None:
            nsi.write('  File "%s"\n' % icofile.toOsSpecific())
        for f in extrafiles:
            nsi.write('  File "%s"\n' % f.toOsSpecific())
        curdir = ""
        for root, dirs, files in self.os_walk(hostDir.toOsSpecific()):
            for name in files:
                basefile = Filename.fromOsSpecific(os.path.join(root, name))
                file = Filename(basefile)
                file.makeAbsolute()
                file.makeRelativeTo(hostDir)
                outdir = file.getDirname().replace('/', '\\')
                if curdir != outdir:
                    nsi.write('  SetOutPath "$INSTDIR\\%s"\n' % outdir)
                    curdir = outdir
                nsi.write('  File "%s"\n' % (basefile.toOsSpecific()))
        nsi.write('  SetOutPath "$INSTDIR"\n')
        nsi.write('  WriteUninstaller "$INSTDIR\\Uninstall.exe"\n')
        nsi.write('  ; Start menu items\n')
        nsi.write('  !insertmacro MUI_STARTMENU_WRITE_BEGIN Application\n')
        nsi.write('    CreateDirectory "$SMPROGRAMS\\$StartMenuFolder"\n')
        if icofile is None:
            nsi.write('    CreateShortCut "$SMPROGRAMS\\$StartMenuFolder\\%s.lnk" "$INSTDIR\\%s.exe"\n' % (self.fullname, self.shortname))
        else:
github panda3d / panda3d / direct / src / stdpy / file.py View on Github external
raw = StreamIOWrapper(file)
        raw.mode = mode

    else:
        vfile = None

        if isinstance(file, core.VirtualFile):
            # We can also "open" a VirtualFile object for reading.
            vfile = file
            filename = vfile.getFilename()
        elif isinstance(file, unicodeType):
            # If a raw string is given, assume it's an os-specific
            # filename.
            filename = core.Filename.fromOsSpecificW(file)
        elif isinstance(file, strType):
            filename = core.Filename.fromOsSpecific(file)
        else:
            # It's either a Filename object or an os.PathLike.
            # If a Filename is given, make a writable copy anyway.
            filename = core.Filename(file)

        if binary or sys.version_info >= (3, 0):
            filename.setBinary()
        else:
            filename.setText()

        if not vfile:
            vfile = _vfs.getFile(filename)

        if not vfile:
            if reading:
                raise FileNotFoundError("No such file or directory: '%s'" % (filename))
github fireclawthefox / DirectGuiDesigner / DirectGuiDesigner.py View on Github external
#show-frame-rate-meter #t
    #want-pstats #t
    """)

# check if we have a config file
home = os.path.expanduser("~")


logfile = os.path.join(home, "DirectGuiDesigner.log")
handler = TimedRotatingFileHandler(logfile)
logging.basicConfig(
    level=logging.DEBUG,
    handlers=[handler])
prcFileName = os.path.join(home, ".DirectGuiDesigner.prc")
if os.path.exists(prcFileName):
    loadPrcFile(Filename.fromOsSpecific(prcFileName))

    # make sure to load our custom paths
    pathsConfig = ConfigVariableSearchPath("custom-model-path", "").getValue()
    for path in pathsConfig.getDirectories():
        line = "model-path {}".format(str(path))
        print(str(path))
        loadPrcFileData("", line)
else:
    with open(prcFileName, "w") as prcFile:
        prcFile.write("skip-ask-for-quit #f\n")
        prcFile.write("create-executable-scripts #f\n")
        prcFile.write("show-toolbar #t\n")

    #if platform.system() == "Windows":
    #    from ctypes import WinDLL
    #    from stat import FILE_ATTRIBUTE_HIDDEN
github panda3d / panda3d / direct / src / stdpy / file.py View on Github external
def listdir(path):
    """ Implements os.listdir over vfs. """
    files = []
    dirlist = _vfs.scanDirectory(core.Filename.fromOsSpecific(path))
    if dirlist is None:
        raise OSError("No such file or directory: '%s'" % (path))

    for file in dirlist:
        files.append(file.getFilename().getBasename())
    return files
github sccn / SNAP / src / launcher.py View on Github external
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:
    loadPrcFileData('', 'win-origin ' + opts.windoworigin.replace('/',' '))
if opts.noborder is not None: