Author: gnichols
Date: 2011-03-08 13:06:28 +0000 (Tue, 08 Mar 2011)
New Revision: 792
Added:
trunk/test-env/www/cgi/networkTest.py
Log:
680225 - network test should use HTTP for file transfer tests rather than NFS
Added: trunk/test-env/www/cgi/networkTest.py
===================================================================
--- trunk/test-env/www/cgi/networkTest.py (rev 0)
+++ trunk/test-env/www/cgi/networkTest.py 2011-03-08 13:06:28 UTC (rev 792)
@@ -0,0 +1,75 @@
+#!/usr/bin/python
+# 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
+#
+
+# this cgi is used by the http transfer portion of the network test. It saves the file
enclosure to the v7
+# storage area for the upload portion of the test. The network test uses a simple
request for the file
+# for the download test
+
+import os,sys,cgi
+v7ClassLibraryPath = '/usr/share/v7/lib/'
+sys.path.append(v7ClassLibraryPath)
+os.putenv("PYTHONPATH", v7ClassLibraryPath)
+from v7.hash import hashModule
+
+from v7.environment import Environment
+
+environment = Environment()
+
+import cgitb
+cgitb.enable()
+
+
+def saveFiles():
+ ipAddress = cgi.escape(os.environ["REMOTE_ADDR"])
+
+ files = list()
+ fieldStorage = cgi.FieldStorage()
+ for key in fieldStorage.keys():
+ if fieldStorage[key].name == 'file':
+ directory = os.path.join(environment.getStoreDirectory(), ipAddress)
+ try:
+ os.mkdir(directory)
+ except OSError:
+ # directory exists
+ pass
+ path = os.path.join(directory, fieldStorage[key].filename)
+ file = open(path, "wb")
+ file.write(fieldStorage[key].value.decode("base64"))
+ file.close()
+ print " Saved: " + path
+ print " From IP: " + ipAddress
+ # getMD5 checksum
+ m=hashModule.md5()
+ file = open(path, "rb")
+ m.update(file.read())
+ file.close()
+ print " checksum: " + m.hexdigest()
+
+
+
+
+print "Content-type: text/plain";
+print
+
+
+files = saveFiles()
+
+
+
+sys.stdout.flush()
+
+
Property changes on: trunk/test-env/www/cgi/networkTest.py
___________________________________________________________________
Added: svn:executable
+ *
Show replies by date