From patchwork Mon Jan 30 17:57:14 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Larson X-Patchwork-Id: 6446 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 6299A249CE for ; Mon, 30 Jan 2012 17:57:15 +0000 (UTC) Received: from mail-bk0-f52.google.com (mail-bk0-f52.google.com [209.85.214.52]) by fiordland.canonical.com (Postfix) with ESMTP id 51C61A1815D for ; Mon, 30 Jan 2012 17:57:15 +0000 (UTC) Received: by mail-bk0-f52.google.com with SMTP id r19so4568550bka.11 for ; Mon, 30 Jan 2012 09:57:15 -0800 (PST) Received: by 10.205.130.12 with SMTP id hk12mr8921375bkc.56.1327946235139; Mon, 30 Jan 2012 09:57:15 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.204.130.220 with SMTP id u28cs159766bks; Mon, 30 Jan 2012 09:57:15 -0800 (PST) Received: by 10.180.89.71 with SMTP id bm7mr24917276wib.20.1327946234536; Mon, 30 Jan 2012 09:57:14 -0800 (PST) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id t44si10632716weq.121.2012.01.30.09.57.14 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 30 Jan 2012 09:57:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) client-ip=91.189.90.7; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) smtp.mail=bounces@canonical.com Received: from ackee.canonical.com ([91.189.89.26]) by indium.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1RrvTe-0004Fg-Ae for ; Mon, 30 Jan 2012 17:57:14 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 47577E0442 for ; Mon, 30 Jan 2012 17:57:14 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: lava-dispatcher X-Launchpad-Branch: ~linaro-validation/lava-dispatcher/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 211 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-validation/lava-dispatcher/trunk] Rev 211: Refactor click-through workaround and add support for omap3 hwpacks Message-Id: <20120130175714.11573.8285.launchpad@ackee.canonical.com> Date: Mon, 30 Jan 2012 17:57:14 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="14727"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: 3d5d55c66b19e2289f6da6eb1e85c6d79c3c94e7 Merge authors: Michael Hudson-Doyle (mwhudson) Related merge proposals: https://code.launchpad.net/~mwhudson/lava-dispatcher/omap3-clickthroughs/+merge/90641 proposed by: Michael Hudson-Doyle (mwhudson) review: Approve - Zygmunt Krynicki (zkrynicki) ------------------------------------------------------------ revno: 211 [merge] committer: Paul Larson branch nick: lava-dispatcher timestamp: Mon 2012-01-30 11:54:30 -0600 message: Refactor click-through workaround and add support for omap3 hwpacks modified: doc/changes.rst 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 === modified file 'doc/changes.rst' --- doc/changes.rst 2012-01-30 17:51:11 +0000 +++ doc/changes.rst 2012-01-30 17:54:30 +0000 @@ -7,6 +7,8 @@ ================================ * Add new android_install_binaries action * Fix problem when reporting failure messages that contain unicode +* Refactor click-through workaround, and add support for new omap3 + hwpacks .. _version_0_4_5: === modified file 'lava_dispatcher/client/lmc_utils.py' --- lava_dispatcher/client/lmc_utils.py 2012-01-27 03:27:03 +0000 +++ lava_dispatcher/client/lmc_utils.py 2012-01-30 03:48:10 +0000 @@ -147,31 +147,104 @@ logging_system('rm -rf ' + mntdir) def _run_linaro_media_create(cmd): + """Run linaro-media-create and accept licenses thrown up in the process. + """ 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=86400) - 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 - + + # This code is a bit out of control. It describes a state machine. Each + # state has a name, a mapping patterns to wait for -> state to move to, a + # timeout for how long to wait for said pattern and optionally some input + # to send to l-m-c when you enter the step. + + # The basic outline is this: + + # We wait for l-m-c to actually start. This has an enormous timeout, + # because 'cmd' starts with 'flock /var/lock/lava-lmc.lck' and when lots + # of jobs start at the same time, it can be a long time before the lock is + # acquired. + + # Once its going, we watch for a couple of key phrases that suggets a + # license popup has appeared. The next few states navigate through the + # dialogs and then accept the license. The 'say-yes' state has extra fun + # stuff to try to move to a state where the "" button is highlighted + # before pressing space (the acceptance dialogs are not consistent about + # whether is the default or not!). + + states = { + 'waiting': { + 'expectations': { + "linaro-hwpack-install": 'default', + }, + 'timeout': 86400, + }, + 'default': { + 'expectations': { + "TI TSPA Software License Agreement": 'accept-tspa', + "SNOWBALL CLICK-WRAP": 'accept-snowball', + }, + 'timeout': 3600, + }, + 'accept-tspa': { + 'expectations': {"": 'accept-tspa-1'}, + 'timeout': 1, + }, + 'accept-tspa-1': { + 'input': "\t ", + 'expectations': { + "Accept TI TSPA Software License Agreement": 'say-yes', + }, + 'timeout': 1, + }, + 'say-yes': { + 'expectations': { + " ": 'say-yes-tab', + "\\033\[41m<(Yes|Ok)>": 'say-yes-space', + }, + 'timeout': 1, + }, + 'say-yes-tab': { + 'input': "\t", + 'expectations': { + ".": 'say-yes', + }, + 'timeout': 1, + }, + 'say-yes-space': { + 'input': " ", + 'expectations': { + ".": 'default', + }, + 'timeout': 1, + }, + 'accept-snowball': { + 'expectations': {"": 'accept-snowball-1'}, + 'timeout': 1, + }, + 'accept-snowball-1': { + 'input': "\t ", + 'expectations': { + "Do you accept": 'say-yes', + }, + 'timeout': 1, + }, + } + + + state = 'waiting' + + while True: + state_data = states[state] + patterns = [] + next_state_names = [] + if 'input' in state_data: + proc.send(state_data['input']) + for pattern, next_state in state_data['expectations'].items(): + patterns.append(pattern) + next_state_names.append(next_state) + patterns.append(pexpect.EOF) + next_state_names.append(None) + logging.debug('waiting for %r' % patterns) + match_id = proc.expect(patterns, timeout=state_data['timeout']) + state = next_state_names[match_id] + if state is None: + return