mirror of
https://git.launchpad.net/~ubuntu-qt-code/+git/calamares-settings-ubuntu
synced 2025-07-01 19:51:30 +00:00
Use geoip.ubuntu.com by default.
This commit is contained in:
parent
ad4ab2cf25
commit
2be42e5594
@ -6,8 +6,8 @@ baseUrl: archive.ubuntu.com
|
|||||||
|
|
||||||
# URL used for IP address lookup
|
# URL used for IP address lookup
|
||||||
geoip:
|
geoip:
|
||||||
style: "json"
|
style: "xml"
|
||||||
url: "https://ipapi.co/json"
|
url: "https://geoip.ubuntu.com/lookup"
|
||||||
|
|
||||||
# Distribution that this is based off of.
|
# Distribution that this is based off of.
|
||||||
# This is so we can make safe assumptions for the contents of
|
# This is so we can make safe assumptions for the contents of
|
||||||
|
@ -24,6 +24,7 @@ from urllib.error import URLError
|
|||||||
import socket
|
import socket
|
||||||
import logging
|
import logging
|
||||||
import distro
|
import distro
|
||||||
|
import xml.etree.ElementTree as ET
|
||||||
|
|
||||||
global sources
|
global sources
|
||||||
sources = """# Automatically generated by Calamares on DATE.
|
sources = """# Automatically generated by Calamares on DATE.
|
||||||
@ -99,10 +100,20 @@ def getcountrycode():
|
|||||||
an empty string.
|
an empty string.
|
||||||
"""
|
"""
|
||||||
if libcalamares.globalstorage.value("hasInternet"):
|
if libcalamares.globalstorage.value("hasInternet"):
|
||||||
|
geoip_style = libcalamares.job.configuration["geoip"]["style"]
|
||||||
geoipurl = libcalamares.job.configuration["geoip"]["url"]
|
geoipurl = libcalamares.job.configuration["geoip"]["url"]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with urllib.request.urlopen(geoipurl, timeout=75) as http_response:
|
with urllib.request.urlopen(geoipurl, timeout=75) as http_response:
|
||||||
localedata = json.loads(http_response.read().decode())
|
if geoip_style == "json":
|
||||||
|
localedata = json.loads(http_response.read().decode())
|
||||||
|
return localedata["country_code"]
|
||||||
|
elif geoip_style == "xml":
|
||||||
|
tree = ET.parse(http_response)
|
||||||
|
root = tree.getroot()
|
||||||
|
return root.find("CountryCode").text
|
||||||
|
else:
|
||||||
|
logging.error("Unknown geoip style: %s", geoip_style)
|
||||||
except HTTPError as http_error:
|
except HTTPError as http_error:
|
||||||
logging.error("Data not retrieved because %s - URL: %s",
|
logging.error("Data not retrieved because %s - URL: %s",
|
||||||
http_error, geoipurl)
|
http_error, geoipurl)
|
||||||
@ -113,9 +124,7 @@ def getcountrycode():
|
|||||||
logging.error("Non-timeout protocol error.")
|
logging.error("Non-timeout protocol error.")
|
||||||
else:
|
else:
|
||||||
logging.info("Country successfully determined.")
|
logging.info("Country successfully determined.")
|
||||||
return localedata["country"]
|
return ""
|
||||||
else:
|
|
||||||
return ""
|
|
||||||
|
|
||||||
|
|
||||||
def get_subdomain_by_country(countrycode):
|
def get_subdomain_by_country(countrycode):
|
||||||
|
1
debian/changelog
vendored
1
debian/changelog
vendored
@ -1,6 +1,7 @@
|
|||||||
calamares-settings-ubuntu (1:23.10.4) UNRELEASED; urgency=medium
|
calamares-settings-ubuntu (1:23.10.4) UNRELEASED; urgency=medium
|
||||||
|
|
||||||
* Remove the Partners repository as an option.
|
* Remove the Partners repository as an option.
|
||||||
|
* Use geoip.ubuntu.com by default.
|
||||||
|
|
||||||
-- Simon Quigley <tsimonq2@ubuntu.com> Sun, 08 Oct 2023 11:53:28 -0500
|
-- Simon Quigley <tsimonq2@ubuntu.com> Sun, 08 Oct 2023 11:53:28 -0500
|
||||||
|
|
||||||
|
@ -2,5 +2,5 @@
|
|||||||
baseUrl: archive.ubuntu.com
|
baseUrl: archive.ubuntu.com
|
||||||
distribution: Lubuntu
|
distribution: Lubuntu
|
||||||
geoip:
|
geoip:
|
||||||
style: "json"
|
style: "xml"
|
||||||
url: "https://ipapi.co/json"
|
url: "https://geoip.ubuntu.com/lookup"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user