mirror of
https://git.launchpad.net/~ubuntu-qt-code/+git/calamares-settings-ubuntu
synced 2025-03-03 23:31:08 +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
|
||||
geoip:
|
||||
style: "json"
|
||||
url: "https://ipapi.co/json"
|
||||
style: "xml"
|
||||
url: "https://geoip.ubuntu.com/lookup"
|
||||
|
||||
# Distribution that this is based off 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 logging
|
||||
import distro
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
global sources
|
||||
sources = """# Automatically generated by Calamares on DATE.
|
||||
@ -99,10 +100,20 @@ def getcountrycode():
|
||||
an empty string.
|
||||
"""
|
||||
if libcalamares.globalstorage.value("hasInternet"):
|
||||
geoip_style = libcalamares.job.configuration["geoip"]["style"]
|
||||
geoipurl = libcalamares.job.configuration["geoip"]["url"]
|
||||
|
||||
try:
|
||||
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:
|
||||
logging.error("Data not retrieved because %s - URL: %s",
|
||||
http_error, geoipurl)
|
||||
@ -113,9 +124,7 @@ def getcountrycode():
|
||||
logging.error("Non-timeout protocol error.")
|
||||
else:
|
||||
logging.info("Country successfully determined.")
|
||||
return localedata["country"]
|
||||
else:
|
||||
return ""
|
||||
return ""
|
||||
|
||||
|
||||
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
|
||||
|
||||
* 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
|
||||
|
||||
|
@ -2,5 +2,5 @@
|
||||
baseUrl: archive.ubuntu.com
|
||||
distribution: Lubuntu
|
||||
geoip:
|
||||
style: "json"
|
||||
url: "https://ipapi.co/json"
|
||||
style: "xml"
|
||||
url: "https://geoip.ubuntu.com/lookup"
|
||||
|
Loading…
x
Reference in New Issue
Block a user