Consistent use of OS detection and host added to Win users.
svn: r15932
This commit is contained in:
parent
90f23818c4
commit
7abb29d568
@ -58,6 +58,7 @@ from gen.db.dbconst import *
|
||||
from gen.utils.callback import Callback
|
||||
from gen.updatecallback import UpdateCallback
|
||||
import Errors
|
||||
import constfunc
|
||||
|
||||
_LOG = logging.getLogger(DBLOGNAME)
|
||||
_MINVERSION = 9
|
||||
@ -1804,8 +1805,12 @@ def write_lock_file(name):
|
||||
if not os.path.isdir(name):
|
||||
os.mkdir(name)
|
||||
f = open(os.path.join(name, DBLOCKFN), "w")
|
||||
if os.name == 'nt':
|
||||
text = os.environ['USERNAME']
|
||||
if constfunc.win():
|
||||
user = os.environ['USERNAME']
|
||||
try:
|
||||
host = os.environ['USERDOMAIN']
|
||||
except:
|
||||
host = ""
|
||||
else:
|
||||
host = os.uname()[1]
|
||||
# An ugly workaround for os.getlogin() issue with Konsole
|
||||
@ -1813,7 +1818,10 @@ def write_lock_file(name):
|
||||
user = os.getlogin()
|
||||
except:
|
||||
user = os.environ.get('USER')
|
||||
if host:
|
||||
text = "%s@%s" % (user, host)
|
||||
else:
|
||||
text = user
|
||||
# Save only the username and host, so the massage can be
|
||||
# printed with correct locale in DbManager.py when a lock is found
|
||||
f.write(text)
|
||||
|
Loading…
Reference in New Issue
Block a user