From 3c0f1968c5017808a4d93866653afbf8153733c0 Mon Sep 17 00:00:00 2001 From: Sergei Trofimov Date: Tue, 26 Jun 2018 08:27:08 +0100 Subject: workloads/apache: fix for Python 3 urllib2 does not exist in Python 3, and its methods have been moved into urllib.request. Use future library to create aliases that work across both 2 and 3. --- wa/workloads/apache.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/wa/workloads/apache.py b/wa/workloads/apache.py index 467f4b38..b9d3c11d 100644 --- a/wa/workloads/apache.py +++ b/wa/workloads/apache.py @@ -1,6 +1,10 @@ from __future__ import division import os -import urllib2 + +from future.standard_library import install_aliases +install_aliases() + +from urllib.request import urlopen from wa import Workload, Parameter, Alias, WorkloadError from wa.utils.exec_control import once @@ -55,7 +59,7 @@ class ApacheBenchmark(Workload): msg = 'ab not found on host; make sure apache2-utils (or you distro equivalent) package is installed.' raise WorkloadError(msg) - response = urllib2.urlopen('http://{}:{}{}'.format(self.target.conn.host, self.port, self.path)) + response = urlopen('http://{}:{}{}'.format(self.target.conn.host, self.port, self.path)) code = response.getcode() if code != 200: msg = 'HTTP request failed with status {}; is Apache running on target?' -- cgit v1.2.3