forked from M-Labs/thermostat
host
This commit is contained in:
parent
c1ae69f218
commit
3c9541fea2
|
@ -563,7 +563,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||||
|
|
||||||
@asyncSlot()
|
@asyncSlot()
|
||||||
async def on_connect_btn_clicked(self):
|
async def on_connect_btn_clicked(self):
|
||||||
ip, port = self.host_set_line.text(), self.port_set_spin.value()
|
host, port = self.host_set_line.text(), self.port_set_spin.value()
|
||||||
try:
|
try:
|
||||||
if not (self.client.is_connecting() or self.client.is_connected()):
|
if not (self.client.is_connecting() or self.client.is_connected()):
|
||||||
self.status_lbl.setText("Connecting...")
|
self.status_lbl.setText("Connecting...")
|
||||||
|
@ -572,7 +572,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||||
self.port_set_spin.setEnabled(False)
|
self.port_set_spin.setEnabled(False)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await self.client.connect(host=ip, port=port, timeout=30)
|
await self.client.connect(host=host, port=port, timeout=30)
|
||||||
except StoppedConnecting:
|
except StoppedConnecting:
|
||||||
return
|
return
|
||||||
await self._on_connection_changed(True)
|
await self._on_connection_changed(True)
|
||||||
|
@ -581,7 +581,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||||
await self.client.disconnect()
|
await self.client.disconnect()
|
||||||
|
|
||||||
except (OSError, TimeoutError, asyncio.TimeoutError) as e: # TODO: Remove asyncio.TimeoutError in Python 3.11
|
except (OSError, TimeoutError, asyncio.TimeoutError) as e: # TODO: Remove asyncio.TimeoutError in Python 3.11
|
||||||
logging.error(f"Failed communicating to {ip}:{port}: {e}")
|
logging.error(f"Failed communicating to {host}:{port}: {e}")
|
||||||
await self._on_connection_changed(False)
|
await self._on_connection_changed(False)
|
||||||
await self.client.disconnect()
|
await self.client.disconnect()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue