initial import
[vuplus_webkit] / Tools / Scripts / webkitpy / common / host.py
1 # Copyright (c) 2010 Google Inc. All rights reserved.
2 # Copyright (c) 2009 Apple Inc. All rights reserved.
3 #
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are
6 # met:
7 #
8 #     * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer.
10 #     * Redistributions in binary form must reproduce the above
11 # copyright notice, this list of conditions and the following disclaimer
12 # in the documentation and/or other materials provided with the
13 # distribution.
14 #     * Neither the name of Google Inc. nor the names of its
15 # contributors may be used to endorse or promote products derived from
16 # this software without specific prior written permission.
17 #
18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30
31 from webkitpy.common.checkout import Checkout
32 from webkitpy.common.checkout.scm import default_scm
33 from webkitpy.common.config.ports import WebKitPort
34 from webkitpy.common.memoized import memoized
35 from webkitpy.common.net import bugzilla, buildbot, statusserver, web
36 from webkitpy.common.net.buildbot.chromiumbuildbot import ChromiumBuildBot
37 from webkitpy.common.net.irc import ircproxy
38 from webkitpy.common.system import executive, filesystem, platforminfo, user, workspace
39 from webkitpy.layout_tests.port.factory import PortFactory
40
41
42 class Host(object):
43     def __init__(self):
44         self.bugs = bugzilla.Bugzilla()
45         self.buildbot = buildbot.BuildBot()
46         self.executive = executive.Executive()
47         self.web = web.Web()
48         self._irc = None
49         self.filesystem = filesystem.FileSystem()
50         self.workspace = workspace.Workspace(self.filesystem, self.executive)
51         self._port = None
52         self.user = user.User()
53         self._scm = None
54         self._checkout = None
55         self.status_server = statusserver.StatusServer()
56         # FIXME: Unfortunately Port objects are currently the central-dispatch objects of the NRWT world.
57         # In order to instantiate a port correctly, we have to pass it at least an executive, user, scm, and filesystem
58         # so for now we just pass along the whole Host object.
59         self.port_factory = PortFactory(self)
60         self.platform = platforminfo.PlatformInfo()
61
62     def _initialize_scm(self, patch_directories=None):
63         self._scm = default_scm(patch_directories)
64         self._checkout = Checkout(self.scm())
65
66     def scm(self):
67         return self._scm
68
69     def checkout(self):
70         return self._checkout
71
72     def port(self):
73         return self._port
74
75     @memoized
76     def chromium_buildbot(self):
77         return ChromiumBuildBot()
78
79     def ensure_irc_connected(self, irc_delegate):
80         if not self._irc:
81             self._irc = ircproxy.IRCProxy(irc_delegate)
82
83     def irc(self):
84         # We don't automatically construct IRCProxy here because constructing
85         # IRCProxy actually connects to IRC.  We want clients to explicitly
86         # connect to IRC.
87         return self._irc
88
89     def command_completed(self):
90         if self._irc:
91             self._irc.disconnect()