1# Copyright 2014 The Chromium Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5from pylib import constants 6from pylib.local.device import local_device_environment 7try: 8 from pylib.remote.device import remote_device_environment 9except ImportError: 10 remote_device_environment = None 11 12def CreateEnvironment(args, error_func): 13 14 if args.environment == 'local': 15 if args.command not in constants.LOCAL_MACHINE_TESTS: 16 return local_device_environment.LocalDeviceEnvironment(args, error_func) 17 # TODO(jbudorick) Add local machine environment. 18 if args.environment == 'remote_device' and remote_device_environment: 19 return remote_device_environment.RemoteDeviceEnvironment(args, 20 error_func) 21 error_func('Unable to create %s environment.' % args.environment) 22