From 738b4a792c8bd1971e774c1ce3a412dd4986c45e 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 653258713..d324bdebc 100644 --- a/bin/PortManager.py +++ b/bin/PortManager.py @@ -90,7 +90,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() @@ -103,6 +106,7 @@ def __isNetworkConnectionActiveOnPort(port): if p == port: return True except: pass + return False # def getPort(preferedPort=None): -- 2.39.2