Author: gnichols
Date: 2011-07-25 14:16:59 +0000 (Mon, 25 Jul 2011)
New Revision: 1028
Modified:
trunk/v7/documentbase.py
trunk/v7/hardwaretest.py
trunk/v7/http.py
Log:
725441 - FEAT: save command should store results on server for review
Modified: trunk/v7/documentbase.py
===================================================================
--- trunk/v7/documentbase.py 2011-07-25 14:15:52 UTC (rev 1027)
+++ trunk/v7/documentbase.py 2011-07-25 14:16:59 UTC (rev 1028)
@@ -268,6 +268,10 @@
def compressToFile(self, filename):
self.save(filename)
try:
+ os.remove(filename+".gz")
+ except:
+ pass
+ try:
gzip = Command("gzip %s" % filename)
gzip.run()
return True
Modified: trunk/v7/hardwaretest.py
===================================================================
--- trunk/v7/hardwaretest.py 2011-07-25 14:15:52 UTC (rev 1027)
+++ trunk/v7/hardwaretest.py 2011-07-25 14:16:59 UTC (rev 1028)
@@ -46,6 +46,7 @@
from v7.redhatrelease import RedHatRelease
from v7.daemon import V7Daemon
from v7.log import Log
+from v7.http import V7Http
class HardwareTestHarness(Controller):
@@ -944,17 +945,20 @@
def __save(self):
if self.certification:
path = self.environment.getStoreDirectory()
+ serverPath = list()
self.makeDirectoryPath(path)
- for tag in Tags.vendor, Tags.model, Tags.arch:
+ for tag in Tags.vendor, Tags.make, Tags.model, Tags.arch:
value = self.certification.getHardware(tag)
if len(value) > 0 and value != "unknown":
path += "/%s" % value
self.makeDirectoryPath(path)
+ serverPath.append(value)
for tag in Tags.name, Tags.release:
value = self.certification.getOS(tag)
if len(value) > 0:
path += "/%s" % value
self.makeDirectoryPath(path)
+ serverPath.append(value)
savedFilename = "v7-results"
hostname = self.certification.getOS(Tags.hostname)
@@ -965,8 +969,16 @@
savedFilename += "-%s" % self.certification.timeStringToTimestamp(runTime)
savedFilename += ".xml"
print "Saving current results to:"
- print "%s/%s" % (path, savedFilename)
- self.certification.save("%s/%s" % (path, savedFilename))
+ savedFilePath = os.path.join(path, savedFilename)
+ print savedFilePath
+ self.certification.compressToFile(savedFilePath)
+
+ if self.testServer and self.ui.promptConfirm("Copy results to test server %s?" % self.testServer):
+ request = V7Http(self.testServer, "/v7/cgi/saveFile.py")
+ request.addField("server-path", serverPath)
+ return request.httpUpload(savedFilePath+".gz")
+
+ # otherwise
return True
#otherwise
Modified: trunk/v7/http.py
===================================================================
--- trunk/v7/http.py 2011-07-25 14:15:52 UTC (rev 1027)
+++ trunk/v7/http.py 2011-07-25 14:16:59 UTC (rev 1028)
@@ -16,7 +16,7 @@
#
# HTTP library for v7's tests
-import os, urllib2, httplib
+import os, urllib2, httplib, re, time
class V7Http:
@@ -33,7 +33,11 @@
lines.append('--' + boundary)
lines.append('Content-Disposition: form-data; name="%s"' % name)
lines.append('')
- lines.append(value)
+ if type(value) is list:
+ for item in value:
+ lines.append(item)
+ else:
+ lines.append(value)
for (name, filename, contents) in self.files:
lines.append('--' + boundary)
lines.append('Content-Disposition: form-data; name="%s"; filename="%s"' % (name, filename))
@@ -71,11 +75,30 @@
responseCode, responseMessage, headers = request.getreply()
if responseCode != 200:
print "Error: could not send message (response code %s)" % responseCode
+ print "Host: %s" % self.host
+ print "URL: %s" % self.url
print "Message: %s" % responseMessage
return (0, None)
return (len(self.body), request.file.read())
+ def httpUpload(self, localFilePath):
+ if not self.addFile(localFilePath):
+ print "Error: could not add file %s to request" % localFilePath
+ return False
+ # otherwise
+ print "sending file %s " % localFilePath
+ startTime = time.time()
+ (size, response) = self.send()
+ stopTime = time.time()
+ if not response:
+ # send failed
+ return False
+ print "response: "
+ print response
+ print "Upload took %.2f seconds, %.2f MB/sec" % (stopTime-startTime, size/((stopTime-startTime)*1000000))
+
+ return True
if __name__ == "__main__":