r280 - in tags: . v7-V1-0R21/tools v7-V1-0R21/v7
by gnichols@fedoraproject.org
Author: gnichols
Date: 2009-12-22 18:18:19 +0000 (Tue, 22 Dec 2009)
New Revision: 280
Added:
tags/v7-V1-0R21/
Modified:
tags/v7-V1-0R21/tools/v7-release.py
tags/v7-V1-0R21/v7/version.py
Log:
tag version
Copied: tags/v7-V1-0R21 (from rev 279, trunk)
Modified: tags/v7-V1-0R21/tools/v7-release.py
===================================================================
--- trunk/tools/v7-release.py 2009-12-22 18:09:20 UTC (rev 279)
+++ tags/v7-V1-0R21/tools/v7-release.py 2009-12-22 18:18:19 UTC (rev 280)
@@ -26,9 +26,9 @@
sourceTar = "%s/v7-%s-%s.el%s.tar.bz2" % (buildDir, v7.version.version, v7.version.release, v7.version.rhel_version)
-print "building for RHEL %u" % v7.version.rhel_version
+print "building for RHEL %s" % v7.version.rhel_version
-distSubdir = "RHEL-%u-HWCert" % v7.version.rhel_version
+distSubdir = "RHEL-%s-HWCert" % v7.version.rhel_version
distVersionDir = "%s/%s" % (distDir, distSubdir)
os.chdir(distVersionDir)
@@ -46,7 +46,7 @@
os.system(command)
# build it
-command = "make build COLLECTION=hwcert-%uE" % v7.version.rhel_version
+command = "make build COLLECTION=hwcert-%sE" % v7.version.rhel_version
print command
os.system(command)
Modified: tags/v7-V1-0R21/v7/version.py
===================================================================
--- trunk/v7/version.py 2009-12-22 18:09:20 UTC (rev 279)
+++ tags/v7-V1-0R21/v7/version.py 2009-12-22 18:18:19 UTC (rev 280)
@@ -1,4 +1,5 @@
# v7/version.py is automatically-generated - DO NOT EDIT
version = '1.0'
-release = '20'
+release = '21'
+rhel_version = '5'
14 years, 4 months
r279 - trunk/v7
by gnichols@fedoraproject.org
Author: gnichols
Date: 2009-12-22 18:09:20 +0000 (Tue, 22 Dec 2009)
New Revision: 279
Modified:
trunk/v7/report.py
Log:
484657 - hts uses code deprecated in python 2.6
Modified: trunk/v7/report.py
===================================================================
--- trunk/v7/report.py 2009-12-22 18:02:39 UTC (rev 278)
+++ trunk/v7/report.py 2009-12-22 18:09:20 UTC (rev 279)
@@ -410,7 +410,7 @@
returnValue = 0
for line in log:
contents += line
- m=hashlib.new()
+ m=hashlib.md5()
m.update(contents)
sum=int(m.hexdigest(),16)
# YK: write the decimal format result to output.log, not hex
14 years, 4 months
r278 - trunk
by gnichols@fedoraproject.org
Author: gnichols
Date: 2009-12-22 18:02:39 +0000 (Tue, 22 Dec 2009)
New Revision: 278
Modified:
trunk/v7.spec.in
Log:
change log
Modified: trunk/v7.spec.in
===================================================================
--- trunk/v7.spec.in 2009-12-22 18:01:33 UTC (rev 277)
+++ trunk/v7.spec.in 2009-12-22 18:02:39 UTC (rev 278)
@@ -77,6 +77,7 @@
548517 - v7 plan traceback: no such attribute runForVirtualization
517311 - submit command causes a traceback if no tests have run
536929 - v7 should augment HAL device detection with other sources
+ 484657 - hts uses code deprecated in python 2.6
* Tue Sep 29 2009 Greg Nichols <gnichols(a)redhat.com>
14 years, 4 months
r277 - trunk/tests/memory
by gnichols@fedoraproject.org
Author: gnichols
Date: 2009-12-22 18:01:33 +0000 (Tue, 22 Dec 2009)
New Revision: 277
Modified:
trunk/tests/memory/memory.py
Log:
484657 - hts uses code deprecated in python 2.6
Modified: trunk/tests/memory/memory.py
===================================================================
--- trunk/tests/memory/memory.py 2009-12-22 18:01:07 UTC (rev 276)
+++ trunk/tests/memory/memory.py 2009-12-22 18:01:33 UTC (rev 277)
@@ -21,7 +21,6 @@
import sys
import re
import time
-import popen2
# sys.path.append("/home/gnichols/devel/v7")
from v7.tags import Constants, DeviceClass
@@ -182,7 +181,8 @@
if self.mode == Constants.self:
command = "echo 'Self Test Mode - would have run %s'" % command
for i in range(number):
- pipe.append(popen2.Popen4(command))
+ commandPipe = Command(command).run()
+ pipe.append(Command(command).pipe)
print "Started: process %u pid %u: %s" % (i, pipe[i].pid, command)
sys.stdout.flush()
waiting = True
@@ -191,7 +191,7 @@
for i in range(number):
if pipe[i]:
found = True
- line = pipe[i].fromchild.readline()
+ line = pipe[i].stdout.readline()
if line and len(line) > 1:
print "process %u pid %u: %s" % (i, pipe[i].pid, line)
sys.stdout.flush()
14 years, 4 months
r276 - trunk/tools
by gnichols@fedoraproject.org
Author: gnichols
Date: 2009-12-22 18:01:07 +0000 (Tue, 22 Dec 2009)
New Revision: 276
Modified:
trunk/tools/v7-release.py
Log:
484657 - hts uses code deprecated in python 2.6
Modified: trunk/tools/v7-release.py
===================================================================
--- trunk/tools/v7-release.py 2009-12-22 18:00:19 UTC (rev 275)
+++ trunk/tools/v7-release.py 2009-12-22 18:01:07 UTC (rev 276)
@@ -1,7 +1,7 @@
#!/usr/bin/python
"""
-This script automates submission of HTS to the brew build system
+This script automates submission of v7 to the brew build system
by checking in a new tarball and updated rpm spec file.
To use in a specific development environment, two directories must
@@ -24,51 +24,29 @@
buildDir = "/home/gnichols/build/v7"
distDir = "/home/gnichols/dist/v7"
-sourceTar = "%s/v7-%s-%s.tar.bz2" % (buildDir, v7.version.version, v7.version.release)
-for rhelVersion in [4, 5]:
- print "building for RHEL %u" % rhelVersion
+sourceTar = "%s/v7-%s-%s.el%s.tar.bz2" % (buildDir, v7.version.version, v7.version.release, v7.version.rhel_version)
- distSubdir = "RHEL-%u-HWCert" % rhelVersion
- distVersionDir = "%s/%s" % (distDir, distSubdir)
- os.chdir(distVersionDir)
+print "building for RHEL %u" % v7.version.rhel_version
- # copy tarball
- destTar = "v7-%s-%s.el%u.tar.bz2" % (v7.version.version, v7.version.release, rhelVersion)
- shutil.copy(sourceTar, destTar)
- print "copied %s to %s" % (sourceTar, destTar)
+distSubdir = "RHEL-%u-HWCert" % v7.version.rhel_version
+distVersionDir = "%s/%s" % (distDir, distSubdir)
+os.chdir(distVersionDir)
- # upload the tarball
- command = "make upload FILES=%s" % destTar
- print command
- os.system(command)
-
- # update the v7.spec
- print
- print "editing the v7.spec"
- buildSpec = open("%s/v7.spec" % buildDir)
- distSpec = open("v7.spec", "w")
- while 1:
- line = buildSpec.readline()
- if not line:
- break
- else:
- if "%define release" in line:
- distSpec.write("%%define release %s.el%u" % (v7.version.release, rhelVersion))
- else:
- distSpec.write(line)
- buildSpec.close()
- distSpec.close()
+# upload the tarball
+command = "make upload FILES=%s" % sourceTar
+print command
+os.system(command)
- # commit the new source and spec
- command = "cvs commit -m \"R%s\" . " % v7.version.release
- print command
- os.system(command)
- command = "make tag"
- print command
- os.system(command)
+# commit the new source and spec
+command = "cvs commit -m \"R%s\" . " % v7.version.release
+print command
+os.system(command)
+command = "make tag"
+print command
+os.system(command)
- # build it
- command = "make build COLLECTION=hwcert-%uE" % rhelVersion
- print command
- os.system(command)
+# build it
+command = "make build COLLECTION=hwcert-%uE" % v7.version.rhel_version
+print command
+os.system(command)
14 years, 4 months
r275 - trunk/v7
by gnichols@fedoraproject.org
Author: gnichols
Date: 2009-12-22 18:00:19 +0000 (Tue, 22 Dec 2009)
New Revision: 275
Modified:
trunk/v7/controller.py
Log:
484657 - hts uses code deprecated in python 2.6
Modified: trunk/v7/controller.py
===================================================================
--- trunk/v7/controller.py 2009-12-22 17:59:48 UTC (rev 274)
+++ trunk/v7/controller.py 2009-12-22 18:00:19 UTC (rev 275)
@@ -20,7 +20,6 @@
import syslog
import errno
import tempfile
-import md5
import time
import re
14 years, 4 months
r274 - trunk/v7
by gnichols@fedoraproject.org
Author: gnichols
Date: 2009-12-22 17:59:48 +0000 (Tue, 22 Dec 2009)
New Revision: 274
Modified:
trunk/v7/report.py
Log:
484657 - hts uses code deprecated in python 2.6
Modified: trunk/v7/report.py
===================================================================
--- trunk/v7/report.py 2009-12-22 17:59:18 UTC (rev 273)
+++ trunk/v7/report.py 2009-12-22 17:59:48 UTC (rev 274)
@@ -16,7 +16,7 @@
# The Report object packages and/or presents test results in text, rpm, or html form.
#
-import os,sys,shutil, md5, codecs
+import os,sys,shutil, hashlib, codecs
import string
from v7.tags import Constants, Tags
@@ -410,7 +410,7 @@
returnValue = 0
for line in log:
contents += line
- m=md5.new()
+ m=hashlib.new()
m.update(contents)
sum=int(m.hexdigest(),16)
# YK: write the decimal format result to output.log, not hex
14 years, 4 months
r273 - trunk/v7
by gnichols@fedoraproject.org
Author: gnichols
Date: 2009-12-22 17:59:18 +0000 (Tue, 22 Dec 2009)
New Revision: 273
Modified:
trunk/v7/documentbase.py
Log:
484657 - hts uses code deprecated in python 2.6
Modified: trunk/v7/documentbase.py
===================================================================
--- trunk/v7/documentbase.py 2009-12-22 17:58:48 UTC (rev 272)
+++ trunk/v7/documentbase.py 2009-12-22 17:59:18 UTC (rev 273)
@@ -131,6 +131,7 @@
value = ""
elif type(value) is int:
value = "%u" % value
+ value = self.removeBadCharacters(value)
return element.setAttribute(attribute, value.encode("utf-8"))
def appendDevice(self, device):
14 years, 4 months
r272 - trunk/v7
by gnichols@fedoraproject.org
Author: gnichols
Date: 2009-12-22 17:58:48 +0000 (Tue, 22 Dec 2009)
New Revision: 272
Modified:
trunk/v7/reporthtml.py
Log:
484657 - hts uses code deprecated in python 2.6
Modified: trunk/v7/reporthtml.py
===================================================================
--- trunk/v7/reporthtml.py 2009-12-22 17:58:11 UTC (rev 271)
+++ trunk/v7/reporthtml.py 2009-12-22 17:58:48 UTC (rev 272)
@@ -16,7 +16,7 @@
# The Report object packages and/or presents test results in text, rpm, or html form.
#
-import os,sys,shutil, md5, codecs
+import os,sys,shutil, codecs
import string
from v7.tags import Constants, Tags
14 years, 4 months
r271 - trunk/v7
by gnichols@fedoraproject.org
Author: gnichols
Date: 2009-12-22 17:58:11 +0000 (Tue, 22 Dec 2009)
New Revision: 271
Added:
trunk/v7/command-popen2.py
Log:
484657 - hts uses code deprecated in python 2.6
Added: trunk/v7/command-popen2.py
===================================================================
--- trunk/v7/command-popen2.py (rev 0)
+++ trunk/v7/command-popen2.py 2009-12-22 17:58:11 UTC (rev 271)
@@ -0,0 +1,275 @@
+# Copyright (c) 2006 Red Hat, Inc. All rights reserved. This copyrighted material
+# is made available to anyone wishing to use, modify, copy, or
+# redistribute it subject to the terms and conditions of the GNU General
+# Public License v.2.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# Author: Greg Nichols
+#
+# Overview:
+# The Command class is a wrapper for shell commands that performs
+# validation and error checking. Example usage can be seen in the
+# __main__ self test function at the end of this file.
+
+
+import os,re, commands, exceptions, popen2, string, sys
+
+
+class Command:
+
+ def __init__(self, command):
+ """ Creates a Command object that wraps the shell command
+ via the supplied string, similar to os.system. The
+ constuctor does not actually execute the command.
+ """
+ self.command = command
+ self.regex = None
+ self.singleLine = True
+ self.regexGroup = None
+ self.output = None
+ self.errors = None
+ self.returnValue = 0
+ self.signal = 0
+
+ def _run(self):
+ commandPipe = popen2.Popen3(self.command, capturestderr=True)
+ self.output = commandPipe.fromchild.readlines()
+ result = commandPipe.wait()
+ self.returnValue = (result >> 8) & 0xFF
+ self.signal = result & 0xFF
+ self.errors = None
+
+ if commandPipe.childerr:
+ self.errors = commandPipe.childerr.readlines()
+ # always print error messages
+ for line in self.errors:
+ sys.stderr.write( line )
+ sys.stderr.flush()
+
+ def _checkErrors(self):
+
+ if self.errors and len(self.errors) > 0:
+ raise V7CommandException(self, "has output on stderr")
+ if self.returnValue != 0:
+ # if error returned, show stdout whether echo or run was called
+ for line in self.output:
+ sys.stdout.write( line )
+ sys.stdout.flush()
+ raise V7CommandException(self, "returned %d" % self.returnValue)
+
+ def run(self):
+ """ This method runs the command to produce an action. Any output
+ to stdout is not echoed to the caller. """
+ self._run()
+ self._checkErrors()
+ return 0
+
+
+ def echo(self):
+ """ output is equivalent to run, except that the commands' output
+ is echo'd on stdout. """
+ self._run()
+ self._checkErrors()
+ for line in self.output:
+ sys.stdout.write( line )
+ return 0
+
+ def echoIgnoreErrors(self):
+ """ like echo, except don't raise exception on errors """
+ self._run()
+ for line in self.output:
+ sys.stdout.write( line )
+ return 0
+
+ def printOutput(self):
+ for line in self.output:
+ sys.stdout.write( line )
+ sys.stdout.flush()
+
+ def printErrors(self):
+ for line in self.errors:
+ sys.stderr.write( line )
+ sys.stderr.flush()
+
+
+ def _getString(self, regex=None, regexGroup=None, singleLine=True, returnList=False, ignoreErrors=False):
+ """
+ Get the string from the command's output. With default parameters
+ it returns the command's single line of output as a string.
+
+ If singleLine is True, and multiple lines are found in the output,
+ V7CommandException is raised.
+
+ The regex parameter allows the output to be searched for a regular
+ expression match. If no regexGroup is supplied, the entire pattern
+ match is returned. The regexGroup parameter allows named
+ substrings of the match to be returned if regex has named groups
+ via the "(?P<name>)" syntax. If no match is found,
+ V7CommandException is raised.
+ """
+ self.regex = regex
+ self.singleLine = singleLine
+ self.regexGroup = regexGroup
+
+ self._run()
+
+ if self.singleLine:
+ if len(self.output) > 1:
+ raise V7CommandException(self, "Found %u lines of output, expected 1" % len(self.output))
+
+ line = self.output[0].strip()
+ if not self.regex:
+ return line
+ # otherwise, try the regex
+ pattern = re.compile(self.regex)
+ match = pattern.match(line)
+ if match:
+ if self.regexGroup:
+ return match.group(self.regexGroup)
+ # otherwise, no group, return the whole line
+ return line
+
+ # no regex match try a grep-style match
+ if not self.regexGroup:
+ match = pattern.search(line)
+ if match:
+ return match.group()
+
+ # otherwise
+ raise V7CommandException(self, "no match for regular expression %s" % self.regex)
+
+
+ #otherwise, multi-line or single-line regex
+ if not self.regex:
+ raise V7CommandError(self, "no regular expression set for multi-line command")
+ pattern = re.compile(self.regex)
+ result = None
+ if returnList:
+ result = list()
+ for line in self.output:
+ if self.regexGroup:
+ match = pattern.match(line)
+ if match:
+ if self.regexGroup:
+ if returnList:
+ result.append(match.group(self.regexGroup))
+ else:
+ return match.group(self.regexGroup)
+ else:
+ # otherwise, return the matching line
+ match = pattern.search(line)
+ if match:
+ if returnList:
+ result.append(match.group())
+ else:
+ return match.group()
+ if result:
+ return result
+
+ # otherwise
+ raise V7CommandException(self, "no match for regular expression %s" % self.regex)
+
+ def getStringList(self, regex=None, regexGroup=None, ignoreErrors=False):
+ """ like getString, except return a complete list of matches on multiple lines."""
+ result = self._getString(regex, regexGroup, singleLine=False, returnList=True)
+ if not ignoreErrors:
+ self._checkErrors()
+ return result
+
+ def getString(self, regex=None, regexGroup=None, singleLine=True, ignoreErrors=False):
+ """ like getString, except return a complete list of matches on multiple lines."""
+ result = self._getString(regex, regexGroup, singleLine, returnList=False)
+ if not ignoreErrors:
+ self._checkErrors()
+ return result
+
+
+ def getInteger(self, regex=None, regexGroup=None, singleLine=True):
+ """
+ getInteger is the same as getString, except the output is required to
+ be an Integer.
+ """
+ value = self.getString(regex, regexGroup, singleLine)
+ return string.atoi(value)
+
+class V7CommandException(exceptions.Exception):
+ def __init__(self, command, message):
+ self.message = message
+ self.command = command
+
+ def __str__(self):
+ return "\"%s\" %s" % (self.command.command, self.message)
+
+
+if __name__ == "__main__":
+
+ try:
+ # positive test: run
+ command = Command("ls -a")
+ print "ls -a:"
+ command.run()
+
+ # positive test: simple match
+ command = Command("date")
+ print "is it 2008?"
+ print command.getString("2008")
+
+ # positive test: regex on single line
+ command = Command("date")
+ print "day of the week via date: %s" % command.getString(regex="^(?P<day>[MTWF][a-z]).*$", regexGroup="day")
+
+ # positive test: regex on multiline
+ command = Command("who")
+ print "a device via who: %s" % command.getString(regex="^(?P<user>[a-z]+) (?P<device>[a-z/]+[0-9]*)[ \t]*(?P<date>2008-\d+-\d+).*$", regexGroup="device", singleLine=False)
+
+ #positive test: integer - simple match
+ command = Command("du .")
+ print "simple du: %u" % command.getInteger(regex="\d+", singleLine=False)
+
+ #positive test: integer
+ command = Command("df .")
+ print "blocks via df: %u" % command.getInteger(regex="^[ \t]+(?P<blocks>[0-9]+[ \t]+).*$", regexGroup="blocks", singleLine=False)
+
+ except V7CommandException, e:
+ print e
+
+ # negative test: fail simple match
+ try:
+ print "is it 1999?:"
+ command = Command("date")
+ command.getString(regex="1999")
+ except V7CommandException, e:
+ print e
+
+ # negative test: return value
+ try:
+ print "negative test: return value:"
+ command = Command("exit 1")
+ print "call exit(1)" % command.getString()
+ except V7CommandException, e:
+ print e
+
+ # negative test: expect single line, get multiple
+ try:
+ print "negative test: more than one line of output"
+ command = Command("who")
+ print "who: %s" % command.getString()
+ except V7CommandException, e:
+ print e
+
+ # negative test: expect single line, get multiple
+ try:
+ print "negative test: output on stderr"
+ command = Command("echo \"boguserror\" >&2; echo \"boguserror\"")
+ print "error echo: %s" % command.getString(regex="boguserror", singleLine=False)
+ except V7CommandException, e:
+ print e
+
+
14 years, 4 months