Salome HOME
projects
/
modules
/
kernel.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge remote branch 'origin/V7_dev'
[modules/kernel.git]
/
bin
/
PortManager.py
diff --git
a/bin/PortManager.py
b/bin/PortManager.py
index 518b4eed9bf78b3bd3b75a3c64fa260c3e625737..d324bdebc4735bc13a51c005f599dc942b3f649f 100644
(file)
--- a/
bin/PortManager.py
+++ b/
bin/PortManager.py
@@
-1,6
+1,6
@@
#!/usr/bin/env python
# -*- coding: iso-8859-1 -*-
#!/usr/bin/env python
# -*- coding: iso-8859-1 -*-
-# Copyright (C) 2007-201
5
CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2007-201
6
CEA/DEN, EDF R&D, OPEN CASCADE
#
# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
#
# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@
-44,7
+44,7
@@
def createLogger():
logger = createLogger()
#------------------------------------
logger = createLogger()
#------------------------------------
-# A file locker
(Linux only)
+# A file locker
def __acquire_lock(lock):
if sys.platform == "win32":
import msvcrt
def __acquire_lock(lock):
if sys.platform == "win32":
import msvcrt
@@
-62,6
+62,7
@@
def __release_lock(lock):
import fcntl
fcntl.flock(lock, fcntl.LOCK_UN)
#
import fcntl
fcntl.flock(lock, fcntl.LOCK_UN)
#
+#------------------------------------
def _getConfigurationFilename():
omniorbUserPath = os.getenv("OMNIORB_USER_PATH")
def _getConfigurationFilename():
omniorbUserPath = os.getenv("OMNIORB_USER_PATH")
@@
-89,7
+90,10
@@
def __isNetworkConnectionActiveOnPort(port):
# netstat options -l and -t are unavailable
# grep command is unavailable
from subprocess import Popen, PIPE
# 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()
import StringIO
buf = StringIO.StringIO(stdout)
ports = buf.readlines()
@@
-102,6
+106,7
@@
def __isNetworkConnectionActiveOnPort(port):
if p == port: return True
except:
pass
if p == port: return True
except:
pass
+ return False
#
def getPort(preferedPort=None):
#
def getPort(preferedPort=None):
@@
-165,6
+170,7
@@
def releasePort(port):
logger.debug("RELEASE PORT (%s)"%port)
config_file, lock_file = _getConfigurationFilename()
logger.debug("RELEASE PORT (%s)"%port)
config_file, lock_file = _getConfigurationFilename()
+ oldmask = os.umask(0)
with open(lock_file, 'w') as lock:
# acquire lock
__acquire_lock(lock)
with open(lock_file, 'w') as lock:
# acquire lock
__acquire_lock(lock)
@@
-199,10
+205,14
@@
def releasePort(port):
__release_lock(lock)
logger.debug("released port port: %s"%str(port))
__release_lock(lock)
logger.debug("released port port: %s"%str(port))
+
+ os.umask(oldmask)
#
def getBusyPorts():
#
def getBusyPorts():
+ busy_ports = []
config_file, lock_file = _getConfigurationFilename()
config_file, lock_file = _getConfigurationFilename()
+ oldmask = os.umask(0)
with open(lock_file, 'w') as lock:
# acquire lock
__acquire_lock(lock)
with open(lock_file, 'w') as lock:
# acquire lock
__acquire_lock(lock)
@@
-222,5
+232,6
@@
def getBusyPorts():
# release lock
__release_lock(lock)
# release lock
__release_lock(lock)
- return busy_ports
+ os.umask(oldmask)
+ return busy_ports
#
#