Browse Source

Try to automatically figure out author name / e-mail

rdb 15 years ago
parent
commit
96452aa4f4
2 changed files with 43 additions and 10 deletions
  1. 27 4
      direct/src/p3d/DeploymentTools.py
  2. 16 6
      direct/src/p3d/pdeploy.py

+ 27 - 4
direct/src/p3d/DeploymentTools.py

@@ -4,7 +4,7 @@ to build for as many platforms as possible. """
 
 
 __all__ = ["Standalone", "Installer"]
 __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 cStringIO import StringIO
 from direct.directnotify.DirectNotifyGlobal import *
 from direct.directnotify.DirectNotifyGlobal import *
 from direct.showbase.AppRunnerGlobal import appRunner
 from direct.showbase.AppRunnerGlobal import appRunner
@@ -13,6 +13,10 @@ from pandac.PandaModules import TiXmlDocument, TiXmlDeclaration, TiXmlElement, r
 from direct.p3d.HostInfo import HostInfo
 from direct.p3d.HostInfo import HostInfo
 # This is important for some reason
 # This is important for some reason
 import encodings
 import encodings
+try:
+    import pwd
+except ImportError:
+    pwd = None
 
 
 # Make sure this matches with the magic in p3dEmbed.cxx.
 # Make sure this matches with the magic in p3dEmbed.cxx.
 P3DEMBED_MAGIC = "\xFF\x3D\x3D\x00"
 P3DEMBED_MAGIC = "\xFF\x3D\x3D\x00"
@@ -198,10 +202,29 @@ class Installer:
         self.version = str(version)
         self.version = str(version)
         self.includeRequires = False
         self.includeRequires = False
         self.licensename = ""
         self.licensename = ""
-        self.authorid = "org.panda3d"
-        self.authorname = ""
-        self.authoremail = ""
         self.licensefile = Filename()
         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.standalone = Standalone(p3dfile, tokens)
         self.http = self.standalone.http
         self.http = self.standalone.http
         self.tempDir = Filename.temporary("", self.shortname, "") + "/"
         self.tempDir = Filename.temporary("", self.shortname, "") + "/"

+ 16 - 6
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.
 for every platform, if possible.
 Note that pdeploy requires an internet connection to run.
 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:
 Usage:
 
 
   %(prog)s [opts] app.p3d standalone|installer|html
   %(prog)s [opts] app.p3d standalone|installer|html
@@ -38,8 +42,8 @@ Options:
      If omitted, the basename of the p3d file is used.
      If omitted, the basename of the p3d file is used.
 
 
   -N "Your Application"
   -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.
      If omitted, the short name is used.
 
 
   -v version_number
   -v version_number
@@ -58,8 +62,8 @@ Options:
   -t token=value
   -t token=value
      Defines a web token or parameter to pass to the application.
      Defines a web token or parameter to pass to the application.
      Use this to configure how the application will be run.
      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
   -P platform
      If this option is provided, it should specify a comma-
      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
      Short identifier of the author of the application. The default
      is "org.panda3d", but you will most likely want to change
      is "org.panda3d", but you will most likely want to change
      it to your own name or that of your organization or company.
      it to your own name or that of your organization or company.
+     Only relevant when generating a graphical installer.
 
 
   -A "Your Company"
   -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 "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
   -h
      Display this help
      Display this help