3 Replies Latest reply: Oct 15, 2013 8:58 AM by Gregg Leventhal RSS

Python WS Script to get server info (v4)

Asya Kamsky Coverity Ninja
Currently Being Moderated

Originally published on 2012-02-02 16:24


This script uses base classes posted Python base classes for v4/Integrity Manager 5.5 web services sample scripts It requires only base server options and it connects to the server to fetch commit port information as well as database URL.


from WebService import WSOpts

from ConfigService import ConfigServiceClient
import sys

def main():
    wsOpts = WSOpts()
    parser = wsOpts.get_common_opts()

    (options, args) = parser.parse_args()

    if wsOpts.checkRequiredMissing(options, ()):


    configServiceClient = ConfigServiceClient(options)

# -----------------------------------------------------------------------------
if __name__ == '__main__':


Note that it uses wsOpts.setLogging() to set the logging level based on --debug flag being passed to the script or not.


It also calls wsOpts.checkRequiredMissing(options, () ) passing in an empty tuple to indicate that it doesn't require any options in addition to base required server connection and authentication options.


Sample output:


$ python serverInfo.py -r 8553
INFO:root:DB port is 5551
INFO:root:Commit port is   9595


Recall that -r is short for --response-file option and 8553 is a file I have in the local directory which contains the values of --host, --port, --user and --password options.


Here is the same script run with --debug option.


$ python serverInfo.py -r 8553 --debug
DEBUG:root:Logging level set to
DEBUG:root:Logging level set to
   commitPort = 9595
   dbDialect = "org.hibernate.dialect.PostgreSQLDialect"
   dbDriver = "org.postgresql.Driver"
   maindbName = "cim"
   maindbUrl = "jdbc:postgresql://localhost:5551/cim"
   maindbUser = "coverity"
INFO:root:DB port is 5551
INFO:root:Commit port is   9595
  • Re: Python WS Script to get server info (v4)
    Gregg Leventhal Contributor
    Currently Being Moderated


    How do I allow a Python script to be run by simply pressing a button within the Coverity Web interface?

    • Re: Python WS Script to get server info (v4)
      Jon Jarboe Moderator
      Currently Being Moderated

      There is an "Export" button available, that is visible when a script is present in the correct place in the server installation (specifically, in the <cc_install_directory>/bin directory).  On Windows, the script should be called "export-defect-handler.bat"; on other platforms, "export-defect-handler" (with execute permissions).


      Typically, you will configure that file to run the Python script with the appropriate command line arguments.  There should be an example in your installation, called "export-defect-handler[.bat].disabled".  The Platform Administrator's guide covers the export handler in more detail.


      Note that the server itself typically runs under a specific account, and that account will need to be able to execute the script.  You might need additional permissions.  For example, on Windows there might be additional restrictions placed on the script by the service control manager or system policy.

More Like This

  • Retrieving data ...