aboutsummaryrefslogtreecommitdiffstats
path: root/testing/tsung/support-python3.patch
blob: fe5a181cd248ac412c932e7f440950d5bf8617a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
From e37e82aa8778688c5b315c4fe54fa4f67e9a4a82 Mon Sep 17 00:00:00 2001
From: Didier Fabert <didier.fabert@gmail.com>
Date: Fri, 31 May 2019 22:52:47 +0200
Subject: [PATCH] Support python3: print statement has been replaced with a
 function

---
 src/tsung-plotter/tsplot.py.in   | 30 +++++++++++++++---------------
 src/tsung-plotter/tsung/tsung.py |  2 +-
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/src/tsung-plotter/tsplot.py.in b/src/tsung-plotter/tsplot.py.in
index f7a180b3..f8eb7295 100644
--- a/src/tsung-plotter/tsplot.py.in
+++ b/src/tsung-plotter/tsplot.py.in
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
 # -*- Mode: python -*-
 # -*- coding: utf-8 -*-
 
@@ -204,7 +204,7 @@ def main(conffile, logs, legends, outdir, verbose):
             stats = [x.strip().rsplit('.', 1)
                      for x in config.get(s, 'stats').split(' ')]
         except:
-            print 'error: unable to read plot "%s" stats' % s
+            print('error: unable to read plot "%s" stats' % s)
             continue
 
         if config.has_option(s, 'styles'):
@@ -235,8 +235,8 @@ def main(conffile, logs, legends, outdir, verbose):
             try:
                 p.__dict__['yfactor'] = map(float,config.get(s, 'yfactor').decode(encoding).split(','))
             except ValueError:
-                print 'warning: %s yfactor not a number: %s' \
-                    % (p.name, config.get(s, yfactor))
+                print('warning: %s yfactor not a number: %s' \
+                    % (p.name, config.get(s, yfactor)))
         # Text parameters - to decode into specified encoding
         for attr in ['title', 'xlabel', 'ylabel', 'plottype', 'yscale']:
             if config.has_option(s, attr):
@@ -249,13 +249,13 @@ def main(conffile, logs, legends, outdir, verbose):
                 try:
                     p.__dict__[attr] = config.getfloat(s, attr)
                 except ValueError:
-                    print 'warning: %s %s not a number: %s' \
-                          % (p.name, attr, config.get(s, attr))
+                    print('warning: %s %s not a number: %s' \
+                          % (p.name, attr, config.get(s, attr)))
 
         outfile = p.plot(stats, dataset)
 
         if verbose:
-            print 'Generated plot %s' % outfile
+            print('Generated plot %s' % outfile)
 
 if __name__ == "__main__":
     from optparse import OptionParser
@@ -280,10 +280,10 @@ if __name__ == "__main__":
         config = options.config
 
     if options.verbose:
-        print 'Using %s configuration file' % config
+        print('Using %s configuration file' % config)
 
     if not os.access(config, os.R_OK):
-        print "can't read configuration file: %s" % config
+        print("can't read configuration file: %s" % config)
         sys.exit(1)
 
     # FIXME: error control
@@ -295,7 +295,7 @@ if __name__ == "__main__":
 
     # args are legend then file, any times wanted by user
     if len(args) % 2 != 0:
-        print "error: please provide legend and tsung log filename"
+        print("error: please provide legend and tsung log filename")
         sys.exit(3)
 
     count   = 0
@@ -311,21 +311,21 @@ if __name__ == "__main__":
         count += 1
 
     if options.verbose:
-        print 'Using %s stats configuration file' % SYS_STATS_CONF
+        print('Using %s stats configuration file' % SYS_STATS_CONF)
 
     logs = []
     for logfile in files:
         if not os.access(logfile, os.R_OK):
-            print "error: unable to read file %s" % logfile
+            print("error: unable to read file %s" % logfile)
 
         else:
             if options.verbose:
-                print 'Parsing Tsung log file', logfile
+                print('Parsing Tsung log file', logfile)
             logs.append((logfile, TsungLog(SYS_STATS_CONF, logfile)))
 
     if len(logs) != len(args) / 2:
-        print 'error while parsing files (%d != %d)' % (len(logs),
-                                                        len(args)/2)
+        print('error while parsing files (%d != %d)' % (len(logs),
+                                                        len(args)/2))
         sys.exit(2)
 
     main(config, logs, legends, options.outdir, options.verbose)
diff --git a/src/tsung-plotter/tsung/tsung.py b/src/tsung-plotter/tsung/tsung.py
index 72d32976..ffcca8af 100644
--- a/src/tsung-plotter/tsung/tsung.py
+++ b/src/tsung-plotter/tsung/tsung.py
@@ -204,7 +204,7 @@ def parse(self):
                                 break
 
                     if name not in self.unknown and not is_re:
-                        print 'WARNING: tsung %s data is not configured' % name
+                        print('WARNING: tsung %s data is not configured' % name)
                         self.unknown.append(name)
 
     def stat(self, name, stat):