Skip to content

Commit

Permalink
Make hostname a parameter like port
Browse files Browse the repository at this point in the history
  • Loading branch information
dan moseley authored and danmoseley committed Mar 15, 2016
1 parent 1bd86a6 commit 6cb9799
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
10 changes: 6 additions & 4 deletions swi.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
current_call_frame = None
current_call_frame_position = None
source_map_state = None
hostname = utils.get_setting('hostname', 'localhost')
port = str(utils.get_setting('chrome_remote_port'))

breakpoint_active_icon = 'Packages/Web Inspector/icons/breakpoint_active.png'
breakpoint_inactive_icon = 'Packages/Web Inspector/icons/breakpoint_inactive.png'
Expand Down Expand Up @@ -108,7 +110,7 @@ def run(self):
mapping.append(['swi_debug_clear_breakpoints', 'Clear all Breakpoints'])
mapping.append(['swi_dump_file_mappings', 'Dump file mappings'])
else:
mapping.append(['swi_debug_start_chrome', 'Start Google Chrome with remote debug port ' + utils.get_setting('chrome_remote_port')])
mapping.append(['swi_debug_start_chrome', 'Start Google Chrome with remote debug port ' + port])

self.cmds = [entry[0] for entry in mapping]
self.items = [entry[1] for entry in mapping]
Expand Down Expand Up @@ -139,7 +141,7 @@ def chrome_launched():
proxy = urllib.request.ProxyHandler({})
opener = urllib.request.build_opener(proxy)
urllib.request.install_opener(opener)
urllib.request.urlopen('http://127.0.0.1:' + utils.get_setting('chrome_remote_port') + '/json')
urllib.request.urlopen('http://' + hostname + ':' + port + '/json')
return True
except:
pass
Expand All @@ -159,7 +161,7 @@ def run(self):
if key == "windows" and (sublime.arch() == "x64" or sublime.executable_path().find('(x86)') >= 0):
key += "_x64"

cmd = [os.getenv('GOOGLE_CHROME_PATH', '') + utils.get_setting('chrome_path')[key], '--remote-debugging-port=' + utils.get_setting('chrome_remote_port')]
cmd = [os.getenv('GOOGLE_CHROME_PATH', '') + utils.get_setting('chrome_path')[key], '--remote-debugging-port=' + port]

profile = utils.get_setting('chrome_profile') or ''
if profile:
Expand All @@ -182,7 +184,7 @@ def run(self):
proxy = urllib.request.ProxyHandler({})
opener = urllib.request.build_opener(proxy)
urllib.request.install_opener(opener)
response = urllib.request.urlopen('http://127.0.0.1:' + utils.get_setting('chrome_remote_port') + '/json')
response = urllib.request.urlopen('http://' + hostname + ':' + port + '/json')
pages = json.loads(response.read().decode('utf-8'))
mapping = {}
for page in pages:
Expand Down
6 changes: 4 additions & 2 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ def assert_main_thread():

main_thread = threading.current_thread()

def get_setting(key):
def get_setting(key, default = None):
s = sublime.load_settings("swi.sublime-settings")
if s and s.has(key):
return s.get(key)
return s.get(key)
else:
return default

0 comments on commit 6cb9799

Please sign in to comment.