Exemplo n.º 1
0
    def getAllPackages(self, includeAllPlatforms=False):
        """ Returns a list of all available packages provided by this
        host. """

        result = []

        items = sorted(self.packages.items())
        for key, platforms in items:
            if self.perPlatform or includeAllPlatforms:
                # If we maintain a different answer per platform,
                # return all of them.
                pitems = sorted(platforms.items())
                for pkey, package in pitems:
                    result.append(package)
            else:
                # If we maintain a host for the current platform
                # only (e.g. a client copy), then return only the
                # current platform, or no particular platform.
                package = platforms.get(PandaSystem.getPlatform(), None)
                if not package:
                    package = platforms.get("", None)

                if package:
                    result.append(package)

        return result
Exemplo n.º 2
0
    def getAllPackages(self, includeAllPlatforms = False):
        """ Returns a list of all available packages provided by this
        host. """

        result = []

        items = sorted(self.packages.items())
        for key, platforms in items:
            if self.perPlatform or includeAllPlatforms:
                # If we maintain a different answer per platform,
                # return all of them.
                pitems = sorted(platforms.items())
                for pkey, package in pitems:
                    result.append(package)
            else:
                # If we maintain a host for the current platform
                # only (e.g. a client copy), then return only the
                # current platform, or no particular platform.
                package = platforms.get(PandaSystem.getPlatform(), None)
                if not package:
                    package = platforms.get(None, None)

                if package:
                    result.append(package)

        return result
Exemplo n.º 3
0
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
Exemplo n.º 4
0
    def run(self):
        """Starts the main loop of the application."""

        if PandaSystem.getPlatform() == 'emscripten':
            return

        # Set the clock to have last frame's time in case we were
        # Paused at the prompt for a long time
        t = self.globalClock.getFrameTime()
        timeDelta = t - self.globalClock.getRealTime()
        self.globalClock.setRealTime(t)
        self.messenger.send("resetClock", [timeDelta])

        if self.taskMgr.resumeFunc != None:
            self.taskMgr.resumeFunc()

        if self.taskMgr.stepping:
            self.doRunFrame()
        else:
            self.taskMgr.running = True
            while self.taskMgr.running:
                try:
                    self.doRunFrame()
                except KeyboardInterrupt:
                    self.taskMgr.stop()
                except SystemError:
                    self.taskMgr.stop()
                    raise
                except IOError as ioError:
                    code, _ = self.taskMgr.unpackIOError(ioError)
                    # Since upgrading to Python 2.4.1, pausing the execution
                    # often gives this IOError during the sleep function:
                    #     IOError: [Errno 4] Interrupted function call
                    # So, let's just handle that specific exception and stop.
                    # All other IOErrors should still get raised.
                    # Only problem: legit IOError 4s will be obfuscated.
                    if code == 4:
                        self.taskMgr.stop()
                    else:
                        raise
                except Exception as e:
                    if self.taskMgr.extendedExceptions:
                        self.taskMgr.stop()
                        Task.print_exc_plus()
                    else:
                        if (ExceptionVarDump.wantStackDumpLog
                                and ExceptionVarDump.dumpOnExceptionInit):
                            ExceptionVarDump._varDump__print(e)
                        raise
                except:
                    if self.taskMgr.extendedExceptions:
                        self.taskMgr.stop()
                        Task.print_exc_plus()
                    else:
                        raise

        self.taskMgr.mgr.stopThreads()
Exemplo n.º 5
0
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
def get_output_name():
    """ Returns the name of the output dir, depending on the system architecture """
    compiler_suffix = ""
    if is_windows():
        compiler_suffix = "_" + get_panda_mscv_version().suffix

    version_suffix = "panda" + PandaSystem.get_version_string()

    return PandaSystem.getPlatform().lower() + "_{}_py{}{}{}".format(
        version_suffix, sys.version_info.major, sys.version_info.minor,
        compiler_suffix)
Exemplo n.º 7
0
    def analyze(self):
        """ Analyzes the user system. This should help debugging when the user
        shares his log. """
        print "System analyzer:"

        def stat(name, *args):
            print " ", str(name).ljust(20, " "), "=", ''.join([str(i) for i in args])

        stat("System", sys.platform, " / ", os.name)
        stat("Bitness", 8 * struct.calcsize("P"))
        stat("Panda3D-Build Date", PandaSystem.getBuildDate())
        stat("Panda3D-Compiler", PandaSystem.getCompiler())
        stat("Panda3D-Distributor", PandaSystem.getDistributor())
        stat("Panda3D-Version", PandaSystem.getVersionString())
        stat("Panda3D-Platform", PandaSystem.getPlatform())
        stat("Panda3D-Official?", PandaSystem.isOfficialVersion())
Exemplo n.º 8
0
    def analyze(self):
        """ Analyzes the user system. This should help debugging when the user
        shares his log. """
        print "System analyzer:"

        def stat(name, *args):
            print " ", str(name).ljust(20, " "), "=", ''.join(
                [str(i) for i in args])

        stat("System", sys.platform, " / ", os.name)
        stat("Bitness", 8 * struct.calcsize("P"))
        stat("Panda3D-Build Date", PandaSystem.getBuildDate())
        stat("Panda3D-Compiler", PandaSystem.getCompiler())
        stat("Panda3D-Distributor", PandaSystem.getDistributor())
        stat("Panda3D-Version", PandaSystem.getVersionString())
        stat("Panda3D-GITCommit", PandaSystem.getGitCommit())
        stat("Panda3D-Platform", PandaSystem.getPlatform())
        stat("Panda3D-Official?", PandaSystem.isOfficialVersion())
Exemplo n.º 9
0
    def getPackage(self, name, version, platform = None):
        """ Returns a PackageInfo that matches the indicated name and
        version and the indicated platform or the current runtime
        platform, if one is provided by this host, or None if not. """

        assert self.hasContentsFile
        platforms = self.packages.get((name, version or None), {})

        if platform is not None:
            # In this case, we are looking for a specific platform
            # only.
            return platforms.get(platform or None, None)

        # We are looking for one matching the current runtime
        # platform.  First, look for a package matching the current
        # platform exactly.
        package = platforms.get(PandaSystem.getPlatform(), None)

        # If not found, look for one matching no particular platform.
        if not package:
            package = platforms.get(None, None)

        return package
Exemplo n.º 10
0
    def getPackage(self, name, version, platform=None):
        """ Returns a PackageInfo that matches the indicated name and
        version and the indicated platform or the current runtime
        platform, if one is provided by this host, or None if not. """

        assert self.hasContentsFile
        platforms = self.packages.get((name, version or ""), {})

        if platform:
            # In this case, we are looking for a specific platform
            # only.
            return platforms.get(platform, None)

        # We are looking for one matching the current runtime
        # platform.  First, look for a package matching the current
        # platform exactly.
        package = platforms.get(PandaSystem.getPlatform(), None)

        # If not found, look for one matching no particular platform.
        if not package:
            package = platforms.get("", None)

        return package
Exemplo n.º 11
0
def get_output_name():
    """ Returns the name of the output dir, depending on the system architecture """
    return PandaSystem.getPlatform().lower() + "_py{}{}".format(
        sys.version_info.major, sys.version_info.minor)
Exemplo n.º 12
0
if not outputDir:
    print('\nYou must name the output directory with the -o parameter.\n')
    sys.exit(1)
if not outputDir.exists():
    print('\nThe specified output directory does not exist!\n')
    sys.exit(1)
elif not outputDir.isDirectory():
    print('\nThe specified output directory is a file!\n')
    sys.exit(1)

if deploy_mode == 'standalone':
    s = Standalone(appFilename, tokens)
    s.basename = shortname

    if currentPlatform:
        platform = PandaSystem.getPlatform()
        if platform.startswith("win"):
            s.build(Filename(outputDir, shortname + ".exe"), platform)
        else:
            s.build(Filename(outputDir, shortname), platform)
    elif len(platforms) == 0:
        s.buildAll(outputDir)
    else:
        for platform in platforms:
            if platform.startswith("win"):
                s.build(
                    Filename(outputDir, platform + "/" + shortname + ".exe"),
                    platform)
            else:
                s.build(Filename(outputDir, platform + "/" + shortname),
                        platform)
Exemplo n.º 13
0
if not outputDir:
    print '\nYou must name the output directory with the -o parameter.\n'
    sys.exit(1)
if not outputDir.exists():
    print '\nThe specified output directory does not exist!\n'
    sys.exit(1)
elif not outputDir.isDirectory():
    print '\nThe specified output directory is a file!\n'
    sys.exit(1)

if deploy_mode == 'standalone':
    s = Standalone(appFilename, tokens)
    s.basename = shortname

    if currentPlatform:
        platform = PandaSystem.getPlatform()
        if platform.startswith("win"):
            s.build(Filename(outputDir, shortname + ".exe"), platform)
        else:
            s.build(Filename(outputDir, shortname), platform)
    elif len(platforms) == 0:
        s.buildAll(outputDir)
    else:
        for platform in platforms:
            if platform.startswith("win"):
                s.build(Filename(outputDir, platform + "/" + shortname + ".exe"), platform)
            else:
                s.build(Filename(outputDir, platform + "/" + shortname), platform)

elif deploy_mode == 'installer':
    if includeRequires: