From 98c52bdea200574a1bfdd331dbf17aa653d26520 Mon Sep 17 00:00:00 2001 From: David James Date: Mon, 2 Aug 2010 21:21:17 -0700 Subject: [PATCH] Make the homedir check a bit simpler. Rather than using split, we can just use os.path.basename(path) to get the username from the homedir name. This is a bit simpler. I've also added a comment which I missed in my last commit. TEST=Ran ./parallel_emerge, verified the new method of getting PORTAGE_USERNAME gets the right username. BUG=none Review URL: http://codereview.chromium.org/3056002 --- parallel_emerge | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/parallel_emerge b/parallel_emerge index 5c7d82c373..fb5c8efcbd 100755 --- a/parallel_emerge +++ b/parallel_emerge @@ -60,9 +60,9 @@ import urllib2 # encounter this case unless they have an old chroot or blow away the # environment by running sudo without the -E specifier. if "PORTAGE_USERNAME" not in os.environ: - homedir = os.environ["HOME"] - if homedir.startswith("/home/"): - os.environ["PORTAGE_USERNAME"] = homedir.split("/")[2] + homedir = os.environ.get("HOME") + if homedir: + os.environ["PORTAGE_USERNAME"] = os.path.basename(homedir) # Portage doesn't expose dependency trees in its public API, so we have to # make use of some private APIs here. These modules are found under @@ -1050,6 +1050,8 @@ def EmergeWorker(task_queue, done_queue, emerge, package_db): opts, spinner = emerge.opts, emerge.spinner opts["--nodeps"] = True while True: + # Wait for a new item to show up on the queue. This is a blocking wait, + # so if there's nothing to do, we just sit here. target = task_queue.get() print "Emerging", target db_pkg = package_db[target]