Commit c46ba4e0 authored by Bryton Lacquement's avatar Bryton Lacquement 🚪

wip

parent db740982
......@@ -804,15 +804,15 @@ shared = true
test_node = self.getTestNode()
node_test_suite = test_node.getNodeTestSuite('foo')
folder = node_test_suite.test_suite_directory
self.assertEqual(False, os.path.exists(folder))
self.assertFalse(os.path.exists(folder))
createFolder(folder)
self.assertEqual(True, os.path.exists(folder))
self.assertTrue(os.path.exists(folder))
to_drop_path = os.path.join(folder, 'drop')
to_drop = open(to_drop_path, 'w')
to_drop.close()
self.assertEqual(True, os.path.exists(to_drop_path))
self.assertTrue(os.path.exists(to_drop_path))
createFolder(folder, clean=True)
self.assertEqual(False, os.path.exists(to_drop_path))
self.assertFalse(os.path.exists(to_drop_path))
def test_15_suite_log_directory(self, my_test_type='UnitTest', grade='master'):
def doNothing(self, *args, **kw):
......
......@@ -547,10 +547,8 @@ def generateReport():
report_dict['filename'].append(filename)
if not per_nb_users_report_dict:
print("ERROR: No result file found, perhaps "\
"``--filename-prefix'' should be specified?", file=sys.stderr)
sys.exit(1)
sys.exit("ERROR: No result file found, perhaps ``--filename-prefix'' should"
"be specified?")
pdf = PdfPages(argument_namespace.output_filename)
......
......@@ -20,11 +20,8 @@ try:
user_nbr = int(user_nbr)
except ValueError:
print("ERROR: Missing arguments: %s URL USERNAME " \
"PASSWORD NUMBER_OF_USERS NEW_USERNAME_PREFIX NEW_USERS_PASSWORD" % \
sys.argv[0], file=sys.stderr)
sys.exit(1)
sys.exit("ERROR: Missing arguments: %s URL USERNAME PASSWORD NUMBER_OF_USERS "
"NEW_USERNAME_PREFIX NEW_USERS_PASSWORD" % sys.argv[0])
# Create a browser instance
browser = Browser(url, username, password)
......
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
from __future__ import division, print_function
from erp5.util.testbrowser.browser import Browser
ITERATION = 20
......@@ -90,4 +90,4 @@ if __name__ == '__main__':
counter += 1
for title, time_list in result_dict.iteritems():
print("%s: %.4fs" % (title, float(sum(time_list)) / ITERATION))
print("%s: %.4fs" % (title, sum(time_list) / ITERATION))
......@@ -33,7 +33,6 @@ import signal
import sys
import time
from . import logger
from slapos.util import bytes2str
MAX_TIMEOUT = 3600 * 4
......@@ -80,7 +79,7 @@ def subprocess_capture(p, log_prefix, get_output=True):
break
if get_output:
buffer.append(data)
log(log_prefix + bytes2str(data).rstrip('\n'))
log(log_prefix + data.decode('utf-8', errors='replace').rstrip('\n'))
if p.stdout:
stdout = []
stdout_thread = threading.Thread(target=readerthread,
......
......@@ -37,7 +37,7 @@ import shutil
import logging
import string
import random
from six.moves.urllib import parse
from six.moves.urllib.parse import urlparse
import base64
from six.moves import http_client as httplib
from . import Utils
......@@ -364,7 +364,7 @@ Require valid-user
user, password = self.generateProfilePasswordAccess()
logger.info("Software Profile password: %s" % password)
self.reachable_profile = "https://%s:%s@%s" % (user, password,
os.path.join(parse.urlparse(self.testnode.config['frontend_url']).netloc,
os.path.join(urlparse(self.testnode.config['frontend_url']).netloc,
"software", self.randomized_path, "software.cfg"))
def prepareSlapOSForTestSuite(self, node_test_suite):
......
......@@ -11,7 +11,7 @@ from uritemplate import expand
import slapos.slap
from slapos.slap import SoftwareProductCollection
from requests.exceptions import HTTPError
from erp5.util.taskdistribution import SAFE_RPC_EXCEPTION_LIST
from ..taskdistribution import SAFE_RPC_EXCEPTION_LIST
from . import logger
import six
......
......@@ -39,7 +39,7 @@ from .ScalabilityTestRunner import ScalabilityTestRunner
from .UnitTestRunner import UnitTestRunner
from .Utils import deunicodeData
from .Utils import rmtree
from erp5.util import taskdistribution
from .. import taskdistribution
MAX_LOG_TIME = 15 # time in days we should keep logs that we can see through
# httd
......@@ -171,7 +171,7 @@ shared = true
# only limit to particular error, if we run that code for all errors,
# then if server having most repositories is down for some time, we would
# erase all repositories and facing later hours of downloads
if getattr(error, 'stderr', b'').find(b'index') >= 0:
if b'index' in getattr(error, 'stderr', b''):
rmtree(repository_path)
logger.warning("Error while getting repository, ignoring this test suite",
exc_info=1)
......
......@@ -27,7 +27,7 @@
#
##############################################################################
from __future__ import print_function
from __future__ import division, print_function
import os
import sys
......@@ -150,7 +150,7 @@ def parseFile(filename, measure_dict):
if line_number > 0:
duration = time() - begin
print("Matched %i lines (%.2f%%), %i skipped (%.2f%%), %i unmatched (%.2f%%) in %.2fs (%i lines per second)." % \
(match_count, (float(match_count) / line_number) * 100, skip_count, (float(skip_count) / line_number) * 100, (line_number - match_count - skip_count), (1 - (float(match_count + skip_count) / line_number)) * 100, duration, line_number / duration),
(match_count, (match_count / line_number) * 100, skip_count, (skip_count / line_number) * 100, (line_number - match_count - skip_count), (1 - (match_count + skip_count) / line_number)) * 100, duration, line_number // duration),
file=sys.stderr)
debug = False
......
......@@ -27,7 +27,7 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from __future__ import print_function
from __future__ import division, print_function
from datetime import date
from os import path
......@@ -84,9 +84,9 @@ class CSVFile(object):
if cell > value_max.get(key, 0):
value_max[key] = cell
column_dict[key].append(cell)
line_num = float(line_num) / 100
line_num = line_num / 100
for key in ratio_dict:
ratio_dict[key] /= line_num
ratio_dict[key] //= line_num
def getColumn(self, column_id):
return self.column_dict[self.column_list[column_id]]
......@@ -103,7 +103,7 @@ def computeExpr(expr):
if expr:
assert expr[0] == '='
num, denom = expr[1:].split('/')
result = float(int(num)) / int(denom)
result = int(num) / int(denom)
else:
result = None
return result
......@@ -136,7 +136,7 @@ def main():
# date_list will be like ['2009/07/01', '2009/07/05', '2009/07/10', ...]
factor = 1
if len(date_string_list) > 20:
factor = int(len(date_string_list) / 20)
factor = int(len(date_string_list) // 20)
i = 0
for date_string in date_string_list:
if i % factor == 0:
......@@ -190,7 +190,7 @@ def main():
if options.minimal_non_empty_ratio is not None:
column_len = len(column)
if column_len:
if float(len(x_data))/column_len < options.minimal_non_empty_ratio:
if len(x_data) / column_len < options.minimal_non_empty_ratio:
print('Not enough values to plot for %s...' % (out_file_name, ))
continue
r_y_data = robjects.FloatVector(y_data)
......
......@@ -213,11 +213,13 @@ def generateInformation(dir, info=id, err=None):
property_list = BusinessTemplate.fromDir(path)
else:
continue
xml.write(b' <template id="%s">\n' % name.encode('utf-8'))
xml.write(b' <template id="%s">\n' % name.encode())
for k, v in property_list:
k = k.encode('utf-8')
if str is not bytes:
k = k.encode()
for v in (v,) if type(v) is bytes else v:
xml.write(b' <%s>%s</%s>\n' % (k, escape(v.decode('utf-8')).encode('utf-8'), k))
xml.write(b' <%s>%s</%s>\n' % (k, escape(v) if str is bytes else
escape(v.decode()).encode(), k))
xml.write(b' </template>\n')
info('done\n')
xml.write(b'</repository>\n')
......
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