#
# By Eric S. Raymond, May 2012. BSD terms apply.
#
-import os, sys, ConfigParser, getopt, tempfile, shutil, datetime, commands
+import os, pwd, sys, ConfigParser, getopt, tempfile, shutil, datetime, commands
version = "1.10"
return output
return None
+def deduce_name():
+ if 'USERNAME' in os.environ:
+ p=pwd.getpwdnam(os.environ['USERNAME'])
+ elif 'LOGNAME' in os.environ:
+ p=pwd.getpwdnam(os.environ['LOGNAME'])
+ else:
+ return None
+ return p.pw_gecos.split(',')[0]
+
+def deduce_userid():
+ if 'USERNAME' in os.environ:
+ p=pwd.getpwdnam(os.environ['USERNAME'])
+ elif 'LOGNAME' in os.environ:
+ p=pwd.getpwdnam(os.environ['LOGNAME'])
+ else:
+ return None
+ return p.pw_name
+
if __name__ == '__main__':
name = email = project = token = url = None
# Gather information that is not project-specific
if not "ALL" in config.sections():
- die("A defaults section with 'name' and 'userid' options is required.")
- elif not config.has_option("ALL", "name"):
- die("A 'name' option is required.")
- elif not config.has_option("ALL", "userid"):
- die("A 'userid' option is required.")
+ config.add_section("ALL")
+ if not config.has_option("ALL", "name"):
+ config.set("ALL", "name") = deduce_name()
+ if not config.has_option("ALL", "userid"):
+ config.set("ALL", "userid") = deduce_userid()
name = config.get("ALL", "name")
userid = config.get("ALL", "userid")
if config.has_option("ALL", "tools"):
</programlisting>
-<para>Begin with an [ALL] section giving your name and userid on the
-Coverity server. You may specify the email address to which success
+<para>You may begin with an [ALL] section giving your name and userid on the
+Coverity server. If you don't specify these, the tool will use your local
+usename and the first (comma-separated) portion of your GECOS field.</para>
+
+<para>You may specify the email address to which success
or failure notifications should be mailed for all other projects here,
or specify different addresses per-project.</para>