Bug 247437 - net-mgmt/flow-tools: Fails to run with Python 3.x
Summary: net-mgmt/flow-tools: Fails to run with Python 3.x
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-06-20 10:48 UTC by Andrew
Modified: 2020-07-22 06:11 UTC (History)
2 users (show)

See Also:
bugzilla: maintainer-feedback? (bofh)
lcook: merge-quarterly?


Attachments
Unuseful patch to flow-rptfmt (7.48 KB, patch)
2020-06-20 11:08 UTC, Andrew
andrew.hotlab: maintainer-approval-
Details | Diff
Makefile patch to depend on Python 2.7 (370 bytes, patch)
2020-06-20 15:58 UTC, Andrew
no flags Details | Diff
flow-tools-0.68.6_2.diff (1.74 KB, patch)
2020-06-20 16:08 UTC, Lewis Cook
lcook: maintainer-approval?
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew 2020-06-20 10:48:48 UTC
I just discovered that building this port with the default Python version (at this time, the 3.7 branch) breaks flow-report(1) because of (I guess) Python's syntax changes. Here is an example:

% flow-cat 2020-06-19 | flow-report -v TYPE=ip-destination-address/ip-source-port
  File "/usr/local/bin/flow-rptfmt", line 113
    print "Ignores:                 %s" % self.field_vals['ignores']
                                      ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print("Ignores:                 %s" % self.field_vals['ignores'])?
flow-report: pclose(flow-rptfmt -f ascii): failed exit code=1.



I do not know Python, but I tried to fix it by adding parentheses to the print() calls to the file /usr/local/bin/flow-rptfmt, but I was only able to go a bit further, and I gave up with this:

  File "/usr/local/bin/flow-rptfmt", line 175
    print i.ljust(self.field_lens[y]),
          ^
SyntaxError: invalid syntax
flow-report: pclose(flow-rptfmt -f ascii): failed exit code=1.
Comment 1 Andrew 2020-06-20 11:08:20 UTC
Created attachment 215810 [details]
Unuseful patch to flow-rptfmt

Helping myself with a Python code checker, I managed to create the attached patch, which however does not seems to fully solve the problems yet. I ended up with this new error:

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.
Comment 2 Kubilay Kocak freebsd_committer freebsd_triage 2020-06-20 14:58:33 UTC
If the software doesn't support Python 3.* (or 3.7 specifically), the current USES=python:<version-spec> should be corrected.

A cursory search of the flow-tools codebase didnt identify an explicit claim or declaration on what versions it *should* support. That the code base is close to 12 years old with only minor changes in the fork, its pretty safe to say this should be USES=python:2.7. 

If it supports some Python 3.x versions but not others, it would be good to obtain explicit verification of this, and which versions they are, so that those specific issues can be isolated and addressed upstream
Comment 3 Andrew 2020-06-20 15:58:53 UTC
Created attachment 215815 [details]
Makefile patch to depend on Python 2.7

Ok, I just tested this patch to the port's Makefile, which makes it dependent on Python 2.7 (still "supported" until the end of 2020).

I guess we might consider the issue solved for now, but the maintainer will likely need to decide if it's sill worth to make net-mgmt/flow-tools alive.

Thanks!
Comment 4 Lewis Cook freebsd_committer freebsd_triage 2020-06-20 16:08:49 UTC
Created attachment 215816 [details]
flow-tools-0.68.6_2.diff

* Explicitly set python version-spec (else fails with python3-*)
* Fix stage-qa message and strip installed library
* pet portclippy

Thought I'd chime in and address some additional issues. :)

QA:

 * portlint: OK (looks fine).
 * testport: OK (poudriere: 12amd64)
Comment 5 Andrew 2020-06-20 16:27:35 UTC
Comment on attachment 215815 [details]
Makefile patch to depend on Python 2.7

Thank you Lewis. I just tested it and it works for me.
Comment 6 Automation User 2020-07-05 00:09:12 UTC
Build info is available at https://gitlab.com/swills/freebsd-ports/pipelines/163159618
Comment 7 Muhammad Moinur Rahman freebsd_committer freebsd_triage 2020-07-10 15:38:11 UTC
Will do build test and commit soon.
Comment 8 commit-hook freebsd_committer freebsd_triage 2020-07-22 06:10:23 UTC
A commit references this bug:

Author: bofh
Date: Wed Jul 22 06:09:53 UTC 2020
New revision: 542834
URL: https://svnweb.freebsd.org/changeset/ports/542834

Log:
  net-mgmt/flow-tools: Fix run with python3

  - Pet portlint

  PR:		247437
  Submitted by:	andrew.hotlab@hotmail.com

Changes:
  head/net-mgmt/flow-tools/Makefile