blob: 9ae9aa948c9a5f699cc40c7a6a79478c0eddb1f1 [file] [log] [blame]
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import select_task
from autotest_lib.client.bin import test
from autotest_lib.client.common_lib import error, utils
from autotest_lib.client.cros import factory_setup_modules
from cros.factory.test import factory
from cros.factory.test import gooftools
from cros.factory.test import shopfloor
from cros.factory.test import task
from cros.factory.test import ui
_MESSAGE_FETCH_FROM_SHOP_FLOOR = "Fetching HWID from shop floor server..."
class WriteHwidTask(task.FactoryTask):
def __init__(self, data): = data
def write_hwid(self):
# TODO(hungte) Support partial matching by gooftools or hwid_tool.
# When the input is not a complete HWID (i.e., BOM-VARIANT pair), select
# and derive the complete ID from active HWIDs in current database.
# Ex: input="BLUE A" => matched to "MARIO BLUE A-B 6868".
hwid =['hwid']
assert hwid"gooftool write_hwid '%s'" % hwid)
def start(self):
assert 'hwid' in, "Missing HWID in data."
hwid ='hwid', None)
if not hwid:
raise ValueError("Invalid empty HWID")
self.add_widget(ui.make_label("%s\n%s" % (_MESSAGE_WRITING, hwid)))
class ShopFloorHwidTask(task.FactoryTask):
def __init__(self, data): = data
def start(self):
def fetch_hwid(self):
shopfloor.update_local_hwid_data()['hwid'] = shopfloor.get_hwid()
class factory_HWID(test.test):
version = 3
def run_once(self, override_hwid=None):
factory.log('%s run_once' % self.__class__) = {'hwid': override_hwid}
self.tasks = [WriteHwidTask(]
if not override_hwid:
if shopfloor.is_enabled()
else select_task.SelectHwidTask(
task.run_factory_tasks(self.job, self.tasks)
factory.log('%s run_once finished' % repr(self.__class__))