[Erp5-report] r8741 - /erp5/trunk/utils/erp5mechanize/userperzope.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Tue Jul 25 15:11:44 CEST 2006
Author: vincent
Date: Tue Jul 25 15:11:43 2006
New Revision: 8741
URL: http://svn.erp5.org?rev=8741&view=rev
Log:
Make csv separator configurable.
Add documentation.
Modified:
erp5/trunk/utils/erp5mechanize/userperzope.py
Modified: erp5/trunk/utils/erp5mechanize/userperzope.py
URL: http://svn.erp5.org/erp5/trunk/utils/erp5mechanize/userperzope.py?rev=8741&r1=8740&r2=8741&view=diff
==============================================================================
--- erp5/trunk/utils/erp5mechanize/userperzope.py (original)
+++ erp5/trunk/utils/erp5mechanize/userperzope.py Tue Jul 25 15:11:43 2006
@@ -29,9 +29,7 @@
import sys
import getopt
-CSV_SEPARATOR=';'
-
-def parse_csv_line(line, sep=','):
+def parse_csv_line(line, sep):
line = line.replace('\n','')
item_list = line.split(sep)
for pos in xrange(len(item_list)):
@@ -43,20 +41,42 @@
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()]))
+def output_csv(separator=',', *args, **kw):
+ sys.stdout.write(separator.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=', ])
+ opt_list, arg_list = getopt.getopt(sys.argv[1:], '', ['maximum_duration=', 'csv_separator='])
except getopt.error, msg:
- print msg
+ print 'Error: %s' % (msg, )
+ print \
+'''Synopsis:
+ %s [--maximum_duration=maximum_duration] [--csv_separator=separator] [file [...]]
+
+ Each given file must be a CSV file separated by separator (default = ,).
+ First CSV column must be of the form user at host.
+ If last collumn contains "FAILED" (without quotes) the following is ignored
+ and the test immediatelly marked as failed.
+ If maximum_duration is given, second and third columns must be floating
+ point values (second is start time, third is stop time). The
+ maximum_duration parameter must be a floating point value aswel. If the
+ test duration exceed the given time limit ,the test is marked as failed.
+ Default is not to check the test duration.
+
+Output:
+ On the standard output is given a CSV file giving for every nimber of zope
+ the maximum number of users for which the test was successfull.
+ The CSV separator is the same as the one given as parameter.
+''' % (sys.argv[0], )
sys.exit(2)
+csv_separator = ','
maximum_duration = None
for o, a in opt_list:
if o == '--maximum_duration':
maximum_duration = float(a)
+ elif o == '--csv_separator':
+ csv_separator = a
result_list = {}
for filename in arg_list:
@@ -66,7 +86,7 @@
known_zope_list = []
failed = 0
for line in line_list:
- field_list = parse_csv_line(line, CSV_SEPARATOR)
+ field_list = parse_csv_line(line, csv_separator)
user = field_list[0]
if user not in known_user_list:
known_user_list.append(user)
@@ -91,5 +111,5 @@
if result == 0:
break
maximum_user_number = max(maximum_user_number, result)
- output_csv(k, maximum_user_number)
+ output_csv(k, maximum_user_number, separator=csv_separator)
More information about the Erp5-report
mailing list