]> thyrsus.com Git - coverity-submit.git/commitdiff
Drop back to Python 2.
authorEric S. Raymond <esr@thyrsus.com>
Thu, 17 May 2012 03:56:56 +0000 (23:56 -0400)
committerEric S. Raymond <esr@thyrsus.com>
Thu, 17 May 2012 03:56:56 +0000 (23:56 -0400)
Makefile
coverity-submit
coverity-submit.xml

index ecebfa6d3548658b628b479dff82815ace7f1ac4..65629a7434bf3d6540ea43c12b53eab788bc18a8 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -29,6 +29,11 @@ coverity-submit-$(VERS).tar.gz: $(SOURCES) coverity-submit.1
        (cd ..; tar -czf coverity-submit/coverity-submit-$(VERS).tar.gz `cat coverity-submit/MANIFEST`)
        (cd ..; rm coverity-submit-$(VERS))
 
+pychecker:
+       @ln -f coverity-submit coverity-submit.py
+       @-pychecker --only --limit 50 coverity-submit.py
+       @rm -f coverity-submit.py
+
 clean:
        rm -f *.pyc *.html coverity-submit.1 MANIFEST ChangeLog SHIPPER.* *~
 
index 8fc0595a95eeab4f81534c24e8329e491f8b233d..28d0db4e9849fe5dbf1642315af2c996c46ef46a 100755 (executable)
-#!/usr/bin/env python3
+#!/usr/bin/env python
 #
 # coverity-submit - submit project to Coverity for scanning
 #
 # By Eric S. Raymond, May 2012.  BSD terms apply.
 #
-import os, sys, configparser, getopt
+import os, sys, ConfigParser, getopt
 
 version="1.0"
 
-config = configparser.RawConfigParser()
-config.read(os.path.expanduser("~/.coverity-submit"))
-
-def die(complaint):
-    sys.stderr.write(complaint + "\n")
-    sys.exit(1)
-
-# Gather information that is not project-specific
-if not config.defaults():
-    die("A defaults section with 'name' and 'userid' options is required.")
-elif not config.has_option("DEFAULT", "name"):
-    die("A 'name' option is required.")
-elif not config.has_option("DEFAULT", "userid"):
-    die("A 'userid' option is required.")
-name = config.get("DEFAULT", "name")
-userid = config.get("DEFAULT", "userid")
-if config.has_option("DEFAULT", "tools"):
-    tools = config.get("DEFAULT", "tools")
-    os.environ["PATH"] += ":"+tools
-
-# Deduce what project and directory to operate on (and go there).
-noexec = False
-(opts, args) = getopt.getopt(sys.argv[1:], "n")
-for (opt, arg) in opts:
-    if opt == '-n':
-        noexec = True
-where = os.path.basename(os.getcwd())
-if args:
-    project = args[0]
-else:
-    project = where
-if project not in config.sections():
-    die("No such project as %s" % project)
-
-# Collect project-specific variables
-if config.has_option(project, "password"):
-    password = config.get(project, "password")
-else:
-    die("Every project requires a password option.")
-if config.has_option(project, "email"):
-    email = config.get(project, "email")
-elif config.has_option("DEFAULT", "email"):
-    upload = config.get("DEFAULT", "email")
-else:
-    die("Every project requires an email option.")
-if config.has_option(project, "upload"):
-    upload = config.get(project, "upload")
-elif config.has_option("DEFAULT", "upload"):
-    upload = config.get("DEFAULT", "upload")
-else:
-    die("Every project requires an upload option.")
-if config.has_option(project, "advertise"):
-    advertise = config.get(project, "advertise")
-elif config.has_option("DEFAULT", "advertise"):
-    upload = config.get("DEFAULT", "advertise")
-else:
-    die("Every project requires an advertise option.")
-if config.has_option(project, "prebuild"):
-    prebuild = config.get(project, "prebuild")
-else:
-    prebuild = None
-if config.has_option(project, "build"):
-    build = config.get(project, "build")
-else:
-    die("Every project requires a build option.")
-if config.has_option(project, "postbuild"):
-    postbuild = config.get(project, "postbuild")
-else:
-    postbuild = None
-if "%s" not in upload:
-    die("The upload option must contain a %s to plug a tarball name into.")
-if "%s" not in advertise:
-    die("The advertise option must contain a %s to plug a tarball name into.")
-
-def do_or_die(cmd):
-    print(cmd)
+if __name__ == '__main__':
+    name = email = project = password = url = None
+
+    config = ConfigParser.RawConfigParser()
+    config.read(os.path.expanduser("~/.coverity-submit"))
+
+    def die(complaint):
+        sys.stderr.write(complaint + "\n")
+        sys.exit(1)
+
+    # 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.")
+    name = config.get("ALL", "name")
+    userid = config.get("ALL", "userid")
+    if config.has_option("ALL", "tools"):
+        tools = config.get("ALL", "tools")
+        os.environ["PATH"] += ":"+tools
+
+    # Deduce what project and directory to operate on (and go there).
+    noexec = False
+    (opts, args) = getopt.getopt(sys.argv[1:], "n")
+    for (opt, arg) in opts:
+        if opt == '-n':
+            noexec = True
+    where = os.path.basename(os.getcwd())
+    if args:
+        project = args[0]
+    else:
+        project = where
+    if project not in config.sections():
+        die("No such project as %s" % project)
+
+    # Collect project-specific variables
+    if config.has_option(project, "password"):
+        password = config.get(project, "password")
+    else:
+        die("Every project requires a password option.")
+    if config.has_option(project, "email"):
+        email = config.get(project, "email")
+    elif config.has_option("ALL", "email"):
+        upload = config.get("ALL", "email")
+    else:
+        die("Every project requires an email option.")
+    if config.has_option(project, "upload"):
+        upload = config.get(project, "upload")
+    elif config.has_option("ALL", "upload"):
+        upload = config.get("ALL", "upload")
+    else:
+        die("Every project requires an upload option.")
+    if config.has_option(project, "advertise"):
+        advertise = config.get(project, "advertise")
+    elif config.has_option("ALL", "advertise"):
+        advertise = config.get("ALL", "advertise")
+    else:
+        die("Every project requires an advertise option.")
+    if config.has_option(project, "prebuild"):
+        prebuild = config.get(project, "prebuild")
+    else:
+        prebuild = None
+    if config.has_option(project, "build"):
+        build = config.get(project, "build")
+    else:
+        die("Every project requires a build option.")
+    if config.has_option(project, "postbuild"):
+        postbuild = config.get(project, "postbuild")
+    else:
+        postbuild = None
+    if "%s" not in upload:
+        die("The upload option must contain a %s to plug a tarball name into.")
+    if "%s" not in advertise:
+        die("The advertise option must contain a %s to plug a tarball name into.")
+
+    def do_or_die(cmd):
+        print(cmd)
+        if not noexec:
+            if os.system(cmd) != 0:
+                sys.stderr.write("Command failed.\n")
+                sys.exit(1)
+
+    # Announce self
+    print("coverity-submit version %s..." % version)
+
+    # Work around a known bug in environment restoration under cove-build.
+    # Without this, xmlto won't run.
+    os.environ["XML_CATALOG_FILES"] = '/etc/xml/catalog'
+
+    # Build local stuff
+    print("Rebuilding and scanning...")
+    if prebuild:
+        do_or_die(prebuild)
+    do_or_die("rm -fr cov-int && cov-build --dir cov-int " + build)
+    if postbuild:
+        do_or_die(postbuild)
+
+    # Create the tarball
+    print("Bundling up required metadata...")
+    readme = """\
+    Name: %(name)s
+    Email: %(email)s
+    Project: %(project)s
+    Submitted-by: coverity-submit
+    """ % globals()
+    sys.stdout.write(readme)
     if not noexec:
-        if os.system(cmd) != 0:
-            sys.stderr.write("Command failed.\n")
-            sys.exit(1)
-
-# Announce self
-print("coverity-submit version %s..." % version)
-
-# Work around a known bug in environment restoration under cove-build.
-# Without this, xmlto won't run.
-os.environ["XML_CATALOG_FILES"] = '/etc/xml/catalog'
-
-# Build local stuff
-print("Rebuilding and scanning...")
-if prebuild:
-    do_or_die(prebuild)
-do_or_die("rm -fr cov-int && cov-build --dir cov-int " + build)
-if postbuild:
-    do_or_die(postbuild)
-
-# Create the tarball
-print("Bundling up required metadata...")
-readme = """\
-Name: %(name)s
-Email: %(email)s
-Project: %(project)s
-Submitted-by: coverity-submit
-""" % locals()
-sys.stdout.write(readme)
-if not noexec:
-    with open("/tmp/README", "w") as wfp:
-        wfp.write(readme)
-tarball = "%s-scan.tgz" % project
-do_or_die("mv cov-int /tmp; (cd /tmp; tar -czf %s README cov-int; rm -fr cov-int)" % tarball)
-
-print("Uploading to where it's publicly visible...")
-do_or_die(upload % ("/tmp/" + tarball))
-url = (advertise % tarball)
-
-print("Posting the analysis request...")
-do_or_die('''curl --data \
- "project=%(project)s&password=%(password)s&email=%(email)s&url=%(url)s" \
- http://scan5.coverity.com/cgi-bin/submit_build.py
-''' % locals())
-
-print("Done. You'll get mail at %s." % email)
+        with open("/tmp/README", "w") as wfp:
+            wfp.write(readme)
+    tarball = "%s-scan.tgz" % project
+    do_or_die("mv cov-int /tmp; (cd /tmp; tar -czf %s README cov-int; rm -fr cov-int)" % tarball)
+
+    print("Uploading to where it's publicly visible...")
+    do_or_die(upload % ("/tmp/" + tarball))
+    url = (advertise % tarball)
+
+    print("Posting the analysis request...")
+    do_or_die('''curl --data \
+     "project=%(project)s&password=%(password)s&email=%(email)s&url=%(url)s" \
+     http://scan5.coverity.com/cgi-bin/submit_build.py
+    ''' % globals())
+
+    print("Done. You'll get mail at %s." % email)
 
 # The following sets edit modes for GNU EMACS
 # Local Variables:
index a13a740a05de96363719ad6f8b79d4d6fec9627b..d1c6276b75c392d79330fe40c7461f1741829d36 100644 (file)
@@ -44,26 +44,28 @@ request status.</para>
 configuration file is best explained by example.</para>
 
 <programlisting>
-[DEFAULT]
-       name=Eric S. Raymond
-       userid=esr
-       email=esr@thyrsus.com
-       tools=/usr/local/coverity/bin
-       upload=scp %s esr@login.ibiblio.org:/public/html/catb/esr
-       advertise=http://catb.org/~esr/%s
+[ALL]
+name: Eric S. Raymond
+userid: esr
+email: esr@thyrsus.com
+tools: /usr/local/coverity/bin
+upload: scp %s esr@login.ibiblio.org:/public/html/catb/esr
+advertise: http://catb.org/~esr/%s
+
 [gpsd]
-       password=XXXXXX
-       prebuild=scons -c
-       build=scons
-       postbuild=
+password: XXXXXX
+prebuild: scons -c
+build: scons
+postbuild: 
+
 [giflib]
-       password=YYYYYYY
-       prebuild=autogen.sh &amp;&amp; make clean
-       build=make -k
-       postbuild=
+password: YYYYYYY
+prebuild: autogen.sh &amp;&amp; make clean
+build: make -k
+postbuild: 
 </programlisting>
 
-<para>Begin with a [DEFAULT] section giving your name and userid on the
+<para>Begin with an [ALL] section giving your name and userid on the
 Coverity server. 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>
@@ -118,7 +120,7 @@ server's HTML response.</para>
 </refsect1>
 <refsect1><title>PREREQUISITES</title>
 
-<para>Requires Python 3, curl, and cov-build.</para>
+<para>Requires Python, curl, and cov-build.</para>
 
 </refsect1>
 <refsect1 id='maintainer'><title>AUTHOR</title>