Package inca :: Module VersionReporter :: Class VersionReporter
[hide private]
[frames] | no frames]

Class VersionReporter

source code

Reporter.Reporter --+
                    |
                   VersionReporter

VersionReporter - Convenience module for creating version reporters:

 from inca.VersionReporter import VersionReporter
 reporter = VersionReporter()
 command = 'somecommand -version'
 pattern = '^version "(.*)"'
 ...
 reporter.setPackageName('packageX')
 reporter.setVersionByExecutable(command, pattern)
 reporter.printReporter()

 or

 reporter.setVersionByGptQuery('packageX')

 or

 reporter.setVersionByRpmQuery('packageX')

 or

 reporter->setPackageVersion('x.x.x')

 or

 for subpackage in subpackages:
   reporter.setSubpackageVersion(subpackage, version)

This module is a subclass of Reporter that provides convenience methods for creating version reporters. A version reporter reports this version information for a package in the following schema (i.e., this is the body of the Inca report):

 <packageVersion>
   <ID>packageX</ID>
   <version>x.x.x</version>
 </packageVersion>

 or

 <packageVersion>
   <ID>packageX</ID>
   <subpackage>
     <ID>subpackageX</ID>
     <version>x.x.x</version>
   </subpackage>
   <subpackage>
     <ID>subpackageY</ID>
     <version>x.x.x</version>
   </subpackage>
 </packageVersion>

Version information can be set using one of the basic methods setPackageVersion (for the first example) or setSubpackageVersion (for the second). In this case, the user retrieves a package's version information directly and uses one of these two methods to report it. This module also provides convenience methods that retrieve a package version using conventional methods of querying version information.

Instance Methods [hide private]
 
__init__(self, **attributes)
Class constructor that returns a new VersionReporter object.
source code
 
getPackageName(self)
Returns the name of the package.
source code
 
getPackageVersion(self)
Returns the version of the package.
source code
 
getSubpackageNames(self)
Returns a list of all the names of all subpackages with a set version.
source code
 
getSubpackageVersion(self, name)
Returns the version of subpackage name.
source code
 
reportBody(self)
Constructs and returns the body of the reporter.
source code
 
setPackageName(self, name)
Set the name of the package.
source code
 
setPackageVersion(self, version)
Report the version of a package as version.
source code
 
setSubpackageVersion(self, name, version)
Report the version of subpackage name as version.
source code
 
setVersionByCompiledProgramOutput(self, **attrs)
Retrieve the package version by compiling and running a program and matching its output against a pattern.
source code
 
setVersionByExecutable(self, command, pattern=None, timeout=None)
Retrieve package version information by executing command and greping the output for pattern.
source code
 
setVersionByFileContents(self, path, pattern=None)
Retrieve the package version by grep'ing the file path for pattern.
source code
 
setVersionByGptQuery(self, *prefixes)
Set subpackage version information by querying GPT for packages prefixed with any element of prefixes.
source code
 
setVersionByRpmQuery(self, pattern)
Set subpackage version information by querying GPT for packages that contain the regular expression pattern.
source code

Inherited from Reporter.Reporter: __del__, addArg, addDependency, argValue, argValues, compiledProgramOutput, compiledProgramStatusOutput, failPrintAndExit, getBody, getCompleted, getCwd, getDescription, getFailMessage, getName, getUrl, getVersion, log, loggedCommandOutput, loggedCommandStatusOutput, printReport, processArgv, report, setBody, setCompleted, setCwd, setDescription, setFailMessage, setName, setResult, setUrl, setVersion, tempFile, xmlElement

Method Details [hide private]

__init__(self, **attributes)
(Constructor)

source code 

Class constructor that returns a new VersionReporter object. The constructor supports the following parameters in addition to those supported by Reporter:

 package_name
   the name of the package for which a version is being determined;
   default ''.

 package_version
   the version of the package.
Overrides: Reporter.Reporter.__init__

reportBody(self)

source code 

Constructs and returns the body of the reporter.

Overrides: Reporter.Reporter.reportBody

setVersionByCompiledProgramOutput(self, **attrs)

source code 

Retrieve the package version by compiling and running a program and matching its output against a pattern. Returns 1 if successful, else 0. The function recognizes the following parameter in addition to those supported by the compiledProgramOutput method of Reporter:

pattern
  pattern to search for in program output; default '(.+)'

setVersionByExecutable(self, command, pattern=None, timeout=None)

source code 

Retrieve package version information by executing command and greping the output for pattern. command is the executable and argument string to retrieve the version (e.g., command_name -version) and pattern is a pattern containing one grouping (i.e., memory parentheses) to retrieve the version from the output. pattern defaults to '([\d\.]+)' if not specified. Fails if timeout is specified and command does not complete within timeout seconds. Returns 1 if successful, else 0.

setVersionByFileContents(self, path, pattern=None)

source code 

Retrieve the package version by grep'ing the file path for pattern. pattern defaults to '([\d\.]+)' if not specified. Returns 1 if successful, else 0.

setVersionByGptQuery(self, *prefixes)

source code 

Set subpackage version information by querying GPT for packages prefixed with any element of prefixes. Returns 1 if successful, else 0.

setVersionByRpmQuery(self, pattern)

source code 

Set subpackage version information by querying GPT for packages that contain the regular expression pattern. Returns 1 if successful, else 0.