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: V7_8_0a2^0 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=41c500294851087709b3fb73f3185635fe188e2d;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 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):