Clean up constants and fix handling of assertion errors in init.

Added much more logging, a little bit of refactoring and
some clean up in init to make debugging issues easier.

BUG=None
TEST=Ran on an alex.

Change-Id: I67cc2d2840643346d84dee1cafc1874ecd239c96
Reviewed-on: http://gerrit.chromium.org/gerrit/4443
Reviewed-by: Craig Harrison <craigdh@google.com>
Reviewed-by: Chris Sosa <sosa@chromium.org>
Tested-by: Chris Sosa <sosa@chromium.org>
diff --git a/server/cros/servotest.py b/server/cros/servotest.py
index 465dff3..2712089 100755
--- a/server/cros/servotest.py
+++ b/server/cros/servotest.py
@@ -4,7 +4,8 @@
 
 import subprocess
 
-from autotest_lib.server import test, autotest
+from autotest_lib.client.common_lib import error
+from autotest_lib.server import test
 import autotest_lib.server.cros.servo
 
 class ServoTest(test.test):
@@ -20,11 +21,18 @@
     def initialize(self, host, servo_port, xml_config='servo.xml',
                    servo_vid=None, servo_pid=None, servo_serial=None):
         """Create a Servo object."""
-        self.servo = autotest_lib.server.cros.servo.Servo(servo_port,
-                                                          xml_config,
-                                                          servo_vid,
-                                                          servo_pid,
-                                                          servo_serial)
+        self.servo = autotest_lib.server.cros.servo.Servo(
+                servo_port, xml_config, servo_vid, servo_pid, servo_serial)
+
+        # Initializes dut, may raise AssertionError if pre-defined gpio
+        # sequence to set GPIO's fail.  Autotest does not handle exception
+        # throwing in initialize and will cause a test to hang.
+        try:
+            self.servo.initialize_dut()
+        except AssertionError as e:
+            del self.servo
+            raise error.TestFail(e)
+
         self._ip = host.ip
 
 
@@ -51,4 +59,4 @@
 
     def cleanup(self):
         """Delete the Servo object."""
-        del self.servo
+        if self.servo: del self.servo