diff options
author | mathieui <mathieui@mathieui.net> | 2015-01-28 09:46:51 +0100 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2015-01-28 09:54:30 +0100 |
commit | 3c46d49704de86635508439f524c684903dc81d3 (patch) | |
tree | 0c8e02a7a6f4d7e50e2d8842c86ce294e5189627 /src/core | |
parent | 0a7b4360adb26b102d85f3191f1061ce7f8dceb6 (diff) | |
download | poezio-3c46d49704de86635508439f524c684903dc81d3.tar.gz poezio-3c46d49704de86635508439f524c684903dc81d3.tar.bz2 poezio-3c46d49704de86635508439f524c684903dc81d3.tar.xz poezio-3c46d49704de86635508439f524c684903dc81d3.zip |
Minor fixes to the certificate warning prompt (#2949)
- slightly lower the CPU usage (callback instead of active waiting w/ sleep)
- make the terminal beep so the user knows something happened
- prevent the user “escaping” the prompt by pressing /, s, or S
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/handlers.py | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/src/core/handlers.py b/src/core/handlers.py index 03a6d32d..b16b8c0f 100644 --- a/src/core/handlers.py +++ b/src/core/handlers.py @@ -1196,20 +1196,7 @@ def validate_ssl(self, pem): self.information('New certificate found (sha-2 hash:' ' %s)\nPlease validate or abort' % sha2_found_cert, 'Warning') - input = windows.YesNoInput(text="WARNING! Server certificate has changed, accept? (y/n)") - self.current_tab().input = input - input.resize(1, self.current_tab().width, self.current_tab().height-1, 0) - input.refresh() - self.doupdate() - old_loop = asyncio.get_event_loop() - new_loop = asyncio.new_event_loop() - asyncio.set_event_loop(new_loop) - new_loop.add_reader(sys.stdin, self.on_input_readable) - future = asyncio.Future() - @asyncio.coroutine - def check_input(future): - while input.value is None: - yield from asyncio.sleep(0.01) + def check_input(): self.current_tab().input = saved_input self.paused = False if input.value: @@ -1222,10 +1209,17 @@ def validate_ssl(self, pem): self.disconnect() new_loop.stop() asyncio.set_event_loop(old_loop) - asyncio.async(check_input(future)) + input = windows.YesNoInput(text="WARNING! Server certificate has changed, accept? (y/n)", callback=check_input) + self.current_tab().input = input + input.resize(1, self.current_tab().width, self.current_tab().height-1, 0) + input.refresh() + self.doupdate() + old_loop = asyncio.get_event_loop() + new_loop = asyncio.new_event_loop() + asyncio.set_event_loop(new_loop) + new_loop.add_reader(sys.stdin, self.on_input_readable) + curses.beep() new_loop.run_forever() - - else: log.debug('First time. Setting certificate to %s', sha2_found_cert) if not config.silent_set('certificate', sha2_found_cert): |