[Erp5-report] r8736 - /erp5/trunk/utils/erp5mechanize/userperzope.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Tue Jul 25 13:51:41 CEST 2006
Author: vincent
Date: Tue Jul 25 13:51:38 2006
New Revision: 8736
URL: http://svn.erp5.org?rev=8736&view=rev
Log:
Add a script to sum up test results to give a number of users per zope instance.
Added:
erp5/trunk/utils/erp5mechanize/userperzope.py (with props)
Added: erp5/trunk/utils/erp5mechanize/userperzope.py
URL: http://svn.erp5.org/erp5/trunk/utils/erp5mechanize/userperzope.py?rev=8736&view=auto
==============================================================================
--- erp5/trunk/utils/erp5mechanize/userperzope.py (added)
+++ erp5/trunk/utils/erp5mechanize/userperzope.py Tue Jul 25 13:51:38 2006
@@ -1,0 +1,95 @@
+#!/usr/bin/python
+##############################################################################
+#
+# Copyright (c) 2006 Nexedi SARL and Contributors. All Rights Reserved.
+# Vincent Pelletier <vincent at nexedi.com>
+#
+# WARNING: This program as such is intended to be used by professional
+# programmers who take the whole responsability of assessing all potential
+# consequences resulting from its eventual inadequacies and bugs
+# End users who are looking for a ready-to-use solution with commercial
+# garantees and support are strongly adviced to contract a Free Software
+# Service Company
+#
+# This program is Free Software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+##############################################################################
+import sys
+import getopt
+
+CSV_SEPARATOR=';'
+
+def parse_csv_line(line, sep=','):
+ line = line.replace('\n','')
+ item_list = line.split(sep)
+ for pos in xrange(len(item_list)):
+ item = item_list[pos]
+ if item[0] == "'":
+ item = item[1:]
+ if item[-1] == "'":
+ item = item[:-1]
+ item_list[pos] = item
+ return item_list
+
+def output_csv(*args, **kw):
+ sys.stdout.write(','.join([repr(v) for v in args] + [repr(v) for v in kw.values()]))
+ sys.stdout.write('\n')
+
+try:
+ opt_list, arg_list = getopt.getopt(sys.argv[1:], '', ['maximum_duration=', ])
+except getopt.error, msg:
+ print msg
+ sys.exit(2)
+
+maximum_duration = None
+for o, a in opt_list:
+ if o == '--maximum_duration':
+ maximum_duration = float(a)
+
+result_list = {}
+for filename in arg_list:
+ csv = open(filename)
+ line_list = csv.readlines()
+ known_user_list = []
+ known_zope_list = []
+ failed = 0
+ for line in line_list:
+ field_list = parse_csv_line(line, CSV_SEPARATOR)
+ user = field_list[0]
+ if user not in known_user_list:
+ known_user_list.append(user)
+ zope = field_list[0].split('@', 1)[1]
+ if zope not in known_zope_list:
+ known_zope_list.append(zope)
+ if field_list[-1] == 'FAILED':
+ failed = True
+ break
+ if maximum_duration is not None and float(field_list[2]) - float(field_list[1]) > maximum_duration:
+ failed = True
+ break
+ if not result_list.has_key(len(known_zope_list)):
+ result_list[len(known_zope_list)] = [failed==False and len(known_user_list) or 0]
+ else:
+ result_list[len(known_zope_list)].append(failed==False and len(known_user_list) or 0)
+ csv.close()
+
+for k, v in result_list.items():
+ maximum_user_number = 0
+ for result in v:
+ if result == 0:
+ break
+ maximum_user_number = max(maximum_user_number, result)
+ output_csv(k, maximum_user_number)
+
Propchange: erp5/trunk/utils/erp5mechanize/userperzope.py
------------------------------------------------------------------------------
svn:executable = *
More information about the Erp5-report
mailing list