Clean up _get_autodir in autotest.py a bit. Adds in some more logging
to make it easier to see what decisions it's making, and changes
the final fallback to checking /usr/local/autotest and /home/autotest
to just look for the directories, rather than an installed client.
Only checking for existing clients at those locations is inconsistent
with the other checks this call does.

Risk: Medium
Visibility: Adds logging to autotest._get_autodir and adjusts its
search to be more consistent.

Signed-off-by: John Admanski <jadmanski@google.com>



git-svn-id: http://test.kernel.org/svn/autotest/trunk@3166 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/server/autotest.py b/server/autotest.py
index bf8f90d..3f4e5fb 100644
--- a/server/autotest.py
+++ b/server/autotest.py
@@ -679,23 +679,26 @@
 def _get_autodir(host):
     autodir = host.get_autodir()
     if autodir:
+        logging.debug('Using existing host autodir: %s', autodir)
         return autodir
     try:
         # There's no clean way to do this. readlink may not exist
-        cmd = "python -c 'import os,sys; print os.readlink(sys.argv[1])' /etc/autotest.conf 2> /dev/null"
+        cmd = ("python -c '%s' /etc/autotest.conf 2> /dev/null"
+               % "import os,sys; print os.readlink(sys.argv[1])")
         autodir = os.path.dirname(host.run(cmd).stdout)
         if autodir:
+            logging.debug('Using autodir from /etc/autotest.conf: %s', autodir)
             return autodir
     except error.AutoservRunError:
         pass
     for path in ['/usr/local/autotest', '/home/autotest']:
         try:
-            host.run('ls %s > /dev/null 2>&1' %
-                     os.path.join(path, 'bin/autotest'))
+            host.run('ls %s > /dev/null 2>&1' % path)
+            logging.debug('Found autodir at %s', path)
             return path
         except error.AutoservRunError:
-            pass
-    raise error.AutotestRunError("Cannot figure out autotest directory")
+            logging.debug('%s does not exist', path)
+    raise error.AutotestRunError('Cannot figure out autotest directory')
 
 
 class log_collector(object):