Changeset 85080 in webkit
- Timestamp:
- Apr 27, 2011 1:44:15 PM (13 years ago)
- Location:
- trunk/Tools
- Files:
-
- 1 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r85076 r85080 1 2011-04-27 Tony Chang <tony@chromium.org> 2 3 Reviewed by Ojan Vafai. 4 5 lazily autoinstall thirdparty python libraries 6 https://bugs.webkit.org/show_bug.cgi?id=55723 7 8 This helps by only having pywebsocket installed when the bots run. It 9 doesn't help much for devs since webkit-patch pulls in almost everything. 10 11 * Scripts/webkitpy/common/net/bugzilla/bugzilla.py: 12 * Scripts/webkitpy/common/net/buildbot/buildbot.py: 13 * Scripts/webkitpy/common/net/networktransaction.py: 14 * Scripts/webkitpy/common/net/networktransaction_unittest.py: 15 * Scripts/webkitpy/common/net/statusserver.py: 16 * Scripts/webkitpy/layout_tests/port/websocket_server.py: 17 * Scripts/webkitpy/thirdparty/__init__.py: Add an import hook so we can install based on 18 the import command rather than just installing everything. 19 * Scripts/webkitpy/thirdparty/__init___unittest.py: Added. 20 1 21 2011-04-27 Girish Ramakrishnan <girish@forwardbias.in> 2 22 -
trunk/Tools/Scripts/webkitpy/common/net/bugzilla/bugzilla.py
r84575 r85080 46 46 from webkitpy.common.net.credentials import Credentials 47 47 from webkitpy.common.system.user import User 48 from webkitpy.thirdparty.autoinstalled.mechanize import Browser49 48 from webkitpy.thirdparty.BeautifulSoup import BeautifulSoup, BeautifulStoneSoup, SoupStrainer 50 49 … … 216 215 # FIXME: We should use some sort of Browser mock object when in dryrun 217 216 # mode (to prevent any mistakes). 217 from webkitpy.thirdparty.autoinstalled.mechanize import Browser 218 218 self.browser = Browser() 219 219 # Ignore bugs.webkit.org/robots.txt until we fix it to allow this -
trunk/Tools/Scripts/webkitpy/common/net/buildbot/buildbot.py
r84676 r85080 47 47 from webkitpy.common.system.zipfileset import ZipFileSet 48 48 from webkitpy.thirdparty.BeautifulSoup import BeautifulSoup 49 from webkitpy.thirdparty.autoinstalled.mechanize import Browser50 49 51 50 _log = get_logger(__file__) … … 58 57 self._builds_cache = {} 59 58 self._revision_to_build_number = None 59 from webkitpy.thirdparty.autoinstalled.mechanize import Browser 60 60 self._browser = Browser() 61 61 self._browser.set_handle_robots(False) # The builder pages are excluded by robots.txt -
trunk/Tools/Scripts/webkitpy/common/net/networktransaction.py
r75230 r85080 30 30 import time 31 31 32 from webkitpy.thirdparty.autoinstalled import mechanize33 32 from webkitpy.common.system.deprecated_logging import log 34 33 … … 51 50 self._total_sleep = 0 52 51 self._backoff_seconds = self._initial_backoff_seconds 52 from webkitpy.thirdparty.autoinstalled import mechanize 53 53 while True: 54 54 try: -
trunk/Tools/Scripts/webkitpy/common/net/networktransaction_unittest.py
r75230 r85080 31 31 from webkitpy.common.net.networktransaction import NetworkTransaction, NetworkTimeout 32 32 from webkitpy.common.system.logtesting import LoggingTestCase 33 from webkitpy.thirdparty.autoinstalled.mechanize import HTTPError34 33 35 34 … … 60 59 self._run_count += 1 61 60 if self._run_count < 3: 61 from webkitpy.thirdparty.autoinstalled.mechanize import HTTPError 62 62 raise HTTPError("http://example.com/", 500, "internal server error", None, None) 63 63 return 42 64 64 65 65 def _raise_404_error(self): 66 from webkitpy.thirdparty.autoinstalled.mechanize import HTTPError 66 67 raise HTTPError("http://foo.com/", 404, "not found", None, None) 67 68 -
trunk/Tools/Scripts/webkitpy/common/net/statusserver.py
r83614 r85080 31 31 from webkitpy.common.net.networktransaction import NetworkTransaction 32 32 from webkitpy.common.system.deprecated_logging import log 33 from webkitpy.thirdparty.autoinstalled.mechanize import Browser34 33 from webkitpy.thirdparty.BeautifulSoup import BeautifulSoup 35 34 … … 47 46 def __init__(self, host=default_host, browser=None, bot_id=None): 48 47 self.set_host(host) 48 from webkitpy.thirdparty.autoinstalled.mechanize import Browser 49 49 self._browser = browser or Browser() 50 50 self.set_bot_id(bot_id) -
trunk/Tools/Scripts/webkitpy/layout_tests/port/websocket_server.py
r76547 r85080 47 47 48 48 from webkitpy.common.system.executive import Executive 49 from webkitpy.thirdparty.autoinstalled.pywebsocket import mod_pywebsocket50 49 51 50 … … 158 157 self._wsout = codecs.open(output_log, "w", "utf-8") 159 158 159 from webkitpy.thirdparty.autoinstalled.pywebsocket import mod_pywebsocket 160 160 python_interp = sys.executable 161 161 pywebsocket_base = os.path.join( -
trunk/Tools/Scripts/webkitpy/thirdparty/__init__.py
r81348 r85080 29 29 import codecs 30 30 import os 31 import sys 31 32 32 33 from webkitpy.common.system.autoinstall import AutoInstaller 34 from webkitpy.common.system.filesystem import FileSystem 35 36 _THIRDPARTY_DIR = os.path.dirname(__file__) 37 _AUTOINSTALLED_DIR = os.path.join(_THIRDPARTY_DIR, "autoinstalled") 33 38 34 39 # Putting the autoinstall code into webkitpy/thirdparty/__init__.py … … 36 41 # webkitpy.thirdparty. This is useful if the caller wants to configure 37 42 # logging prior to executing autoinstall code. 38 39 # FIXME: Ideally, a package should be autoinstalled only if the caller40 # attempts to import from that individual package. This would41 # make autoinstalling lazier than it is currently. This can42 # perhaps be done using Python's import hooks as the original43 # autoinstall implementation did.44 43 45 44 # FIXME: If any of these servers is offline, webkit-patch breaks (and maybe … … 49 48 # 50 49 # webkitpy/thirdparty/autoinstalled 51 thirdparty_dir = os.path.dirname(__file__)52 autoinstalled_dir = os.path.join(thirdparty_dir, "autoinstalled")50 fs = FileSystem() 51 fs.maybe_make_directory(_AUTOINSTALLED_DIR) 53 52 54 # We need to download ClientForm since the mechanize package that we download 55 # below requires it. The mechanize package uses ClientForm, for example, 56 # in _html.py. Since mechanize imports ClientForm in the following way, 57 # 58 # > import sgmllib, ClientForm 59 # 60 # the search path needs to include ClientForm. We put ClientForm in 61 # its own directory so that we can include it in the search path without 62 # including other modules as a side effect. 63 clientform_dir = os.path.join(autoinstalled_dir, "clientform") 64 installer = AutoInstaller(append_to_search_path=True, 65 target_dir=clientform_dir) 66 installer.install(url="http://pypi.python.org/packages/source/C/ClientForm/ClientForm-0.2.10.zip", 67 url_subpath="ClientForm.py") 53 init_path = fs.join(_AUTOINSTALLED_DIR, "__init__.py") 54 if not fs.exists(init_path): 55 fs.write_text_file(init_path, "") 68 56 69 # The remaining packages do not need to be in the search path, so we create 70 # a new AutoInstaller instance that does not append to the search path. 71 installer = AutoInstaller(target_dir=autoinstalled_dir) 57 readme_path = fs.join(_AUTOINSTALLED_DIR, "README") 58 if not fs.exists(readme_path): 59 fs.write_text_file(readme_path, 60 "This directory is auto-generated by WebKit and is " 61 "safe to delete.\nIt contains needed third-party Python " 62 "packages automatically downloaded from the web.") 72 63 73 installer.install(url="http://pypi.python.org/packages/source/m/mechanize/mechanize-0.2.4.zip",74 url_subpath="mechanize")75 installer.install(url="http://pypi.python.org/packages/source/p/pep8/pep8-0.5.0.tar.gz#md5=512a818af9979290cd619cce8e9c2e2b",76 url_subpath="pep8-0.5.0/pep8.py")77 installer.install(url="http://www.adambarth.com/webkit/eliza",78 target_name="eliza.py")79 64 80 # Since irclib and ircbot are two top-level packages, we need to import 81 # them separately. We group them into an irc package for better 82 # organization purposes. 83 irc_dir = os.path.join(autoinstalled_dir, "irc") 84 installer = AutoInstaller(target_dir=irc_dir) 85 installer.install(url="http://downloads.sourceforge.net/project/python-irclib/python-irclib/0.4.8/python-irclib-0.4.8.zip", url_subpath="irclib.py") 86 installer.install(url="http://downloads.sourceforge.net/project/python-irclib/python-irclib/0.4.8/python-irclib-0.4.8.zip", url_subpath="ircbot.py") 65 class AutoinstallImportHook(object): 66 def __init__(self, filesystem=None): 67 self._fs = filesystem or FileSystem() 87 68 88 pywebsocket_dir = os.path.join(autoinstalled_dir, "pywebsocket") 89 installer = AutoInstaller(target_dir=pywebsocket_dir) 90 installer.install(url="http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.5.2.tar.gz", 91 url_subpath="pywebsocket-0.5.2/src/mod_pywebsocket")69 def find_module(self, fullname, path): 70 # This method will run before each import. See http://www.python.org/dev/peps/pep-0302/ 71 if '.autoinstalled' not in fullname: 72 return 92 73 93 readme_path = os.path.join(autoinstalled_dir, "README") 94 if not os.path.exists(readme_path): 95 with codecs.open(readme_path, "w", "ascii") as file: 96 file.write("This directory is auto-generated by WebKit and is " 97 "safe to delete.\nIt contains needed third-party Python " 98 "packages automatically downloaded from the web.") 74 if '.mechanize' in fullname: 75 self._install_mechanize() 76 elif '.pep8' in fullname: 77 self._install_pep8() 78 elif '.eliza' in fullname: 79 self._install_eliza() 80 elif '.irc' in fullname: 81 self._install_irc() 82 elif '.pywebsocket' in fullname: 83 self._install_pywebsocket() 84 85 def _install_mechanize(self): 86 # The mechanize package uses ClientForm, for example, in _html.py. 87 # Since mechanize imports ClientForm in the following way, 88 # 89 # > import sgmllib, ClientForm 90 # 91 # the search path needs to include ClientForm. We put ClientForm in 92 # its own directory so that we can include it in the search path 93 # without including other modules as a side effect. 94 clientform_dir = self._fs.join(_AUTOINSTALLED_DIR, "clientform") 95 installer = AutoInstaller(append_to_search_path=True, 96 target_dir=clientform_dir) 97 installer.install(url="http://pypi.python.org/packages/source/C/ClientForm/ClientForm-0.2.10.zip", 98 url_subpath="ClientForm.py") 99 100 self._install("http://pypi.python.org/packages/source/m/mechanize/mechanize-0.2.4.zip", 101 "mechanize") 102 103 def _install_pep8(self): 104 self._install("http://pypi.python.org/packages/source/p/pep8/pep8-0.5.0.tar.gz#md5=512a818af9979290cd619cce8e9c2e2b", 105 "pep8-0.5.0/pep8.py") 106 107 def _install_eliza(self): 108 installer = AutoInstaller(target_dir=_AUTOINSTALLED_DIR) 109 installer.install(url="http://www.adambarth.com/webkit/eliza", 110 target_name="eliza.py") 111 112 def _install_irc(self): 113 # Since irclib and ircbot are two top-level packages, we need to import 114 # them separately. We group them into an irc package for better 115 # organization purposes. 116 irc_dir = self._fs.join(_AUTOINSTALLED_DIR, "irc") 117 installer = AutoInstaller(target_dir=irc_dir) 118 installer.install(url="http://downloads.sourceforge.net/project/python-irclib/python-irclib/0.4.8/python-irclib-0.4.8.zip", 119 url_subpath="irclib.py") 120 installer.install(url="http://downloads.sourceforge.net/project/python-irclib/python-irclib/0.4.8/python-irclib-0.4.8.zip", 121 url_subpath="ircbot.py") 122 123 def _install_pywebsocket(self): 124 pywebsocket_dir = self._fs.join(_AUTOINSTALLED_DIR, "pywebsocket") 125 installer = AutoInstaller(target_dir=pywebsocket_dir) 126 installer.install(url="http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.5.2.tar.gz", 127 url_subpath="pywebsocket-0.5.2/src/mod_pywebsocket") 128 129 def _install(self, url, url_subpath): 130 installer = AutoInstaller(target_dir=_AUTOINSTALLED_DIR) 131 installer.install(url=url, url_subpath=url_subpath) 132 133 134 sys.meta_path.append(AutoinstallImportHook())
Note: See TracChangeset
for help on using the changeset viewer.