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

Unified Diff: gm/rebaseline_server/server.py

Issue 51353002: rebaseline_server: report proper URL upon launch (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: close_socket Created 7 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/rebaseline_server/server.py
===================================================================
--- gm/rebaseline_server/server.py (revision 12004)
+++ gm/rebaseline_server/server.py (working copy)
@@ -18,6 +18,7 @@
import posixpath
import re
import shutil
+import socket
import sys
import thread
import time
@@ -65,6 +66,17 @@
_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 @@
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()
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698