Add support for installing presenter on non-CrOS device

With this change, we can install the presenter on a non-CrOS device by
running:

  install_factory_toolkit.run -- --non-cros --enable-presenter \
      --no-enable-device

and run the presenter by:

  sudo /usr/local/factory/sh/start_presenter.sh

On Ubuntu 14.04, the prerequisites include:
  - Google Chrome
  - python-yaml
  - python-netifaces
  - python-numpy
  - python-jsonrpclib
  - python-ws4py

BUG=chrome-os-partner:36843
TEST=Install and run the presenter on Ubuntu 14.04.

Change-Id: I11e1a6c979c263b6d5e7c21ddc72025be140cce5
Signed-off-by: Vic Yang <victoryang@google.com>
Reviewed-on: https://chromium-review.googlesource.com/250664
Tested-by: Vic Yang <victoryang@chromium.org>
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Commit-Queue: Vic Yang <victoryang@chromium.org>
diff --git a/py/toolkit/installer.py b/py/toolkit/installer.py
index 37f1c5d..a371e7e 100755
--- a/py/toolkit/installer.py
+++ b/py/toolkit/installer.py
@@ -113,7 +113,7 @@
   _sudo = True
 
   def __init__(self, src, dest, no_enable, enable_presenter,
-               enable_device, system_root='/'):
+               enable_device, non_cros=False, system_root='/'):
     self._src = src
     self._system_root = system_root
     if dest == self._system_root:
@@ -121,7 +121,7 @@
       self._var_dest = os.path.join(dest, 'var')
 
       # Make sure we're on a CrOS device.
-      if not _in_cros_device():
+      if not non_cros and not _in_cros_device():
         sys.stderr.write(
             "ERROR: You're not on a CrOS device (for more details, please\n"
             'check utils.py:in_cros_device), so you must specify a test\n'
@@ -130,7 +130,14 @@
             '\n'
             '  install_factory_toolkit.run -- --help\n'
             '\n'
-            'for help.\n')
+            'for help.\n'
+            '\n'
+            'If you want to install the presenter on a non-CrOS host,\n'
+            'please run\n'
+            '\n'
+            '  install_factory_toolkit.run -- \\\n'
+            '      --non-cros --no-enable-device --enable-presenter\n'
+            '\n')
         sys.exit(1)
       if os.getuid() != 0:
         raise Exception('You must be root to install the factory toolkit on a '
@@ -365,6 +372,10 @@
                       action='store_false', help=argparse.SUPPRESS)
   parser.set_defaults(enable_presenter=True)
 
+  parser.add_argument('--non-cros', dest='non_cros',
+                      action='store_true',
+                      help='Install on non-ChromeOS host.')
+
   parser.add_argument('--enable-device', dest='enable_device',
                       action='store_true',
                       help='Run goofy in device mode on startup')
@@ -429,7 +440,7 @@
         else DummyContext(args.dest)) as dest:
     installer = FactoryToolkitInstaller(
         src_root, dest, args.no_enable, args.enable_presenter,
-        args.enable_device)
+        args.enable_device, args.non_cros)
 
     print installer.WarningMessage(args.dest if patch_test_image else None)