Bug 251054 - net-mgmt/flow-tools: errors with Python 3.7
Summary: net-mgmt/flow-tools: errors with Python 3.7
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Muhammad Moinur Rahman
URL:
Keywords: buildisok
Depends on:
Blocks:
 
Reported: 2020-11-11 16:42 UTC by Andrew
Modified: 2021-02-13 12:39 UTC (History)
2 users (show)

See Also:
bugzilla: maintainer-feedback? (bofh)


Attachments
patch-flow-log2rrd (264 bytes, patch)
2020-11-11 18:01 UTC, Volodymyr Pushkar
no flags Details | Diff
patch-flow-rpt2rrd (2.44 KB, patch)
2020-11-11 18:01 UTC, Volodymyr Pushkar
no flags Details | Diff
patch-flow-rptfmt (1.99 KB, patch)
2020-11-11 18:02 UTC, Volodymyr Pushkar
no flags Details | Diff
Patch for the port maintainer (6.76 KB, patch)
2020-11-11 18:24 UTC, Andrew
no flags Details | Diff
Current patched port (4.64 KB, application/octet-stream)
2021-01-23 11:16 UTC, Andrew
no flags Details
Patch for the whole port #2 (8.95 KB, patch)
2021-02-06 10:20 UTC, Volodymyr Pushkar
vladimir.pushkar: maintainer-approval? (bofh)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew 2020-11-11 16:42:49 UTC
After transition from python 2.7 to 3.7, flow-report(1) seems to have some issues... for example:

# flow-cat ft-v05.2020-06-19.000001+0200 | flow-report 
Traceback (most recent call last):
  File "/usr/local/bin/flow-rptfmt", line 533, in <module>
    rpt.load(sys.stdin, opt_sort_field, opt_max_lines, opt_percent)
  File "/usr/local/bin/flow-rptfmt", line 297, in load
    splt = string.split(line2,',')
AttributeError: module 'string' has no attribute 'split'
flow-report: pclose(flow-rptfmt -f ascii): failed exit code=1.

Another example:

# flow-cat ft-v05.2020-06-19.000001+0200 | flow-report -v TYPE=ip-destination-address/ip-destination-port -v SORT=+octets -v OPTIONS=-header
Traceback (most recent call last):
  File "/usr/local/bin/flow-rptfmt", line 533, in <module>
    rpt.load(sys.stdin, opt_sort_field, opt_max_lines, opt_percent)
  File "/usr/local/bin/flow-rptfmt", line 324, in load
    for i in string.split(line[8:],','):
AttributeError: module 'string' has no attribute 'split'
flow-report: pclose(flow-rptfmt -f ascii): failed exit code=1.


As asked in bug #249388, comment #6, here is the content of /usr/local/etc/cfg/stat.cfg:

stat-report default
  type @{TYPE:-summary-detail}
  output
    format ascii
    sort @{SORT:-+}
    fields @{FIELDS:-+}
    options @{OPTIONS:-+header,+xheader,+totals}
    path |flow-rptfmt @{RPTOPT:--f ascii}

stat-definition default
  report default
Comment 1 Volodymyr Pushkar 2020-11-11 18:01:19 UTC
Created attachment 219567 [details]
patch-flow-log2rrd
Comment 2 Volodymyr Pushkar 2020-11-11 18:01:47 UTC
Created attachment 219568 [details]
patch-flow-rpt2rrd
Comment 3 Volodymyr Pushkar 2020-11-11 18:02:07 UTC
Created attachment 219569 [details]
patch-flow-rptfmt
Comment 4 Volodymyr Pushkar 2020-11-11 18:03:39 UTC
I attached patches for this port, please try it out. Looking for port update.
Comment 5 Andrew 2020-11-11 18:24:30 UTC
Created attachment 219570 [details]
Patch for the port maintainer

(In reply to Volodymyr Pushkar from comment #4)

Wonderful, thank you Vlad: I just tested them and they look like working for me!

I merged them all in this patch for port's maintainer.
Comment 6 Automation User 2020-11-26 00:16:27 UTC
Build and package info is available at https://gitlab.com/swills/freebsd-ports/pipelines/221374697
Comment 7 Andrew 2021-01-23 11:16:27 UTC
Created attachment 221834 [details]
Current patched port

(In reply to Volodymyr Pushkar from comment #4)

Sorry to disturb you again Vlad, but I just applied your patches to the latest port version on FreeBSD 12.2/amd64, and the issue raised again:

# flow-cat ft-v05.2021-01-23.113001+0100  | flow-report -v OPTIONS=-header -v SORT=+octets -v TYPE=ip-source-address/ip-destination-port
Traceback (most recent call last):
  File "/usr/local/bin/flow-rptfmt", line 533, in <module>
    rpt.load(sys.stdin, opt_sort_field, opt_max_lines, opt_percent)
  File "/usr/local/bin/flow-rptfmt", line 324, in load
    for i in string.split(line[8:],','):
AttributeError: module 'string' has no attribute 'split'
flow-report: pclose(flow-rptfmt -f ascii): failed exit code=1.


Please find attached the patched files I'm using to build the package from.
Comment 8 Volodymyr Pushkar 2021-01-24 07:32:11 UTC
(In reply to Andrew from comment #7)

Just checked on my system (I use python 3.8 if this matters) and everything works fine with your patch:

#  ['/usr/local/bin/flow-rptfmt', '-f', 'ascii']
ip-source-address ip-destination-port flows octets packets duration
10.12.37.1        0                   15    28182  197     750017
10.12.32.4        0                   15    25324  198     769031

According to the error you are getting, it looks like your files are not patched.
Please check for availability of the following files:

#/usr/ports/net-mgmt/flow-tools>ls -la files/patch-flow-* | grep -v orig
-rw-r--r--  1 root  wheel   264 24 янв.  09:26 files/patch-flow-log2rrd
-rw-r--r--  1 root  wheel  2505 24 янв.  09:26 files/patch-flow-rpt2rrd
-rw-r--r--  1 root  wheel  2034 24 янв.  09:26 files/patch-flow-rptfmt
Comment 9 Andrew 2021-01-24 09:43:59 UTC
(In reply to Volodymyr Pushkar from comment #8)

I'm so sorry... I simply missed to apply files/patch-flow-rptfmt: it's still working (I'm using Python 3.7). Thank you Vlad!

It would be also nice if someone with the commit bit might apply the patch to SVN/Git Ports tree, thus we'll be able to close this bug report.
Comment 10 Volodymyr Pushkar 2021-02-06 10:20:58 UTC
Created attachment 222203 [details]
Patch for the whole port #2

Added additional patches for lib/ftpaths.c, pkg-plist, and Makefile. Bumped PORTREVISION once again. Now flow-filter and flow-nfilter will look into /usr/local/etc/flow-tools instead of missing /usr/local/etc/sym or /usr/local/etc/cfg. Also files under /usr/local/etc/flow-tools covered by '@sample' in pkg-plist which gives us samples (.sample suffix) and prevents modified configs from overwriting.
Comment 11 Muhammad Moinur Rahman freebsd_committer freebsd_triage 2021-02-11 00:15:18 UTC
Hi,

Thanks for the patch. I am sorry that I have been AFK for a while due to travels and getting positive and stranded on a foreign soil. However I am back now and committing.

Just to make sure that there are two patches now. Can anyone confirm please which one I should actually use? Moreover I am actually maintaining standalone flow-tools here at https://github.com/5u623l20/flow-tools/ to reduce patch clutters in the ports itself.
Comment 12 Volodymyr Pushkar 2021-02-11 05:08:44 UTC
Hello, welcome back ;)
The last added one includes all previous and also the new one.
Comment 13 commit-hook freebsd_committer freebsd_triage 2021-02-13 12:38:05 UTC
A commit references this bug:

Author: bofh
Date: Sat Feb 13 12:37:53 UTC 2021
New revision: 565131
URL: https://svnweb.freebsd.org/changeset/ports/565131

Log:
  net-mgmt/flow-tools: Fix config path

  - Fix errors with python3.7 [1]

  PR:	251054 [1] , 252131
  Submitted by:	vladimir.pushkar@gmail.com [1]
  Reported by:	may@vlant.ru , andrew.hotlab@hotmail.com [1]

Changes:
  head/net-mgmt/flow-tools/Makefile
  head/net-mgmt/flow-tools/distinfo
  head/net-mgmt/flow-tools/files/patch-lib_ftxlate.c
  head/net-mgmt/flow-tools/files/patch-src_acl2.c
  head/net-mgmt/flow-tools/pkg-plist