Brak połączenia z internetem - obsługa wyjątku

pull/1/head
pawel 2022-11-01 13:10:50 +01:00
rodzic e4e0462d40
commit de15254804
4 zmienionych plików z 14 dodań i 0 usunięć

Wyświetl plik

@ -64,6 +64,7 @@ import pl_google.pl_google as pl_google
lang = "pl_google"
pygame_bug = 0
data_sources_error_msg = ['_','zrodlo_danych_niedostepne']
hello_msg = ['_','tu_eksperymentalna_automatyczna_stacja_pogodowa','sr0wx']
goodbye_msg = ['_','tu_sr0wx']
read_sources_msg = False

Plik binarny nie jest wyświetlany.

Plik binarny nie jest wyświetlany.

Wyświetl plik

@ -77,6 +77,7 @@ import pygame
import sys
import logging, logging.handlers
import numpy
import urllib2
# ``os``, ``sys`` and ``time`` doesn't need further explanation, these are
# syandard Python packages.
@ -160,6 +161,18 @@ if len(args) > 0:
else:
modules = config.modules
try:
dane = urllib2.urlopen('http://google.pl', None, 30);
except urllib2.URLError, e:
modules = []
message += " ".join(config.data_sources_error_msg)
logger.info(COLOR_FAIL + "Brak połączenia z internetem" + COLOR_ENDC + "\n")
except socket.timeout:
modules = []
message += " ".join(config.data_sources_error_msg)
logger.info(COLOR_FAIL + "Brak połączenia z internetem" + COLOR_ENDC + "\n")
lang = my_import('.'.join((config.lang, config.lang)))
sources = [lang.source, ]