:return user name
"""
- return os.getenv('USERNAME', 'unknown') if sys.platform == 'win32' \
- else os.getenv('USER', os.getenv('LOGNAME', 'unknown'))
+ if sys.platform == 'win32':
+ username = os.getenv('USERNAME')
+ else:
+ username = os.getenv('USER', os.getenv('LOGNAME'))
+ if username is None:
+ import getpass
+ username = getpass.getuser()
+ return username
# ---
"""
return os.getenv('APPNAME', 'SALOME') # 'SALOME' is default user name
+def getPid():
+ return os.getpid()
+
# ---
def getPortNumber(use_default=True):
- with_hostname : use host name:
- with_port : use port number:
- with_app : use application name:
+ - with_pid : use current pid
Any of these keyword arguments can accept either explicit string value,
or `True` to automatically deduce value from current configuration.
_with_kwarg('with_hostname', getShortHostName)
_with_kwarg('with_port', getPortNumber)
_with_kwarg('with_app', getAppName)
+ _with_kwarg('with_pid', getPid)
_with_str(suffix)
# raise an exception if file name is empty