From: Cédric Aguerre Date: Mon, 29 Feb 2016 10:40:39 +0000 (+0100) Subject: [EDF-12448] Only search in TCP ports (avoid "oserror [Errno 7] Argument list too... X-Git-Tag: V8_1_0a1~27 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=738b4a792c8bd1971e774c1ce3a412dd4986c45e;p=modules%2Fkernel.git [EDF-12448] Only search in TCP ports (avoid "oserror [Errno 7] Argument list too long" raised by python subprocess --- 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):