diff mbox

[Branch,~linaro-validation/lava-dispatcher/trunk] Rev 201: Workaround for license acceptance from ChiThu

Message ID 20120124050019.26976.92758.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Paul Larson Jan. 24, 2012, 5 a.m. UTC
Merge authors:
  Le Chi Thu le.chi.thu@linaro.org <le.chi.thu@linaro.org>
Related merge proposals:
  https://code.launchpad.net/~le-chi-thu/lava-dispatcher/snowball-license-auto-accept/+merge/89613
  proposed by: Le Chi Thu (le-chi-thu)
  review: Approve - Paul Larson (pwlars)
  review: Resubmit - Le Chi Thu (le-chi-thu)
------------------------------------------------------------
revno: 201 [merge]
committer: Paul Larson <paul.larson@linaro.org>
branch nick: lava-dispatcher
timestamp: Mon 2012-01-23 22:58:01 -0600
message:
  Workaround for license acceptance from ChiThu
modified:
  lava_dispatcher/client/lmc_utils.py


--
lp:lava-dispatcher
https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk

You are subscribed to branch lp:lava-dispatcher.
To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'lava_dispatcher/client/lmc_utils.py'
--- lava_dispatcher/client/lmc_utils.py	2012-01-12 20:38:57 +0000
+++ lava_dispatcher/client/lmc_utils.py	2012-01-22 22:39:22 +0000
@@ -1,10 +1,13 @@ 
 from commands import getoutput, getstatusoutput
 import contextlib
 import logging
+import pexpect
 import re
 import os
 import shutil
 from tempfile import mkdtemp
+import sys
+import time
 
 from lava_dispatcher.client.base import CriticalError
 from lava_dispatcher.utils import (
@@ -98,19 +101,8 @@ 
     client.context.test_data.add_metadata(metadata)
 
     image_file = os.path.join(tarball_dir, "lava.img")
-    #XXX Hack for removing startupfiles from snowball hwpacks
+
     logging.info("client.device_type = %s" %client.device_type)
-    if client.device_type == "snowball":
-        logging.info("Remove startupfiles from snowball")
-	cmd = "sudo linaro-hwpack-replace -r startupfiles-v3 -t %s -i" % hwpack_path
-        rc, output = getstatusoutput(cmd)
-        if rc:
-            raise RuntimeError("linaro-hwpack-replace failed: %s" % output)
-
-        cmd = "sudo linaro-hwpack-replace -r startupfiles -t %s -i" % hwpack_path
-        rc, output = getstatusoutput(cmd)
-        if rc:
-            raise RuntimeError("linaro-hwpack-replace failed: %s" % output)
 
     cmd = ("sudo flock /var/lock/lava-lmc.lck linaro-media-create --hwpack-force-yes --dev %s "
            "--image-file %s --binary %s --hwpack %s --image-size 3G" %
@@ -119,7 +111,7 @@ 
         cmd += ' --rootfs ' + rootfstype
     logging.info("Executing the linaro-media-create command")
     logging.info(cmd)
-    rc, output = getstatusoutput(cmd)
+    rc = run_dispatcher_snowball_license_fix(cmd)
     if rc:
         shutil.rmtree(tarball_dir)
         raise RuntimeError("linaro-media-create failed: %s" % output)
@@ -152,3 +144,37 @@ 
     finally:
         logging_system('sudo umount ' + mntdir)
         logging_system('rm -rf ' + mntdir)
+
+def run_dispatcher_snowball_license_fix(cmd):
+    try:
+        proc = pexpect.spawn(cmd, logfile=sys.stdout)
+        done = False
+
+        while not done:
+            id = proc.expect(["SNOWBALL CLICK-WRAP",
+                              "Do you accept the",
+                              "Configuring startupfiles",
+                              "Configuring ux500-firmware",
+                              "Configuring lbsd",
+                              "Configuring mali400-dev",
+                              pexpect.EOF], timeout=2400)
+            if id == 0:
+                proc.send('\t')
+                time.sleep(1)
+                proc.send('\r')
+
+            elif id == 1:
+                if not mali400:
+                    proc.send('\t')
+                time.sleep(1)
+                proc.send('\r')
+            elif id == 6:
+                done = True
+            elif id == 5:
+                mali400 = True
+            else:
+                mali400 = False
+    except pexpect.ExceptionPexpect:
+        return 1
+
+    return 0