From 41c500294851087709b3fb73f3185635fe188e2d Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=A9dric=20Aguerre?= Date: Mon, 29 Feb 2016 11:40:39 +0100 Subject: [PATCH] [EDF-12448] Only search in TCP ports (avoid "oserror [Errno 7] Argument list too long" raised by python subprocess --- bin/PortManager.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bin/PortManager.py b/bin/PortManager.py index 999166106..a3b24a0f1 100644 --- a/bin/PortManager.py +++ b/bin/PortManager.py @@ -89,7 +89,10 @@ def __isNetworkConnectionActiveOnPort(port): # netstat options -l and -t are unavailable # grep command is unavailable from subprocess import Popen, PIPE - stdout, _ = Popen(['netstat','-an'], stdout=PIPE).communicate() + if sys.platform == "win32": + stdout, _ = Popen(['netstat','-a','-n','-p tcp'], stdout=PIPE).communicate() + else: + stdout, _ = Popen(['netstat','-ant'], stdout=PIPE).communicate() import StringIO buf = StringIO.StringIO(stdout) ports = buf.readlines() @@ -102,6 +105,7 @@ def __isNetworkConnectionActiveOnPort(port): if p == port: return True except: pass + return False # def getPort(preferedPort=None): -- 2.39.2