blob: 5292d4daeff20d28fbd28b2f391968b4bb3e489a [file] [log] [blame]
mblighce955fc2009-08-24 21:59:02 +00001# Copyright 2009 Google Inc. Released under the GPL v2
2
3"""
4This file contains the implementation of a host object for the local machine.
5"""
6
7import platform
8from autotest_lib.client.common_lib import hosts, error
9from autotest_lib.client.bin import utils
10
11class LocalHost(hosts.Host):
12 def _initialize(self, hostname=None, *args, **dargs):
13 super(LocalHost, self)._initialize(*args, **dargs)
14
15 # hostname will be an actual hostname when this client was created
16 # by an autoserv process
17 if not hostname:
18 hostname = platform.node()
19 self.hostname = hostname
20
21
22 def wait_up(self, timeout=None):
23 # a local host is always up
24 return True
25
26
27 def run(self, command, timeout=3600, ignore_status=False,
28 stdout_tee=utils.TEE_TO_LOGS, stderr_tee=utils.TEE_TO_LOGS,
jadmanskif7368c52009-10-13 14:56:23 +000029 stdin=None, args=()):
mblighce955fc2009-08-24 21:59:02 +000030 """
31 @see common_lib.hosts.Host.run()
32 """
jadmanskif7368c52009-10-13 14:56:23 +000033 result = utils.run(
34 command, timeout=timeout, ignore_status=True,
35 stdout_tee=stdout_tee, stderr_tee=stderr_tee, stdin=stdin,
36 args=args)
mblighce955fc2009-08-24 21:59:02 +000037
38 if not ignore_status and result.exit_status > 0:
39 raise error.AutotestHostRunError('command execution error', result)
40
41 return result