Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(317)

Unified Diff: webkit/tools/layout_tests/layout_package/http_server.py

Issue 243022: Clean up code duplication in layout test http_server.py (Closed)
Patch Set: Remove sys path since already imported via bash Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/python/google/httpd_utils.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/tools/layout_tests/layout_package/http_server.py
diff --git a/webkit/tools/layout_tests/layout_package/http_server.py b/webkit/tools/layout_tests/layout_package/http_server.py
old mode 100644
new mode 100755
index 9f328f6b15953737f0759f12013857ed599e20b5..f438f43bc85eb48824cb48e8691317991f7c8d80
--- a/webkit/tools/layout_tests/layout_package/http_server.py
+++ b/webkit/tools/layout_tests/layout_package/http_server.py
@@ -17,6 +17,7 @@ import time
import urllib
import path_utils
+import google.httpd_utils
def RemoveLogFiles(folder, starts_with):
files = os.listdir(folder)
@@ -25,9 +26,6 @@ def RemoveLogFiles(folder, starts_with):
full_path = os.path.join(folder, file)
os.remove(full_path)
-class HttpdNotStarted(Exception):
- pass
-
class Lighttpd:
# Webkit tests
try:
@@ -220,38 +218,14 @@ class Lighttpd:
for mapping in mappings:
url = 'http%s://127.0.0.1:%d/' % ('sslcert' in mapping and 's' or '',
mapping['port'])
- if not self._UrlIsAlive(url):
- raise HttpdNotStarted('Failed to start httpd on port %s' %
- str(mapping['port']))
+ if not google.httpd_utils.UrlIsAlive(url):
+ raise google.httpd_utils.HttpdNotStarted('Failed to start httpd on ',
+ 'port %s' %
+ str(mapping['port']))
# Our process terminated already
if self._process.returncode != None:
- raise HttpdNotStarted('Failed to start httpd.')
-
- def _UrlIsAlive(self, url):
- """Checks to see if we get an http response from |url|.
- We poll the url 5 times with a 3 second delay. If we don't
- get a reply in that time, we give up and assume the httpd
- didn't start properly.
-
- Args:
- url: The URL to check.
- Return:
- True if the url is alive.
- """
- attempts = 5
- while attempts > 0:
- try:
- response = urllib.urlopen(url)
- # Server is up and responding.
- return True
- except IOError:
- pass
- attempts -= 1
- # Wait 3 seconds and try again.
- time.sleep(3)
-
- return False
+ raise google.httpd_utils.HttpdNotStarted('Failed to start httpd.')
# TODO(deanm): Find a nicer way to shutdown cleanly. Our log files are
# probably not being flushed, etc... why doesn't our python have os.kill ?
« no previous file with comments | « tools/python/google/httpd_utils.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698