display any error received when checking for updates
This commit is contained in:
parent
3b67433a67
commit
b169d35316
|
@ -74,16 +74,17 @@ class RefreshController(BaseController):
|
|||
response.raise_for_status()
|
||||
except requests.exceptions.RequestException as e:
|
||||
log.exception("checking for update")
|
||||
self.check_error = e
|
||||
self.check_state = CheckState.FAILED
|
||||
return
|
||||
result = response.json()
|
||||
log.debug("_check_result %s", result)
|
||||
for snap in result["result"]:
|
||||
if snap["name"] == self.snap_name:
|
||||
self.check_state = CheckState.AVAILABLE
|
||||
break
|
||||
else:
|
||||
self.check_state = CheckState.UNAVAILABLE
|
||||
result = response.json()
|
||||
log.debug("_check_result %s", result)
|
||||
for snap in result["result"]:
|
||||
if snap["name"] == self.snap_name:
|
||||
self.check_state = CheckState.AVAILABLE
|
||||
break
|
||||
else:
|
||||
self.check_state = CheckState.UNAVAILABLE
|
||||
if self.view:
|
||||
self.view.update_check_state()
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import json
|
||||
import logging
|
||||
|
||||
from urwid import (
|
||||
|
@ -178,10 +179,19 @@ class RefreshView(BaseView):
|
|||
def check_state_failed(self):
|
||||
self.spinner.stop()
|
||||
|
||||
rows = [Text("<explanation goes here>")]
|
||||
try:
|
||||
result = self.controller.check_error.response.json()
|
||||
except (AttributeError, json.decoder.JSONDecodeError):
|
||||
message = None
|
||||
else:
|
||||
message = result.get("result", {}).get("message")
|
||||
if message is None:
|
||||
message = "Unknown error: {}".format(self.controller.check_error)
|
||||
|
||||
rows = [Text(message)]
|
||||
|
||||
buttons = button_pile([
|
||||
done_btn(_("Try again"), on_press=self.still_checking),
|
||||
done_btn(_("Try again"), on_press=self.try_again),
|
||||
done_btn(_("Continue without updating"), on_press=self.done),
|
||||
other_btn(_("Back"), on_press=self.cancel),
|
||||
])
|
||||
|
@ -190,6 +200,10 @@ class RefreshView(BaseView):
|
|||
self.title = self.failed_title
|
||||
self._w = screen(rows, buttons, excerpt=_(self.failed_excerpt))
|
||||
|
||||
def try_again(self, sender=None):
|
||||
self.controller.snapd_network_changed()
|
||||
self.check_state_checking()
|
||||
|
||||
def update(self, sender=None):
|
||||
self.spinner.stop()
|
||||
|
||||
|
|
|
@ -284,7 +284,7 @@ class Application:
|
|||
"signal": Signal(),
|
||||
"prober": prober,
|
||||
"loop": None,
|
||||
"pool": futures.ThreadPoolExecutor(4),
|
||||
"pool": futures.ThreadPoolExecutor(10),
|
||||
"answers": answers,
|
||||
"input_filter": input_filter,
|
||||
"scale_factor": scale,
|
||||
|
|
Loading…
Reference in New Issue