diff --git a/swi.py b/swi.py index 2c2d90f..9b073e9 100644 --- a/swi.py +++ b/swi.py @@ -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' @@ -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] @@ -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 @@ -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: @@ -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: diff --git a/utils.py b/utils.py index ffb1979..5e940be 100644 --- a/utils.py +++ b/utils.py @@ -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) \ No newline at end of file + return s.get(key) + else: + return default