public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/flow-tools] rawhide: Convert Python files to Python 3 with a patch
@ 2026-06-27 16:48 Karolina Surma
  0 siblings, 0 replies; only message in thread
From: Karolina Surma @ 2026-06-27 16:48 UTC (permalink / raw)
  To: git-commits

            A new commit has been pushed.

            Repo   : rpms/flow-tools
            Branch : rawhide
            Commit : 4343546999b476284f8d9ac3fa0e314df9be535c
            Author : Karolina Surma <ksurma@redhat.com>
            Date   : 2026-06-27T16:48:05+00:00
            Stats  : +445/-4 in 2 file(s)
            URL    : https://src.fedoraproject.org/rpms/flow-tools/c/4343546999b476284f8d9ac3fa0e314df9be535c?branch=rawhide

            Log:
            Convert Python files to Python 3 with a patch

Since this package is not really updated in Fedora,
we can generate a patch with the last Python containing lib2to3 (3.12)
and store it in the repository, rather than pull in an old Python to the
buildroot.

---
diff --git a/Format-bin-flow-to-be-compatible-with-Python3.patch b/Format-bin-flow-to-be-compatible-with-Python3.patch
new file mode 100644
index 0000000..479fa0b
--- /dev/null
+++ b/Format-bin-flow-to-be-compatible-with-Python3.patch
@@ -0,0 +1,443 @@
+From 2d868f47a8b58fbbf825eff1e83fcada4f956013 Mon Sep 17 00:00:00 2001
+From: Karolina Surma <ksurma@redhat.com>
+Date: Fri, 17 Oct 2025 09:50:48 +0200
+Subject: [PATCH] Format bin/flow* to be compatible with Python3
+
+Generated automatically on the unpacked sources with
+`python3.12 -m lib2to3 --write --nobackups bin/flow*`
+---
+ bin/flow-log2rrd |   6 +-
+ bin/flow-rpt2rrd |  32 +++++------
+ bin/flow-rptfmt  | 146 +++++++++++++++++++++++------------------------
+ 3 files changed, 92 insertions(+), 92 deletions(-)
+
+diff --git a/bin/flow-log2rrd b/bin/flow-log2rrd
+index c333c3d..fa2c5ce 100755
+--- a/bin/flow-log2rrd
++++ b/bin/flow-log2rrd
+@@ -41,8 +41,8 @@ while line :
+   elif fields[4][5:12] == 'capture' :
+     name='capture'
+   else :
+-    raise ValueError, "Expecting flow-capture or flow-fanout logs, got %s" %\
+-      fields[4]
++    raise ValueError("Expecting flow-capture or flow-fanout logs, got %s" %\
++      fields[4])
+ 
+   tv = {}
+   for f in fields :
+@@ -66,7 +66,7 @@ while line :
+ 
+     if not os.access(rrdFile, os.F_OK) :
+ 
+-      print 'Creating RRD ', rrdFile
++      print('Creating RRD ', rrdFile)
+ 
+       if name == 'capture' :
+ 
+diff --git a/bin/flow-rpt2rrd b/bin/flow-rpt2rrd
+index 7a38244..5511d85 100755
+--- a/bin/flow-rpt2rrd
++++ b/bin/flow-rpt2rrd
+@@ -156,13 +156,13 @@ class ftrpt2rrd:
+     # exists?
+     if not os.access(rrdFile, os.F_OK):
+ 
+-      print "Creating RRD", rrdFile
++      print("Creating RRD", rrdFile)
+ 
+       rrdParams = []
+       t = str(int(self.start_time) - 300)
+       rrdParams.append('--start')
+       rrdParams.append(t)
+-      for i in use_fields_index.keys():
++      for i in list(use_fields_index.keys()):
+         rrdParams.append("DS:%s:ABSOLUTE:600:U:U" % use_fields_index[i])
+       if (self.rrd_5min):
+         rrdParams.append('RRA:AVERAGE:0.5:1:%s' % self.rrd_5min)
+@@ -179,18 +179,18 @@ class ftrpt2rrd:
+ 
+       rrdtool.create(rrdFile, *rrdParams)
+       if self.debug:
+-        print >>sys.stderr, string.join(rrdParams,' ')
++        print(string.join(rrdParams,' '), file=sys.stderr)
+ 
+     # foreach value
+ 
+     update = self.start_time
+-    for i in use_fields_index.keys():
++    for i in list(use_fields_index.keys()):
+       update = "%s:%s" % (update,vals[i])
+     if self.debug:
+-      print >>sys.stderr, "update", update
++      print("update", update, file=sys.stderr)
+ 
+     if (self.verbose):
+-      print "Updating RRD", rrdFile
++      print("Updating RRD", rrdFile)
+ 
+     rrdtool.update(rrdFile,update)
+     
+@@ -249,16 +249,16 @@ class ftrpt2rrd:
+ 
+           # start time must be set by now
+           if (self.start_time == 0):
+-            raise ValueError, "Start time not found, make sure flow-report is including the header"
++            raise ValueError("Start time not found, make sure flow-report is including the header")
+ 
+           # load symbol tables
+           if self.mapsym == 1:
+-            for i in self.field_keys.keys():
++            for i in list(self.field_keys.keys()):
+               self.sym[i] = ftsym(self.field_names[i])
+ 
+           # convert use_fields to use_fields_index for easier access
+           self.use_fields_index = {}
+-          for i in self.use_fields.keys():
++          for i in list(self.use_fields.keys()):
+             if self.use_fields[i] and self.field_names2.get(i,'x') != 'x':
+               self.use_fields_index[self.field_names2[i]] = i
+ 
+@@ -271,7 +271,7 @@ class ftrpt2rrd:
+ 
+           # combine the key fields to form one key
+           k = ''
+-          for i in self.field_keys.keys():
++          for i in list(self.field_keys.keys()):
+             # try a symbol table lookup
+             if self.mapsym == 1:
+               t = self.sym[i].findbyval(splt[i])
+@@ -301,9 +301,9 @@ class ftrpt2rrd:
+ 
+     # keys which were not available in the report also need to be
+     # updated with 0 values.
+-    for i in xrange(len(splt)):
++    for i in range(len(splt)):
+       splt[i] = 0
+-    for x in self.use_key_names.keys():
++    for x in list(self.use_key_names.keys()):
+       if not (self.use_key_names[x] & 2):
+         self.update_rrd(x, splt, self.use_fields_index)
+ 
+@@ -345,13 +345,13 @@ for o,v in opts:
+   elif o == '-v':
+     opt_verbose = 1
+   elif o == '-h':
+-    print "Usage: flow-rpt2rrd [-nv] [-k keys] [-K keyfile] [-f fields]"
+-    print "                    [-p rrd_path] [-P fname_postfix]"
+-    print "                    [-r rrd_storage 5_min:30_min:2_hr:1_day ]"
++    print("Usage: flow-rpt2rrd [-nv] [-k keys] [-K keyfile] [-f fields]")
++    print("                    [-p rrd_path] [-P fname_postfix]")
++    print("                    [-r rrd_storage 5_min:30_min:2_hr:1_day ]")
+     sys.exit(0)
+ 
+ if opt_keys == '':
+-  print >>sys.stderr, "Keys must be defined with -k or -K."
++  print("Keys must be defined with -k or -K.", file=sys.stderr)
+   sys.exit(1)
+ 
+ ftrrd = ftrpt2rrd()
+diff --git a/bin/flow-rptfmt b/bin/flow-rptfmt
+index 6f78c15..57c4f8f 100755
+--- a/bin/flow-rptfmt
++++ b/bin/flow-rptfmt
+@@ -110,52 +110,52 @@ class ftrptfmt:
+   def _fmt_summary_detail(self):
+ 
+     if self.got_totals:
+-      print "Ignores:                 %s" % self.field_vals['ignores']
+-      print "Total Flows:             %s" % self.field_vals['flows']
+-      print "Total Octets:            %s" % self.field_vals['octets']
+-      print "Total Packets:           %s" % self.field_vals['packets']
+-      print "Total Duration (ms):     %s" % self.field_vals['duration']
+-    print "Real Time:               %s" % self.field_vals['time_real']
+-    print "Average Flow Time:       %s" % self.field_vals['aflowtime']
+-    print "Average Packets/Second:  %s" % self.field_vals['aps']
+-    print "Average Flows/Second:    %s" % self.field_vals['afs']
+-    print "Average Packets/Flow:    %s" % self.field_vals['apf']
+-    print "Flows/Second:            %s" % self.field_vals['fps']
+-    print "Flows/Second (real):     %s" % self.field_vals['fps_real']
+-
+-    print "\nAverage IP packet size distribution:"
+-    print "\n   1-32   64   96  128  160  192  224  256  288  320  352  384  416  448  480\n  ",
++      print("Ignores:                 %s" % self.field_vals['ignores'])
++      print("Total Flows:             %s" % self.field_vals['flows'])
++      print("Total Octets:            %s" % self.field_vals['octets'])
++      print("Total Packets:           %s" % self.field_vals['packets'])
++      print("Total Duration (ms):     %s" % self.field_vals['duration'])
++    print("Real Time:               %s" % self.field_vals['time_real'])
++    print("Average Flow Time:       %s" % self.field_vals['aflowtime'])
++    print("Average Packets/Second:  %s" % self.field_vals['aps'])
++    print("Average Flows/Second:    %s" % self.field_vals['afs'])
++    print("Average Packets/Flow:    %s" % self.field_vals['apf'])
++    print("Flows/Second:            %s" % self.field_vals['fps'])
++    print("Flows/Second (real):     %s" % self.field_vals['fps_real'])
++
++    print("\nAverage IP packet size distribution:")
++    print("\n   1-32   64   96  128  160  192  224  256  288  320  352  384  416  448  480\n  ", end=' ')
+     for x in range(7,22):
+-      print ("%-3.3f" % float(self.field_vals[x]))[1:],
+-    print "\n\n    512  544  576 1024 1536 2048 2560 3072 3584 4096 4608\n  ",
++      print(("%-3.3f" % float(self.field_vals[x]))[1:], end=' ')
++    print("\n\n    512  544  576 1024 1536 2048 2560 3072 3584 4096 4608\n  ", end=' ')
+     for x in range(22,33):
+-      print ("%-3.3f" % float(self.field_vals[x]))[1:],
++      print(("%-3.3f" % float(self.field_vals[x]))[1:], end=' ')
+ 
+-    print "\n\nPackets per flow distribution:"
+-    print "\n      1    2    4    8   12   16   20   24   28   32   36   40   44   48   52\n  ",
++    print("\n\nPackets per flow distribution:")
++    print("\n      1    2    4    8   12   16   20   24   28   32   36   40   44   48   52\n  ", end=' ')
+     for x in range(33,48):
+-      print ("%-3.3f" % float(self.field_vals[x]))[1:],
+-    print "\n\n     60  100  200  300  400  500  600  700  800  900 >900\n   ",
++      print(("%-3.3f" % float(self.field_vals[x]))[1:], end=' ')
++    print("\n\n     60  100  200  300  400  500  600  700  800  900 >900\n   ", end=' ')
+     for x in range(48,59):
+-      print ("%-3.3f" % float(self.field_vals[x]))[1:],
++      print(("%-3.3f" % float(self.field_vals[x]))[1:], end=' ')
+ 
+-    print "\n\nOctets per flow distribution:"
+-    print "\n     32   64  128  256  512 1280 2048 2816 3584 4352 5120 5888 6656 7424 8192\n  ",
++    print("\n\nOctets per flow distribution:")
++    print("\n     32   64  128  256  512 1280 2048 2816 3584 4352 5120 5888 6656 7424 8192\n  ", end=' ')
+     for x in range(59,74):
+-      print ("%-3.3f" % float(self.field_vals[x]))[1:],
+-    print "\n\n   8960 9728 10496 11264 12032 12800 13568 14336 15104 15872 >15872\n  ",
+-    print ("%-3.3f" % float(self.field_vals[74]))[1:],
++      print(("%-3.3f" % float(self.field_vals[x]))[1:], end=' ')
++    print("\n\n   8960 9728 10496 11264 12032 12800 13568 14336 15104 15872 >15872\n  ", end=' ')
++    print(("%-3.3f" % float(self.field_vals[74]))[1:], end=' ')
+     for x in range(75,85):
+-      print ("%-3.3f " % float(self.field_vals[x]))[1:],
++      print(("%-3.3f " % float(self.field_vals[x]))[1:], end=' ')
+ 
+-    print "\n\nFlow Time Distribution (ms):"
+-    print "\n    10    50  100  200  500 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000\n  ",
++    print("\n\nFlow Time Distribution (ms):")
++    print("\n    10    50  100  200  500 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000\n  ", end=' ')
+     for x in range(85,100):
+-      print ("%-3.3f" % float(self.field_vals[x]))[1:],
+-    print "\n\n  12000 14000 16000 18000 20000 22000 24000 26000 28000 30000 >30000\n  ",
++      print(("%-3.3f" % float(self.field_vals[x]))[1:], end=' ')
++    print("\n\n  12000 14000 16000 18000 20000 22000 24000 26000 28000 30000 >30000\n  ", end=' ')
+     for x in range(100,111):
+-      print ("%-3.3f " % float(self.field_vals[x]))[1:],
+-    print
++      print(("%-3.3f " % float(self.field_vals[x]))[1:], end=' ')
++    print()
+ 
+ #
+ #
+@@ -168,16 +168,16 @@ class ftrptfmt:
+       line = int(self.max_lines)
+ 
+       for x in self.field_iter:
+-        for y in xrange(self.field_total):
++        for y in range(self.field_total):
+           if self.field_display[y]:
+ #            print "x=",x,"y=",y,"#"
+             i = self.field_avals[x][y]
+-            print i.ljust(self.field_lens[y]),
++            print(i.ljust(self.field_lens[y]), end=' ')
+         if line:
+           line = line - 1
+           if not line:
+             break
+-        print
++        print()
+ 
+     else:
+ 
+@@ -194,23 +194,23 @@ class ftrptfmt:
+     for i in self.header_info:
+       if i[0:7] == '# rec1:':
+         break
+-      print i;
++      print(i);
+ 
+-    print "# ", sys.argv
++    print("# ", sys.argv)
+ 
+     # summary-detail is a special format
+     if self.display_summary_detail != 1:
+-      for x in xrange(self.field_total):
++      for x in range(self.field_total):
+         if self.field_display[x]:
+           i = self.field_names[x]
+           l = self.field_lens[x] 
+-          print i.ljust(l),
+-      print
++          print(i.ljust(l), end=' ')
++      print()
+ #
+ #
+ #
+   def fmt_ascii_footer(self) :
+-    print "\n",
++    print("\n", end=' ')
+ 
+ #
+ # HTML
+@@ -220,20 +220,20 @@ class ftrptfmt:
+  
+     if self.display_header:
+ 
+-      print '''<pre>''' 
++      print('''<pre>''') 
+       for i in self.header_info:
+         if i[0:7] == '#rec1:':
+           break
+-        print i
+-      print '''</pre>''' 
++        print(i)
++      print('''</pre>''') 
+ 
+-    print "<table border cellspacing=0 cellpadding=5>"
+-    print "<tr>"
++    print("<table border cellspacing=0 cellpadding=5>")
++    print("<tr>")
+     if self.display_summary_detail != 1:
+-      for x in xrange(self.field_total):
++      for x in range(self.field_total):
+         if self.field_display[x]:
+-          print " <th>", self.field_names[x], '''</th>'''
+-    print '''</tr>'''
++          print(" <th>", self.field_names[x], '''</th>''')
++    print('''</tr>''')
+   
+ #
+ #
+@@ -245,26 +245,26 @@ class ftrptfmt:
+       line = int(self.max_lines)
+       
+       for x in self.field_iter:
+-        print "<tr>"
+-        for y in xrange(self.field_total):
++        print("<tr>")
++        for y in range(self.field_total):
+           if self.field_display[y]:   
+             i = self.field_avals[x][y]
+-            print "  <td>", i, '''</td>'''
++            print("  <td>", i, '''</td>''')
+         if line:
+           line = line - 1
+           if not line:
+             break
+-        print '''</tr>'''
++        print('''</tr>''')
+ 
+     else:
+-      print '''<pre>''' 
++      print('''<pre>''') 
+       self._fmt_summary_detail()
+-      print '''</pre>''' 
++      print('''</pre>''') 
+ #
+ #
+ #
+   def fmt_html_footer(self) :
+-    print '''</table>'''
++    print('''</table>''')
+   
+ 
+ #
+@@ -348,7 +348,7 @@ class ftrptfmt:
+     
+           splt = string.split(line, ',')
+     
+-          for i in xrange(self.field_total):
++          for i in range(self.field_total):
+ 
+             if len(splt[i]) > self.field_lens[i]:
+               self.field_lens[i] = len(splt[i])
+@@ -365,7 +365,7 @@ class ftrptfmt:
+         break;
+ 
+     # default to sequentially as read
+-    self.field_iter = range(self.recno)
++    self.field_iter = list(range(self.recno))
+ 
+ #
+ #
+@@ -378,10 +378,10 @@ class ftrptfmt:
+     
+     # figure out which fields are okay to print
+     if self.field_use['all'] == 1:
+-      for x in xrange(self.field_total):
++      for x in range(self.field_total):
+         self.field_display[x] = 1
+     else:
+-      for x in xrange(self.field_total):
++      for x in range(self.field_total):
+         self.field_display[x] = self.field_use.get(self.field_names[x],0)
+ 
+ #
+@@ -405,8 +405,8 @@ class ftrptfmt:
+           self.field_iter.sort(lambda a,b: cmp(self.field_avals[a][i],
+             self.field_avals[b][i]))
+         else:
+-          self.field_iter.sort(lambda a,b: cmp(long(self.field_avals[a][i]),
+-            long(self.field_avals[b][i])))
++          self.field_iter.sort(lambda a,b: cmp(int(self.field_avals[a][i]),
++            int(self.field_avals[b][i])))
+ 
+       elif sort_field[0] == '-':
+ 
+@@ -419,8 +419,8 @@ class ftrptfmt:
+             self.field_avals[b][i]))
+ 
+         else:
+-          self.field_iter.sort(lambda b,a: cmp(long(self.field_avals[a][i]),
+-            long(self.field_avals[b][i])))
++          self.field_iter.sort(lambda b,a: cmp(int(self.field_avals[a][i]),
++            int(self.field_avals[b][i])))
+ 
+ #
+ #
+@@ -428,7 +428,7 @@ class ftrptfmt:
+   def mapsym(self):
+     
+     # foreach key field try to map in symbols
+-    for i in self.field_keys.keys():
++    for i in list(self.field_keys.keys()):
+       if self.field_display[i] != 1:
+         continue
+       n = self.field_names[i]
+@@ -445,14 +445,14 @@ class ftrptfmt:
+   def percent(self):
+ 
+     # foreach field
+-    for i in xrange(self.field_total):
++    for i in range(self.field_total):
+       # skip key fields
+       if self.field_keys.get(i,0) == 1:
+         continue
+       # for each value for the field
+       self.field_totals[i] = 0
+       for j in self.field_iter:
+-        self.field_totals[i] += long(self.field_avals[j][i])
++        self.field_totals[i] += int(self.field_avals[j][i])
+       for j in self.field_iter:
+         self.field_avals[j][i] = "%5.6f" % (float(self.field_avals[j][i]) / float(self.field_totals[i]) * 100)
+         # readjust field len
+@@ -515,13 +515,13 @@ for o,v in opts:
+   elif o == '-s':
+     opt_sort_field = v
+   elif o == '-h':
+-    print "Usage: flow-rptfmt [-hHnp] [-a alarm] [-f format] [-F display_fields]"
+-    print "                   [-m max_lines] [-s sort_field]"
++    print("Usage: flow-rptfmt [-hHnp] [-a alarm] [-f format] [-F display_fields]")
++    print("                   [-m max_lines] [-s sort_field]")
+     sys.exit(0)
+ 
+ 
+ def sig_alarm(sig, stack):
+-  print "flow-rptfmt exceeded CPU time, consider running report offline."
++  print("flow-rptfmt exceeded CPU time, consider running report offline.")
+   sys.exit(0)
+ 
+ signal.signal(signal.SIGALRM, sig_alarm)
+-- 
+2.51.0
+

diff --git a/flow-tools.spec b/flow-tools.spec
index 4e2b507..480162b 100644
--- a/flow-tools.spec
+++ b/flow-tools.spec
@@ -23,6 +23,8 @@ Patch0:  flow-werror-fix.patch
 # Fix extern usage
 Patch1:  flow-tools-extern.patch
 Patch2: flow-tools-c99.patch
+# Convert Python2 code to Python3
+Patch3:  Format-bin-flow-to-be-compatible-with-Python3.patch
 
 BuildRequires: gcc
 %if 0%{with openssl}
@@ -34,9 +36,6 @@ BuildRequires: zlib-devel
 BuildRequires: bison
 BuildRequires: flex
 BuildRequires: doxygen
-%if 0%{?fedora} >= 31
-BuildRequires: python3.12
-%endif
 BuildRequires: systemd-rpm-macros
 BuildRequires: make
 
@@ -103,7 +102,6 @@ This package contains additional documentation, such as man pages in html format
 %autosetup -p1
 # Remove /bin/env deps
 sed -i '1s|^#!.*python|#!/usr/bin/python3|' bin/flow*
-python3.12 -m lib2to3 --write --nobackups bin/flow*
 sed -i '1s|^#!.*perl|#!/usr/bin/perl|' utils/*
 # Fix mariadb-connector-c detection
 sed -i s/my_init/mysql_init/g configure

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-06-27 16:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-27 16:48 [rpms/flow-tools] rawhide: Convert Python files to Python 3 with a patch Karolina Surma

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox