aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm
diff options
context:
space:
mode:
authorGravatar epoger@google.com <epoger@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-10-30 14:09:04 +0000
committerGravatar epoger@google.com <epoger@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-10-30 14:09:04 +0000
commitb08c707847be4b0c94adf592912b4e7073f71ecb (patch)
tree2625599fbfaebe71020833fd16ee65af33a30ae0 /gm
parentbbe66f0824dc47823826f6265879d7a57843fed3 (diff)
rebaseline_server: report proper URL upon launch
BUG=skia:1767 (SkipBuildbotRuns) R=jcgregorio@google.com Review URL: https://codereview.chromium.org/51353002 git-svn-id: http://skia.googlecode.com/svn/trunk@12016 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gm')
-rwxr-xr-xgm/rebaseline_server/server.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/gm/rebaseline_server/server.py b/gm/rebaseline_server/server.py
index a15b9b95d2..94ed046d77 100755
--- a/gm/rebaseline_server/server.py
+++ b/gm/rebaseline_server/server.py
@@ -18,6 +18,7 @@ import os
import posixpath
import re
import shutil
+import socket
import sys
import thread
import time
@@ -65,6 +66,17 @@ _HTTP_HEADER_CONTENT_TYPE = 'Content-Type'
_SERVER = None # This gets filled in by main()
+def get_routable_ip_address():
+ """Returns routable IP address of this host (the IP address of its network
+ interface that would be used for most traffic, not its localhost
+ interface). See http://stackoverflow.com/a/166589 """
+ sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+ sock.connect(('8.8.8.8', 80))
+ host = sock.getsockname()[0]
+ sock.close()
+ return host
+
+
class Server(object):
""" HTTP server for our HTML rebaseline viewer. """
@@ -164,15 +176,16 @@ class Server(object):
if self._export:
server_address = ('', self._port)
+ host = get_routable_ip_address()
if self._editable:
logging.warning('Running with combination of "export" and "editable" '
'flags. Users on other machines will '
'be able to modify your GM expectations!')
else:
- server_address = ('127.0.0.1', self._port)
+ host = '127.0.0.1'
+ server_address = (host, self._port)
http_server = BaseHTTPServer.HTTPServer(server_address, HTTPRequestHandler)
- logging.info('Ready for requests on http://%s:%d' % (
- http_server.server_name, http_server.server_port))
+ logging.info('Ready for requests on http://%s:%d' % (host, http_server.server_port))
http_server.serve_forever()