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
#17872 [CEA] /tmp/.salome_PortManager.lock permission denied
[modules/kernel.git]
/
bin
/
PortManager.py
diff --git
a/bin/PortManager.py
b/bin/PortManager.py
index b135ab3b4a44e3faf03750513997e3bad8973c1f..e0584ac81529000f029ad5267f0b1b6a66dbd8b9 100644
(file)
--- a/
bin/PortManager.py
+++ b/
bin/PortManager.py
@@
-1,6
+1,6
@@
#!/usr/bin/env python3
# -*- coding: iso-8859-1 -*-
#!/usr/bin/env python3
# -*- coding: iso-8859-1 -*-
-# Copyright (C) 2007-201
7
CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2007-201
9
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
@@
-35,11
+35,11
@@
__PORT_MAX_NUMBER = 2910
import logging
def createLogger():
logger = logging.getLogger(__name__)
import logging
def createLogger():
logger = logging.getLogger(__name__)
-
#
logger.setLevel(logging.DEBUG)
+
#
logger.setLevel(logging.DEBUG)
logger.setLevel(logging.INFO)
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
logger.setLevel(logging.INFO)
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
- formatter = logging.Formatter("%(levelname)s:%(threadName)s:%(message)s")
+ formatter = logging.Formatter("%(levelname)s:%(threadName)s:%(
pathname)s[%(lineno)s]%(
message)s")
ch.setFormatter(formatter)
logger.addHandler(ch)
return logger
ch.setFormatter(formatter)
logger.addHandler(ch)
return logger
@@
-83,6
+83,11
@@
def _getConfigurationFilename():
import tempfile
temp = tempfile.NamedTemporaryFile()
lock_file = os.path.join(os.path.dirname(temp.name), ".salome_PortManager.lock")
import tempfile
temp = tempfile.NamedTemporaryFile()
lock_file = os.path.join(os.path.dirname(temp.name), ".salome_PortManager.lock")
+ try:
+ with open(lock_file, 'wb'):
+ pass
+ except IOError:
+ pass
temp.close()
return (portmanager_config, lock_file)
temp.close()
return (portmanager_config, lock_file)
@@
-100,7
+105,7
@@
def __isNetworkConnectionActiveOnPort(port):
# netstat options -l and -t are unavailable
# grep command is unavailable
if sys.platform == "win32":
# netstat options -l and -t are unavailable
# grep command is unavailable
if sys.platform == "win32":
- cmd = ['netstat','-a','-n','-p
tcp']
+ cmd = ['netstat','-a','-n','-p
','
tcp']
else:
cmd = ['netstat','-ant']
pass
else:
cmd = ['netstat','-ant']
pass
@@
-118,7
+123,7
@@
def __isNetworkConnectionActiveOnPort(port):
return False
from io import StringIO
return False
from io import StringIO
- buf = StringIO(out.decode())
+ buf = StringIO(out.decode(
'utf-8', 'ignore'
))
ports = buf.readlines()
# search for TCP - LISTEN connections
import re
ports = buf.readlines()
# search for TCP - LISTEN connections
import re
@@
-132,12
+137,12
@@
def __isNetworkConnectionActiveOnPort(port):
return False
#
return False
#
-def getPort(preferedPort=None):
+def getPort(prefer
r
edPort=None):
logger.debug("GET PORT")
config_file, lock_file = _getConfigurationFilename()
oldmask = os.umask(0)
logger.debug("GET PORT")
config_file, lock_file = _getConfigurationFilename()
oldmask = os.umask(0)
- with open(lock_file, '
w
b') as lock:
+ with open(lock_file, '
r
b') as lock:
# acquire lock
__acquire_lock(lock)
# acquire lock
__acquire_lock(lock)
@@
-159,7
+164,7
@@
def getPort(preferedPort=None):
config[appli_path] = []
# append port
config[appli_path] = []
# append port
- port = preferedPort
+ port = prefer
r
edPort
if not port or __isPortUsed(port, config):
port = __PORT_MIN_NUMBER
while __isPortUsed(port, config):
if not port or __isPortUsed(port, config):
port = __PORT_MIN_NUMBER
while __isPortUsed(port, config):
@@
-177,7
+182,7
@@
def getPort(preferedPort=None):
logger.debug("write config: %s"%str(config))
try:
with open(config_file, 'wb') as f:
logger.debug("write config: %s"%str(config))
try:
with open(config_file, 'wb') as f:
- pickle.dump(config, f)
+ pickle.dump(config, f
, protocol=0
)
except IOError:
pass
except IOError:
pass
@@
-196,7
+201,7
@@
def releasePort(port):
config_file, lock_file = _getConfigurationFilename()
oldmask = os.umask(0)
config_file, lock_file = _getConfigurationFilename()
oldmask = os.umask(0)
- with open(lock_file, '
w
b') as lock:
+ with open(lock_file, '
r
b') as lock:
# acquire lock
__acquire_lock(lock)
# acquire lock
__acquire_lock(lock)
@@
-224,7
+229,7
@@
def releasePort(port):
logger.debug("write config: %s"%str(config))
try:
with open(config_file, 'wb') as f:
logger.debug("write config: %s"%str(config))
try:
with open(config_file, 'wb') as f:
- pickle.dump(config, f)
+ pickle.dump(config, f
, protocol=0
)
except IOError:
pass
except IOError:
pass