Commit 55f21858 authored by Thomas Gambier's avatar Thomas Gambier Committed by Thomas Gambier

resiliencytest: supports python3

parent ca3341d5
...@@ -36,6 +36,7 @@ import random ...@@ -36,6 +36,7 @@ import random
import ssl import ssl
import string import string
import time import time
from slapos.util import bytes2str, str2bytes
from six.moves.urllib.request import HTTPCookieProcessor, HTTPSHandler, \ from six.moves.urllib.request import HTTPCookieProcessor, HTTPSHandler, \
build_opener build_opener
from six.moves.urllib.error import HTTPError from six.moves.urllib.error import HTTPError
...@@ -89,7 +90,7 @@ class SlaprunnerTestSuite(ResiliencyTestSuite): ...@@ -89,7 +90,7 @@ class SlaprunnerTestSuite(ResiliencyTestSuite):
try: try:
url = "%s/%s" % (self.slaprunner_backend_url, resource) url = "%s/%s" % (self.slaprunner_backend_url, resource)
if data: if data:
result = self._opener_director.open(url, data=data) result = self._opener_director.open(url, data=str2bytes(data))
else: else:
result = self._opener_director.open(url) result = self._opener_director.open(url)
...@@ -102,7 +103,7 @@ class SlaprunnerTestSuite(ResiliencyTestSuite): ...@@ -102,7 +103,7 @@ class SlaprunnerTestSuite(ResiliencyTestSuite):
def _login(self): def _login(self):
self.logger.debug('Logging in...') self.logger.debug('Logging in...')
b64string = base64.encodestring('%s:%s' % (self.slaprunner_user, self.slaprunner_password))[:-1] b64string = base64.b64encode(('%s:%s' % (self.slaprunner_user, self.slaprunner_password)).encode()).decode()
self._opener_director.addheaders = [ self._opener_director.addheaders = [
('Authorization', 'Basic %s' % b64string), ('Authorization', 'Basic %s' % b64string),
# By default we will prefer to receive JSON to simplify # By default we will prefer to receive JSON to simplify
......
...@@ -244,13 +244,13 @@ def viewLog(): ...@@ -244,13 +244,13 @@ def viewLog():
return render_template('viewLog.html') return render_template('viewLog.html')
def getFileLog(): def getFileLog():
logfile = request.form.get('filename', '').encode('utf-8') logfile = request.form.get('filename', '')
if logfile == "instance.log": if logfile == "instance.log":
file_path = app.config['instance_log'] file_path = app.config['instance_log']
elif logfile == "software.log": elif logfile == "software.log":
file_path = app.config['software_log'] file_path = app.config['software_log']
else: else:
file_path = realpath(app.config, logfile) file_path = realpath(app.config, logfile.encode('utf-8'))
try: try:
if not os.path.exists(file_path): if not os.path.exists(file_path):
raise IOError raise IOError
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment