Skip to content
Snippets Groups Projects
Commit b92ffd3a authored by Vincent Texier's avatar Vincent Texier
Browse files

fix timeout exception when adding a community

parent 2c54c369
No related branches found
No related tags found
1 merge request!409fix some crashes
...@@ -6,6 +6,7 @@ Created on 8 mars 2014 ...@@ -6,6 +6,7 @@ Created on 8 mars 2014
import logging import logging
import asyncio import asyncio
import aiohttp import aiohttp
from ucoinpy.api import errors from ucoinpy.api import errors
...@@ -65,6 +66,7 @@ class StepPageInit(Step): ...@@ -65,6 +66,7 @@ class StepPageInit(Step):
server = self.config_dialog.lineedit_server.text() server = self.config_dialog.lineedit_server.text()
port = self.config_dialog.spinbox_port.value() port = self.config_dialog.spinbox_port.value()
logging.debug("Is valid ? ") logging.debug("Is valid ? ")
self.config_dialog.label_error.setText(self.tr("connecting..."))
try: try:
self.node = await Node.from_address(None, server, port, session=aiohttp.ClientSession()) self.node = await Node.from_address(None, server, port, session=aiohttp.ClientSession())
community = Community.create(self.node) community = Community.create(self.node)
...@@ -78,12 +80,15 @@ class StepPageInit(Step): ...@@ -78,12 +80,15 @@ class StepPageInit(Step):
self.config_dialog.label_error.setText(str(e)) self.config_dialog.label_error.setText(str(e))
#except (MalformedDocumentError, ValueError) as e: #except (MalformedDocumentError, ValueError) as e:
# self.config_dialog.label_error.setText(str(e)) # self.config_dialog.label_error.setText(str(e))
except aiohttp.errors.TimeoutError:
self.config_dialog.label_error.setText(self.tr("Could not connect. Check hostname, ip address or port"))
@asyncify @asyncify
async def check_connect(self, checked=False): async def check_connect(self, checked=False):
server = self.config_dialog.lineedit_server.text() server = self.config_dialog.lineedit_server.text()
port = self.config_dialog.spinbox_port.value() port = self.config_dialog.spinbox_port.value()
logging.debug("Is valid ? ") logging.debug("Is valid ? ")
self.config_dialog.label_error.setText(self.tr("connecting..."))
try: try:
self.node = await Node.from_address(None, server, port, session=aiohttp.ClientSession()) self.node = await Node.from_address(None, server, port, session=aiohttp.ClientSession())
community = Community.create(self.node) community = Community.create(self.node)
...@@ -108,12 +113,15 @@ Yours : {0}, the network : {1}""".format(registered[1], registered[2]))) ...@@ -108,12 +113,15 @@ Yours : {0}, the network : {1}""".format(registered[1], registered[2])))
self.config_dialog.label_error.setText(str(e)) self.config_dialog.label_error.setText(str(e))
except NoPeerAvailable: except NoPeerAvailable:
self.config_dialog.label_error.setText(self.tr("Could not connect. Check node peering entry")) self.config_dialog.label_error.setText(self.tr("Could not connect. Check node peering entry"))
except aiohttp.errors.TimeoutError:
self.config_dialog.label_error.setText(self.tr("Could not connect. Check hostname, ip address or port"))
@asyncify @asyncify
async def check_register(self, checked=False): async def check_register(self, checked=False):
server = self.config_dialog.lineedit_server.text() server = self.config_dialog.lineedit_server.text()
port = self.config_dialog.spinbox_port.value() port = self.config_dialog.spinbox_port.value()
logging.debug("Is valid ? ") logging.debug("Is valid ? ")
self.config_dialog.label_error.setText(self.tr("connecting..."))
try: try:
session = aiohttp.ClientSession() session = aiohttp.ClientSession()
self.node = await Node.from_address(None, server, port, session=session) self.node = await Node.from_address(None, server, port, session=session)
...@@ -152,6 +160,8 @@ Yours : {0}, the network : {1}""".format(registered[1], registered[2]))) ...@@ -152,6 +160,8 @@ Yours : {0}, the network : {1}""".format(registered[1], registered[2])))
self.config_dialog.label_error.setText(str(e)) self.config_dialog.label_error.setText(str(e))
except NoPeerAvailable: except NoPeerAvailable:
self.config_dialog.label_error.setText(self.tr("Could not connect. Check node peering entry")) self.config_dialog.label_error.setText(self.tr("Could not connect. Check node peering entry"))
except aiohttp.errors.TimeoutError:
self.config_dialog.label_error.setText(self.tr("Could not connect. Check hostname, ip address or port"))
def is_valid(self): def is_valid(self):
return self.node is not None return self.node is not None
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment