From 7abb29d5680d838cf2515294d8ba946dfbe60c4d Mon Sep 17 00:00:00 2001 From: Peter Landgren Date: Mon, 27 Sep 2010 17:54:22 +0000 Subject: [PATCH] Consistent use of OS detection and host added to Win users. svn: r15932 --- src/gen/db/write.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/gen/db/write.py b/src/gen/db/write.py index 46d8ac563..21ff41f6a 100644 --- a/src/gen/db/write.py +++ b/src/gen/db/write.py @@ -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)