|
|
@ -108,13 +108,13 @@ def getcountrycode():
|
|
|
|
if libcalamares.globalstorage.value("hasInternet"):
|
|
|
|
if libcalamares.globalstorage.value("hasInternet"):
|
|
|
|
geoipurl = libcalamares.job.configuration["geoip"]["url"]
|
|
|
|
geoipurl = libcalamares.job.configuration["geoip"]["url"]
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
with urllib.request.urlopen(geoipurl, timeout=75) as url:
|
|
|
|
with urllib.request.urlopen(geoipurl, timeout=75) as http_response:
|
|
|
|
localedata = json.loads(url.read().decode())
|
|
|
|
localedata = json.loads(http_response.read().decode())
|
|
|
|
except HTTPError as error:
|
|
|
|
except HTTPError as http_error:
|
|
|
|
logging.error("Data not retrieved because %s - URL: %s",
|
|
|
|
logging.http_error("Data not retrieved because %s - URL: %s",
|
|
|
|
error, geoipurl)
|
|
|
|
http_error, geoipurl)
|
|
|
|
except URLError as error:
|
|
|
|
except URLError as url_error:
|
|
|
|
if isinstance(error.reason, socket.timeout):
|
|
|
|
if isinstance(url_error.reason, socket.timeout):
|
|
|
|
logging.error("Socket timed out - URL %s", geoipurl)
|
|
|
|
logging.error("Socket timed out - URL %s", geoipurl)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
logging.error("Non-timeout protocol error.")
|
|
|
|
logging.error("Non-timeout protocol error.")
|
|
|
@ -126,6 +126,9 @@ def getcountrycode():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_subdomain_by_country(countrycode):
|
|
|
|
def get_subdomain_by_country(countrycode):
|
|
|
|
|
|
|
|
"""Return the subdomain for the given countrycode
|
|
|
|
|
|
|
|
or an empty string.
|
|
|
|
|
|
|
|
"""
|
|
|
|
if countrycode in SUBDOMAINS_BY_COUNTRY_CODE.keys():
|
|
|
|
if countrycode in SUBDOMAINS_BY_COUNTRY_CODE.keys():
|
|
|
|
return SUBDOMAINS_BY_COUNTRY_CODE[countrycode]
|
|
|
|
return SUBDOMAINS_BY_COUNTRY_CODE[countrycode]
|
|
|
|
else:
|
|
|
|
else:
|
|
|
@ -133,10 +136,12 @@ def get_subdomain_by_country(countrycode):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def getcodename():
|
|
|
|
def getcodename():
|
|
|
|
|
|
|
|
"""Return the codename of the distribution, similar to lsb_release -cs"""
|
|
|
|
return get_distro_information()["CODENAME"]
|
|
|
|
return get_distro_information()["CODENAME"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def changesources(subdomain):
|
|
|
|
def changesources(subdomain):
|
|
|
|
|
|
|
|
"""Replace the placeholders and then create the sources.list"""
|
|
|
|
distro = libcalamares.job.configuration["distribution"]
|
|
|
|
distro = libcalamares.job.configuration["distribution"]
|
|
|
|
url = "http://{}{}".format(subdomain,
|
|
|
|
url = "http://{}{}".format(subdomain,
|
|
|
|
libcalamares.job.configuration["baseUrl"])
|
|
|
|
libcalamares.job.configuration["baseUrl"])
|
|
|
|