diff options
author | Sergei Trofimov <sergei.trofimov@arm.com> | 2018-06-26 08:27:08 +0100 |
---|---|---|
committer | Marc Bonnici <marc.bonnici@arm.com> | 2018-06-26 09:55:29 +0100 |
commit | 3c0f1968c5017808a4d93866653afbf8153733c0 (patch) | |
tree | 2d8eefe1775de5b26300df5cdc10e2a45968c12c | |
parent | d4aad394d7425a791203e63c10f495ccbadb01e5 (diff) |
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.
-rw-r--r-- | wa/workloads/apache.py | 8 |
1 files 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?' |