summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2010-09-03 22:51:59 -0700
committerZac Medico <zmedico@gentoo.org>2010-09-03 22:51:59 -0700
commit4ea10d332bb291aaad99b43629681da43f4a51f2 (patch)
treec5ad06241bf4c12c3e0eaa70d7f82ab699b42631
parentce3f72b79f21e96003e075cb2f08faf8787df7da (diff)
downloadportage-4ea10d332bb291aaad99b43629681da43f4a51f2.tar.gz
portage-4ea10d332bb291aaad99b43629681da43f4a51f2.tar.bz2
portage-4ea10d332bb291aaad99b43629681da43f4a51f2.zip
Make portage.locks avoid importing the portage.output module when in
quiet mode. This is one less import triggered by ebuild-ipc.py, which should be as lightweight as possible.
-rw-r--r--pym/portage/locks.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/pym/portage/locks.py b/pym/portage/locks.py
index 476143cdc..62380ceea 100644
--- a/pym/portage/locks.py
+++ b/pym/portage/locks.py
@@ -17,7 +17,6 @@ from portage.const import PORTAGE_BIN_PATH
from portage.exception import DirectoryNotFound, FileNotFound, \
InvalidData, TryAgain, OperationNotPermitted, PermissionDenied
from portage.data import portage_gid
-from portage.output import EOutput
from portage.util import writemsg
from portage.localization import _
@@ -121,21 +120,26 @@ def lockfile(mypath, wantnewlockfile=0, unlinkfile=0,
raise TryAgain(mypath)
global _quiet
- out = EOutput()
- out.quiet = _quiet
+ if _quiet:
+ out = None
+ else:
+ out = portage.output.EOutput()
if waiting_msg is None:
if isinstance(mypath, int):
waiting_msg = _("waiting for lock on fd %i") % myfd
else:
waiting_msg = _("waiting for lock on %s\n") % lockfilename
- out.ebegin(waiting_msg)
+ if out is not None:
+ out.ebegin(waiting_msg)
# try for the exclusive lock now.
try:
fcntl.lockf(myfd, fcntl.LOCK_EX)
except EnvironmentError as e:
- out.eend(1, str(e))
+ if out is not None:
+ out.eend(1, str(e))
raise
- out.eend(os.EX_OK)
+ if out is not None:
+ out.eend(os.EX_OK)
elif e.errno == errno.ENOLCK:
# We're not allowed to lock on this FS.
os.close(myfd)