Commit 175ac850 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki Committed by Jérome Perrin

erp5_test_result: Make code compatible with both python2 and python3.

parent 04913fa6
......@@ -32,6 +32,7 @@ from zLOG import LOG,DEBUG,ERROR
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions
from Products.ZSQLCatalog.SQLCatalog import SimpleQuery
from six.moves import range
TEST_SUITE_MAX = 4
# Depending on the test suite priority, we will affect
# more or less cores
......@@ -215,12 +216,12 @@ class ERP5ProjectUnitTestDistributor(XMLObject):
# we divide per 3 because we have 3 cores per node
node_quantity_min = PRIORITY_MAPPING[int_index][0]/3
node_quantity_max = PRIORITY_MAPPING[int_index][1]/3
for x in xrange(0, node_quantity_min):
for x in range(0, node_quantity_min):
score = float(x)/(x+1)
all_test_suite_list.append((score, test_suite_url, title))
test_suite_score.setdefault(test_suite_url, []).append(score)
# additional suites, lower score
for x in xrange(0, node_quantity_max -
for x in range(0, node_quantity_max -
node_quantity_min ):
score = float(1) + x/(x+1)
all_test_suite_list.append((1 + x/(x+1), test_suite_url, title))
......
......@@ -33,6 +33,7 @@ from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions
import json
import jinja2
from six.moves import range
class ERP5ScalabilityDistributor(ERP5ProjectUnitTestDistributor, object):
security = ClassSecurityInfo()
......@@ -342,7 +343,7 @@ class ERP5ScalabilityDistributor(ERP5ProjectUnitTestDistributor, object):
try:
template = jinja2.Template(cluster_configuration)
for index in xrange(0, len(number_configuration_list)):
for index in range(0, len(number_configuration_list)):
template_vars = { "count" : number_configuration_list[index],
"comp" : remaining_nodes }
configuration_list_json.append( json.loads(
......
......@@ -28,8 +28,8 @@
from urllib import quote_plus
from urlparse import urlparse
from urlparse import urljoin
from six.moves.urllib.parse import urlparse
from six.moves.urllib.parse import urljoin
import logging
from AccessControl import ClassSecurityInfo
......
......@@ -27,6 +27,7 @@
import jinja2
import json
from six.moves import range
def getGeneratedConfigurationList(self, *args, **kw):
document_list = []
......@@ -36,7 +37,7 @@ def getGeneratedConfigurationList(self, *args, **kw):
#max = self.getNumberConfiguration()
comp_list_view = [ "COMP-%i" %(x) for x in range(0,max_comp) ]
for count in xrange(1, max_+1):
for count in range(1, max_+1):
template_vars = { "count" : count, "comp" : comp_list_view }
output_text = template.render(template_vars)
description = json.dumps(json.loads(output_text), sort_keys=True, indent=4, separators=(',', ': '))
......@@ -126,7 +127,7 @@ def generateConfigurationList(self, test_suite_title):
# bad json configuration
try:
template = jinja2.Template(cluster_configuration)
for count in xrange(1, number_configuration+1):
for count in range(1, number_configuration+1):
template_vars = { "count" : count, "comp" : remaining_nodes_computer_guid }
configuration_list_json.append( json.loads( template.render( template_vars ) ) )
return_dict['launchable'] = True
......
......@@ -9,6 +9,7 @@ if len(value_list) != 2:
a, b = value_list
from Products.ERP5Type.Document import newTempBase
import six
# make sure that a is the oldest result
if a.getIntIndex() > b.getIntIndex():
......@@ -50,7 +51,7 @@ for a_line in a.searchFolder(portal_type='Test Result Line'):
before_url=a_line.absolute_url(),
**d))
for title, not_in_a in b_title_dict.iteritems():
for title, not_in_a in six.iteritems(b_title_dict):
b_line = b[not_in_a]
d = dict((prop, b_line.getProperty(prop)) for prop in compared_prop_list)
object_list.append(newTempBase(context, title,
......
......@@ -22,7 +22,7 @@ for tl in test_result_lines:
test_name = test.split(':')[0]
test_documents_created = test.split(':')[1].replace('doc/hour', '').strip()
# initial init
if test_name not in results.keys():
if test_name not in list(results.keys()):
results[test_name] = []
results[test_name].append({'created_docs': test_documents_created,
'duration':3600})
......
......@@ -32,7 +32,8 @@ from Products.ERP5Type import Permissions
from Products.ERP5Type.Tool.BaseTool import BaseTool
from Products.ZSQLCatalog.SQLCatalog import SimpleQuery, NegatedQuery
from zLOG import LOG, DEBUG
from xmlrpclib import Binary
from six.moves.xmlrpc_client import Binary
import six
class TaskDistributionTool(BaseTool):
"""
......@@ -266,7 +267,7 @@ class TaskDistributionTool(BaseTool):
extract all xmlrpclib.Binary instance
"""
return {x: y.data if isinstance(y, Binary) else y
for x, y in xmlrpc_dict.iteritems()}
for x, y in six.iteritems(xmlrpc_dict)}
security.declarePublic('reportTaskFailure')
def reportTaskFailure(self, test_result_path, status_dict, node_title):
......
import string
from random import choice
from six.moves import range
test_suite = state_change['object']
portal = test_suite.getPortalObject()
......
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