From 96452aa4f4b867a9134021e070315818a5ca3ab6 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 27 Feb 2011 20:22:14 +0000 Subject: [PATCH] Try to automatically figure out author name / e-mail --- direct/src/p3d/DeploymentTools.py | 31 +++++++++++++++++++++++++++---- direct/src/p3d/pdeploy.py | 22 ++++++++++++++++------ 2 files changed, 43 insertions(+), 10 deletions(-) diff --git a/direct/src/p3d/DeploymentTools.py b/direct/src/p3d/DeploymentTools.py index 98b626a1fd..d05ddb8cf6 100644 --- a/direct/src/p3d/DeploymentTools.py +++ b/direct/src/p3d/DeploymentTools.py @@ -4,7 +4,7 @@ to build for as many platforms as possible. """ __all__ = ["Standalone", "Installer"] -import os, sys, subprocess, tarfile, shutil, time, zipfile, glob +import os, sys, subprocess, tarfile, shutil, time, zipfile, glob, socket, getpass from cStringIO import StringIO from direct.directnotify.DirectNotifyGlobal import * from direct.showbase.AppRunnerGlobal import appRunner @@ -13,6 +13,10 @@ from pandac.PandaModules import TiXmlDocument, TiXmlDeclaration, TiXmlElement, r from direct.p3d.HostInfo import HostInfo # This is important for some reason import encodings +try: + import pwd +except ImportError: + pwd = None # Make sure this matches with the magic in p3dEmbed.cxx. P3DEMBED_MAGIC = "\xFF\x3D\x3D\x00" @@ -198,10 +202,29 @@ class Installer: self.version = str(version) self.includeRequires = False self.licensename = "" - self.authorid = "org.panda3d" - self.authorname = "" - self.authoremail = "" self.licensefile = Filename() + self.authorid = "org.panda3d" + self.authorname = os.environ.get("DEBFULLNAME", "") + self.authoremail = os.environ.get("DEBEMAIL", "") + + # Try to determine a default author name ourselves. + uname = None + if pwd is not None and hasattr(os, 'getuid'): + uinfo = pwd.getpwuid(os.getuid()) + if uinfo: + uname = uinfo.pw_name + if not self.authorname: + self.authorname = \ + uinfo.pw_gecos.split(',', 1)[0] + + # Fallbacks in case that didn't work or wasn't supported. + if not uname: + uname = getpass.getuser() + if not self.authorname: + self.authorname = uname + if not self.authoremail and ' ' not in uname: + self.authoremail = "%s@%s" % (uname, socket.gethostname()) + self.standalone = Standalone(p3dfile, tokens) self.http = self.standalone.http self.tempDir = Filename.temporary("", self.shortname, "") + "/" diff --git a/direct/src/p3d/pdeploy.py b/direct/src/p3d/pdeploy.py index d1d58a45db..eebefa3ed3 100644 --- a/direct/src/p3d/pdeploy.py +++ b/direct/src/p3d/pdeploy.py @@ -8,6 +8,10 @@ installer or an HTML webpage. It will attempt to create packages for every platform, if possible. Note that pdeploy requires an internet connection to run. +When used with the 'installer' option, it is strongly advisable +to specify most if not all of the descriptive information that can +be passed on the command-line. + Usage: %(prog)s [opts] app.p3d standalone|installer|html @@ -38,8 +42,8 @@ Options: If omitted, the basename of the p3d file is used. -N "Your Application" - Full name of the application or game. This value will - be used to display to the end-user. + Full name of the application or game. This is the name that + will be displayed to end-user. If omitted, the short name is used. -v version_number @@ -58,8 +62,8 @@ Options: -t token=value Defines a web token or parameter to pass to the application. Use this to configure how the application will be run. - You can pass as many -t options as you need. Examples of - tokens are width, height, log_basename, auto_start, hidden. + You can pass as many -t options as you need. Some examples of + tokens are width, height, log_basename, auto_start and hidden. -P platform If this option is provided, it should specify a comma- @@ -100,12 +104,18 @@ Options: Short identifier of the author of the application. The default is "org.panda3d", but you will most likely want to change it to your own name or that of your organization or company. + Only relevant when generating a graphical installer. -A "Your Company" - Full name of the author of the application. + Full name of the author of the application. The default is + determined from the GECOS information of the current user if + available; if not, your username is used. + Only relevant when generating a graphical installer. -e "you@your_company.com" - E-mail address of the maintainer of the application. + E-mail address of the maintainer of the application. The default + is username@hostname. + Only relevant when generating a graphical installer. -h Display this help