Giter Club home page Giter Club logo

apt-smart's People

Contributors

martin68 avatar tfogwill avatar xolox avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

apt-smart's Issues

Need option to test all mirrors

In some local network, the same country does not mean faster than foreign countries.

Please add an option to test all mirrors.

AttributeError: 'generator' object has no attribute 'updater'

I've had a few servers have this issue, this one is in singapore. Only thing I can guess is the mirror list is small for this region?

root@apac-sg:# apt-smart -l
2021-07-05 17:40:19 apac-sg.nexusbytes..com apt_smart[11019] INFO Checking if Debian 10 (buster) is available on http://security.debian.org ..
2021-07-05 17:40:19 apac-sg.nexusbytes..com apt_smart[11019] INFO Debian 10 (buster) is supported (based on security mirror).
2021-07-05 17:40:19 apac-sg.nexusbytes..com apt_smart[11019] INFO Adding BASE_URL mirror:
2021-07-05 17:40:19 apac-sg.nexusbytes.root@apac-sg:
# apt-smart -l apt_smart[11019] INFO http://ftp.debian.org/debian
2021-07-05 17:40:19 apac-sg.nexusbytes.root@apac-sg:# apt-smart -l apt_smart.backends.debian[11019] INFO Discovering Debian mirrors at https://www.debian.org/mirror/list ..
2021-07-05 17:40:20 apac-sg.nexusbytes.root@apac-sg:
# apt-smart -l apt_smart.backends.debian[11019] INFO Found your location: Singapore by https://ipapi.co/json
2021-07-05 17:40:22 apac-sg.nexusbytes.root@apac-sg:# apt-smart -l apt_smart.backends.debian[11019] INFO Discovered 3 Debian mirrors in 2.21 seconds.
2021-07-05 17:40:22 apac-sg.nexusbytes.root@apac-sg:
# apt-smart -l apt_smart.cli[11019] ERROR Encountered unexpected exception! Aborting ..
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/apt_smart/cli.py", line 211, in main
callback()
File "/usr/local/lib/python3.7/dist-packages/apt_smart/cli.py", line 231, in report_available_mirrors
have_bandwidth = any(c.bandwidth for c in updater.ranked_mirrors)
File "/usr/local/lib/python3.7/dist-packages/property_manager3/init.py", line 784, in get
value = super(custom_property, self).get(obj, type)
File "/usr/local/lib/python3.7/dist-packages/apt_smart/init.py", line 390, in ranked_mirrors
mirrors = sorted(self.available_mirrors, key=lambda c: c.sort_key, reverse=True)
File "/usr/local/lib/python3.7/dist-packages/property_manager3/init.py", line 784, in get
value = super(custom_property, self).get(obj, type)
File "/usr/local/lib/python3.7/dist-packages/apt_smart/init.py", line 158, in available_mirrors
candidate.updater = self
AttributeError: 'generator' object has no attribute 'updater'

update list of packages required for installation

Thanks for this.
I've just installed it on my Kubuntu 20.10 system.
However, I got an error message when I entered the command sudo apt install python-pip python-setuptools python-wheel and then discovered that I actually needed to install the python3-pip package only.
It seems you need to update this information.

Printing the full output of apt-smart --list-mirrors to a file

I'd like to automate the process of selecting the best mirror via a cron job script. Probably the biggest problem is that I can't print the output of apt-smart --list-mirrors to a file fully. For example, the command apt-smart --list-mirrors > /tmp/mirrors.txt contains only the names of mirror servers - without rank, last updated and bandwidth columns, which I also need so that I can better optimize the choice of the best server, as currently apt-smart --find-best-mirror unfortunately chooses the most up-to-date server, although it may be far too slow compared with another which is several times faster while only a couple of hours behind its last update time.

Permit selection of repo by index (rather than URL)

Currently, -l lists mirrors indexed, and -b just lists the first one and -a selects that first one.

It has happened to me that I want to use 2 or 3, for example, but am constrained to copy and paste the URL and us -c

IMHO, if there was an option akin to -l which prompted for and expected an int as input would then configure the selected one.

-c cannot take an int reliably, as the list of the last l run is not guaranteed to be the same when you run with c but you could bind this to -cl (or -lc) reliably, meaning change based on a list, or of course use a whole new option like C for interactive change which dumps then output of -l then prompts for an int to select one of them and once entered configures it.

Given the ease with which an int can be mis-typed or selected a confirmation step may be warranted, printing the URL selected and asking for confirmation.

unexpected exception fetching https://www.debian.org/mirror/list

`root@plex:~# apt-smart -b
2021-01-13 13:19:24 plex.cronus89.com apt_smart[10633] INFO Checking if Debian 10 (buster) is available on http://security.debian.org ..
2021-01-13 13:19:29 plex.cronus89.com apt_smart[10633] INFO Debian 10 (buster) is supported (based on security mirror).
2021-01-13 13:19:29 plex.cronus89.com apt_smart[10633] INFO Adding BASE_URL mirror:
2021-01-13 13:19:29 plex.cronus89.com apt_smart[10633] INFO http://ftp.debian.org/debian
2021-01-13 13:19:29 plex.cronus89.com apt_smart.backends.debian[10633] INFO Discovering Debian mirrors at https://www.debian.org/mirror/list ..
2021-01-13 13:19:39 plex.cronus89.com apt_smart.cli[10633] ERROR Encountered unexpected exception! Aborting ..
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/apt_smart/backends/debian.py", line 108, in discover_mirrors
response = fetch_url(url, timeout=2)
File "/usr/local/lib/python3.7/dist-packages/apt_smart/http.py", line 53, in fetch_url
response = urlopen(url)
File "/usr/lib/python3.7/urllib/request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python3.7/urllib/request.py", line 525, in open
response = self._open(req, data)
File "/usr/lib/python3.7/urllib/request.py", line 543, in _open
'_open', req)
File "/usr/lib/python3.7/urllib/request.py", line 503, in _call_chain
result = func(*args)
File "/usr/lib/python3.7/urllib/request.py", line 1367, in https_open
context=self._context, check_hostname=self._check_hostname)
File "/usr/lib/python3.7/urllib/request.py", line 1324, in do_open
encode_chunked=req.has_header('Transfer-encoding'))
File "/usr/lib/python3.7/http/client.py", line 1244, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/lib/python3.7/http/client.py", line 1290, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/lib/python3.7/http/client.py", line 1239, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/lib/python3.7/http/client.py", line 1026, in _send_output
self.send(msg)
File "/usr/lib/python3.7/http/client.py", line 966, in send
self.connect()
File "/usr/lib/python3.7/http/client.py", line 1399, in connect
super().connect()
File "/usr/lib/python3.7/http/client.py", line 938, in connect
(self.host,self.port), self.timeout, self.source_address)
File "/usr/lib/python3.7/socket.py", line 707, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
File "/usr/lib/python3.7/socket.py", line 748, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
File "/usr/local/lib/python3.7/dist-packages/stopit/signalstop.py", line 29, in handle_timeout
'value (%d seconds).' % self.seconds)
stopit.utils.TimeoutException: Block exceeded maximum timeout value (2 seconds).

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/apt_smart/cli.py", line 211, in main
callback()
File "/usr/local/lib/python3.7/dist-packages/apt_smart/cli.py", line 224, in report_best_mirror
output(updater.best_mirror)
File "/usr/local/lib/python3.7/dist-packages/property_manager3/init.py", line 784, in get
value = super(custom_property, self).get(obj, type)
File "/usr/local/lib/python3.7/dist-packages/apt_smart/init.py", line 208, in best_mirror
return self.ranked_mirrors[0].mirror_url
File "/usr/local/lib/python3.7/dist-packages/property_manager3/init.py", line 784, in get
value = super(custom_property, self).get(obj, type)
File "/usr/local/lib/python3.7/dist-packages/apt_smart/init.py", line 390, in ranked_mirrors
mirrors = sorted(self.available_mirrors, key=lambda c: c.sort_key, reverse=True)
File "/usr/local/lib/python3.7/dist-packages/property_manager3/init.py", line 784, in get
value = super(custom_property, self).get(obj, type)
File "/usr/local/lib/python3.7/dist-packages/apt_smart/init.py", line 153, in available_mirrors
for candidate in self.backend.discover_mirrors():
File "/usr/local/lib/python3.7/dist-packages/apt_smart/backends/debian.py", line 118, in discover_mirrors
response = fetch_url(url, timeout=5)
File "/usr/local/lib/python3.7/dist-packages/apt_smart/http.py", line 53, in fetch_url
response = urlopen(url)
File "/usr/lib/python3.7/urllib/request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python3.7/urllib/request.py", line 525, in open
response = self._open(req, data)
File "/usr/lib/python3.7/urllib/request.py", line 543, in _open
'_open', req)
File "/usr/lib/python3.7/urllib/request.py", line 503, in _call_chain
result = func(*args)
File "/usr/lib/python3.7/urllib/request.py", line 1352, in http_open
return self.do_open(http.client.HTTPConnection, req)
File "/usr/lib/python3.7/urllib/request.py", line 1324, in do_open
encode_chunked=req.has_header('Transfer-encoding'))
File "/usr/lib/python3.7/http/client.py", line 1244, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/lib/python3.7/http/client.py", line 1290, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/lib/python3.7/http/client.py", line 1239, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/lib/python3.7/http/client.py", line 1026, in _send_output
self.send(msg)
File "/usr/lib/python3.7/http/client.py", line 966, in send
self.connect()
File "/usr/lib/python3.7/http/client.py", line 938, in connect
(self.host,self.port), self.timeout, self.source_address)
File "/usr/lib/python3.7/socket.py", line 707, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
File "/usr/lib/python3.7/socket.py", line 748, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
File "/usr/local/lib/python3.7/dist-packages/stopit/signalstop.py", line 29, in handle_timeout
'value (%d seconds).' % self.seconds)
stopit.utils.TimeoutException: Block exceeded maximum timeout value (5 seconds).`

When I manually curl https://www.debian.org/mirror/list it connects fine and has no issues.

Version: 7.1.1 on Python 3.6: 'apt-smart -a' does not inform of updates

Each of (1) sudo apt-get update and (2) sudo apt-update yields a message that some package(s) 'can be upgraded' if (and only if) some package(s) can in fact be upgraded. apt-smart a seems not to do that. Thus, any script that, in order to check for possible updates, parses the ouput of 1 or 2 will fail if your program is used instead. See e.g. this snippet of bash that I wrote (or rather that I adapted so as to use apt-smart instead of apt).

Error on `apt-smart --version`

Seems like something is wrong here. πŸ˜‰

$ apt-smart --version
Version: 7.1.3 on Python 3.8
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/usr/lib/python3.8/logging/__init__.py", line 2127, in shutdown
    h.close()
  File "/usr/lib/python3.8/logging/handlers.py", line 892, in close
    self.socket.close()
AttributeError: 'SysLogHandler' object has no attribute 'socket'

The above still exits with code 0, but the following exits with code 120:

$ (set -Eeuo pipefail; apt-smart --version 2>&1 | head -n1; echo $?); echo $?
Version: 7.1.3 on Python 3.8
120

Apt-smart does not work on Ubuntu 24.04 LTS (Noble)

I installed and ran apt-smart like this:

sudo python3 -m pip install -U apt-smart --break-system-packages
apt-smart -a

and got this traceback:

Encountered unexpected exception! Aborting ..
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/dist-packages/apt_smart/cli.py", line 211, in main
    callback()
  File "/usr/local/lib/python3.12/dist-packages/apt_smart/__init__.py", line 589, in change_mirror
    new_mirror = self.best_mirror
                 ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/property_manager3/__init__.py", line 784, in __get__
    value = super(custom_property, self).__get__(obj, type)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/apt_smart/__init__.py", line 203, in best_mirror
    logger.debug("Selecting best %s mirror ..", self.distributor_id.capitalize())
                                                ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/property_manager3/__init__.py", line 784, in __get__
    value = super(custom_property, self).__get__(obj, type)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/apt_smart/__init__.py", line 313, in distributor_id
    return self.release.distributor_id
           ^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/property_manager3/__init__.py", line 784, in __get__
    value = super(custom_property, self).__get__(obj, type)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/apt_smart/__init__.py", line 447, in release
    return coerce_release(self.distribution_codename)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/property_manager3/__init__.py", line 784, in __get__
    value = super(custom_property, self).__get__(obj, type)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/apt_smart/__init__.py", line 298, in distribution_codename
    raise EnvironmentError("Failed to determine the distribution codename using apt's package resource list!")
OSError: Failed to determine the distribution codename using apt's package resource list!

I suspect this is because of the switch to the deb822 format for Ubuntu sources:

$ cat /etc/apt/sources.list
# Ubuntu sources have moved to the /etc/apt/sources.list.d/ubuntu.sources
# file, which uses the deb822 format. Use deb822-formatted .sources files
# to manage package sources in the /etc/apt/sources.list.d/ directory.
# See the sources.list(5) manual page for details.

Trace back error

When I install the apt smart package but I don't know how to solve this traceback error

Error if use mirror scheme

In /etc/apt/sources.list.
If I use deb mirror://mirrors.ubuntu.com/mirrors.txt focal main, it fails:

2019-12-18 00:13:53 aya-NH50 executor.process[7612] DEBUG Executing external command: test -e /etc/apt/sources.list.d/official-package-repositories.list
2019-12-18 00:13:53 aya-NH50 executor.process[7612] DEBUG Constructing subprocess.Popen object ..
2019-12-18 00:13:53 aya-NH50 executor.process[7612] DEBUG Joining synchronous process using subprocess.Popen.communicate() ..
2019-12-18 00:13:53 aya-NH50 executor.process[7612] DEBUG Got return code 1 from synchronous process (test -e /etc/apt/sources.list.d/official-package-repositories.list).
2019-12-18 00:13:53 aya-NH50 executor.process[7612] DEBUG Executing external command: cat /etc/apt/sources.list
2019-12-18 00:13:53 aya-NH50 executor.process[7612] DEBUG Constructing subprocess.Popen object ..
2019-12-18 00:13:53 aya-NH50 executor.process[7612] DEBUG Joining synchronous process using subprocess.Popen.communicate() ..
2019-12-18 00:13:53 aya-NH50 executor.process[7612] DEBUG Got return code 0 from synchronous process (cat /etc/apt/sources.list).
2019-12-18 00:13:53 aya-NH50 apt_smart.cli[7612] ERROR Encountered unexpected exception! Aborting ..
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/apt_smart/cli.py", line 211, in main
    callback()
  File "/usr/local/lib/python3.7/dist-packages/apt_smart/cli.py", line 231, in report_available_mirrors
    have_bandwidth = any(c.bandwidth for c in updater.ranked_mirrors)
  File "/usr/local/lib/python3.7/dist-packages/property_manager3/__init__.py", line 784, in __get__
    value = super(custom_property, self).__get__(obj, type)
  File "/usr/local/lib/python3.7/dist-packages/apt_smart/__init__.py", line 387, in ranked_mirrors
    mirrors = sorted(self.available_mirrors, key=lambda c: c.sort_key, reverse=True)
  File "/usr/local/lib/python3.7/dist-packages/property_manager3/__init__.py", line 784, in __get__
    value = super(custom_property, self).__get__(obj, type)
  File "/usr/local/lib/python3.7/dist-packages/apt_smart/__init__.py", line 131, in available_mirrors
    if self.release_is_eol:
  File "/usr/local/lib/python3.7/dist-packages/property_manager3/__init__.py", line 784, in __get__
    value = super(custom_property, self).__get__(obj, type)
  File "/usr/local/lib/python3.7/dist-packages/apt_smart/__init__.py", line 475, in release_is_eol
    logger.debug("Checking whether %s is EOL ..", self.release)
  File "/usr/local/lib/python3.7/dist-packages/property_manager3/__init__.py", line 784, in __get__
    value = super(custom_property, self).__get__(obj, type)
  File "/usr/local/lib/python3.7/dist-packages/apt_smart/__init__.py", line 444, in release
    return coerce_release(self.distribution_codename)
  File "/usr/local/lib/python3.7/dist-packages/property_manager3/__init__.py", line 784, in __get__
    value = super(custom_property, self).__get__(obj, type)
  File "/usr/local/lib/python3.7/dist-packages/apt_smart/__init__.py", line 295, in distribution_codename
    raise EnvironmentError("Failed to determine the distribution codename using apt's package resource list!")
OSError: Failed to determine the distribution codename using apt's package resource list!

It works if I use general url such as:
deb http://archive.ubuntu.com/ubuntu/ focal main

apt-smart seems to fail when a mirror redirects

Been noticing lately that some of the fastest mirrors here in western canada fail to get properly evaluated by apt-smart because they redirect to a different domain:

$ apt-smart -l
------------------------------------------------------------------------------------------------------
| Rank | Mirror URL                         | Available? | Updating? | Last updated    | Bandwidth   |
------------------------------------------------------------------------------------------------------
|    1 | http://ubuntu.ca-west.mirror.fu... | Yes        | No        | Up to date      | 756.01 KB/s |
|    2 | http://archive.ubuntu.com/ubuntu   | Yes        | No        | Up to date      | 125.06 KB/s |
|    3 | http://mirror.ca-tr.kamatera.co... | Yes        | No        | 2 hours behind  | 323.41 KB/s |
|    4 | http://ubuntu.mirror.iweb.ca       | Yes        | No        | 2 hours behind  | 287.97 KB/s |
|    5 | http://ubuntu.mirror.rafal.ca/u... | Yes        | No        | 2 hours behind  | 258.71 KB/s |
|    6 | http://archive.ubuntu.mirror.ra... | Yes        | No        | 2 hours behind  | 241.21 KB/s |
|    7 | https://mirror.esecuredata.com/... | Yes        | No        | 2 hours behind  | 153.14 KB/s |
|    8 | http://mirror.rcg.sfu.ca/mirror... | Yes        | No        | 4 hours behind  | 589.06 KB/s |
|    9 | http://mirror.csclub.uwaterloo.... | Yes        | No        | 4 hours behind  | 299.43 KB/s |
|   10 | http://ubuntu.mirror.globo.tech    | Yes        | No        | 6 hours behind  | 276.76 KB/s |
|   11 | http://mirror.its.dal.ca/ubuntu    | Yes        | No        | 11 hours behind | 208.07 KB/s |
|   12 | http://gpl.savoirfairelinux.net... | Yes        | No        | 18 hours behind | 268.65 KB/s |
|   13 | https://mirror.reenigne.net/ubuntu | Yes        | No        | 20 hours behind | 195.08 KB/s |
|   14 | http://ubuntu.bhs.mirrors.ovh.n... | Yes        | No        | 1 day behind    | 219.52 KB/s |
|   15 | http://mirror.it.ubc.ca/ubuntu     | Yes        | No        | 4 days behind   | 1.47 MB/s   |
|   16 | http://muug.ca/mirror/ubuntu       | Yes        | No        | 8 weeks behind  | 577.77 KB/s |
|   17 | http://mirror.clibre.uqam.ca/ub... | No         | No        | Unknown         | Unknown     |
|   18 | http://mirror.layeronline.com/u... | No         | No        | Unknown         | Unknown     |
|   19 | http://mirror.cedille.club/ubuntu  | No         | No        | Unknown         | Unknown     |
|   20 | http://mirrors.layeronline.com/... | No         | No        | Unknown         | Unknown     |
------------------------------------------------------------------------------------------------------

layeronline specifically redirects to https://mirrors.edge.kernel.org/ubuntu/, which is the fastest mirror from my ISP, but apt-smart ignores it. would be great if apt-smart was able to follow redirects and still eval these mirrors.

Feature Request: stdin support

I'm not sure if it can be done without this but hope there'll be native support for stdin so I can use some code to input a list of URLs directly into apt-smart.

Feature Request: Allow testing of other OS repositories

I host an apt server which mirrors content from various deb-based distros like Debian, Kali and Ubuntu.

Ideally I'd like apt-smart to be able to take a parameter for the distro, so that I can check the performance of mirrors for each distro that I mirror.

Need to accurately detect distro codename

apt-smart appears to use a hard-coded list of url to determine distro codename:

  • /etc/apt/sources.list
  • /etc/apt/sources.list.d/official-package-repositories.list

apt-smart should support dynamic sources, scanning .list files under /etc/apt/sources.list.d/.

In all of the boxes in our environment, /etc/apt/sources.list is empty and we use one file per repositories in /etc/apt/sources.list.d

Running apt-smart in our environment, supplying a mirror list file results in apt-smart failing with:
2020-09-30 11:35:09 hostname.domain.com property_manager3[14498] SPAM Setting value of AptMirrorUpdater.get_sources_list_options property to {2: 'Ubuntu-Server 18.04 LTS _Bionic Beaver_ - Release amd64 (20180426)', 4: 'Ubuntu-Server 18.04 LTS _Bionic Beaver_ - Release amd64 (20180426)'} .. 2020-09-30 11:35:09 hostname.domain.com apt_smart.cli[14498] ERROR Encountered unexpected exception! Aborting .. Failed to determine the distribution codename

Would it be a better idea to just get the distro information from /etc/os-release?

UnicodeDecodeError: 'ascii' codec can't decode byte 0xeb

I stumbled onto apt-smart while attempting to find solutions to the common "hash sum mismatch" problem with apt-get.

I installed as per instructions and then ran apt-smart -b as can be seen in the below output. However the below error was encountered.

The second time I ran it succeeded and reported mirror http://mirror.solnode.io/ubuntu/releases.

However the third and all subsequent attempts failed with the below error although with different ordinal positions eg byte 0x8d in position 46457, byte 0xe6 in position 53352, byte 0xb0 in position 15208.

Scripts are being run in Ubuntu 18.04 using Vagrant with VirtualBox hosted in Win10.

vagrant@vagrant:~$ which apt-smart
/home/vagrant/.local/bin/apt-smart
vagrant@vagrant:~$ apt-smart -b
2020-05-02 01:55:08 vagrant apt_smart[17170] INFO Ubuntu 18.04 (bionic) is supported (based on known EOL dates).
2020-05-02 01:55:08 vagrant apt_smart[17170] INFO Adding BASE_URL mirror:
2020-05-02 01:55:08 vagrant apt_smart[17170] INFO http://archive.ubuntu.com/ubuntu
2020-05-02 01:55:08 vagrant apt_smart.backends.ubuntu[17170] INFO Identifying fast Ubuntu mirrors using http://mirrors.ubuntu.com/mirrors.txt ..
2020-05-02 01:55:09 vagrant apt_smart.backends.ubuntu[17170] INFO Discovered 18 Ubuntu mirrors in 1.22 second.
2020-05-02 01:55:09 vagrant apt_smart[17170] INFO Checking 18 mirrors for availability and performance ..
2020-05-02 01:55:14 vagrant apt_smart[17170] INFO Start retrieving :attr:`base_last_updated` using is_available
2020-05-02 01:55:14 vagrant apt_smart.cli[17170] ERROR Encountered unexpected exception! Aborting ..
Traceback (most recent call last):
  File "/home/vagrant/.local/lib/python2.7/site-packages/apt_smart/cli.py", line 211, in main
    callback()
  File "/home/vagrant/.local/lib/python2.7/site-packages/apt_smart/cli.py", line 224, in report_best_mirror
    output(updater.best_mirror)
  File "/home/vagrant/.local/lib/python2.7/site-packages/property_manager/__init__.py", line 788, in __get__
    value = super(custom_property, self).__get__(obj, type)
  File "/home/vagrant/.local/lib/python2.7/site-packages/apt_smart/__init__.py", line 208, in best_mirror
    return self.ranked_mirrors[0].mirror_url
  File "/home/vagrant/.local/lib/python2.7/site-packages/property_manager/__init__.py", line 788, in __get__
    value = super(custom_property, self).__get__(obj, type)
  File "/home/vagrant/.local/lib/python2.7/site-packages/apt_smart/__init__.py", line 422, in ranked_mirrors
    update_mapping = dict((c.archive_update_in_progress_url, c) for c in mirrors if c.is_available)
  File "/home/vagrant/.local/lib/python2.7/site-packages/apt_smart/__init__.py", line 422, in <genexpr>
    update_mapping = dict((c.archive_update_in_progress_url, c) for c in mirrors if c.is_available)
  File "/home/vagrant/.local/lib/python2.7/site-packages/property_manager/__init__.py", line 788, in __get__
    value = super(custom_property, self).__get__(obj, type)
  File "/home/vagrant/.local/lib/python2.7/site-packages/apt_smart/__init__.py", line 1045, in is_available
    date_string_raw = self.release_gpg_contents.decode().split("Date: ", 1)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xeb in position 36813: ordinal not in range(128)

maybe a smarter choice needed?

For me the output of the command apt-smart --list-mirrors is:

------------------------------------------------------------------------------------------------------
| Rank | Mirror URL                         | Available? | Updating? | Last updated    | Bandwidth   |
------------------------------------------------------------------------------------------------------
|    1 | http://archive.ubuntu.com/ubuntu   | Yes        | No        | Up to date      | 335.33 KB/s |
|    2 | http://ubuntu.turhost.com/ubuntu   | Yes        | No        | 1 hour behind   | 708.1 KB/s  |
|    3 | http://ubuntu.saglayici.com/ubuntu | Yes        | No        | 3 hours behind  | 430.89 KB/s |
|    4 | http://ubuntu.vargonen.com/ubuntu  | Yes        | No        | 3 hours behind  | 122.09 KB/s |
|    5 | http://mirror.muvhost.com/ubuntu   | Yes        | No        | 4 hours behind  | 666.03 KB/s |
|    6 | http://mirror.ni.net.tr/ubuntu     | Yes        | No        | 12 hours behind | 588.75 KB/s |
|    7 | https://mirror.sh.com.tr/ubuntu    | Yes        | No        | 1 week behind   | 801.89 KB/s |
|    8 | http://ftp.linux.org.tr/ubuntu     | Yes        | Yes       | 4 hours behind  | 422.29 KB/s |
------------------------------------------------------------------------------------------------------

And the output of the command apt-smart --find-best-mirror is http://archive.ubuntu.com.
It seems to me that apt-smart is not taking into account the bandwidth (server speed) enough.
I fully agree that, in general, server speed is less important than the time since it was updated.
For instance, the server ranking 7 in the list could even be at the very bottom.
However, I think being merely β€œ1 hour behind” should be considered less important than having less than half the speed.
Therefore, I think the 2nd server in the list should actually be selected as the best mirror.

Not found reliable way to get up-to-date distro info of Linuxmint yet, you may have problem if you use newest version of Linuxmint

Unlike Ubuntu having distro-info package which can be got updated by APT, Linuxmint does not have similar package to get up-to-date distro info, at lease I cannot find one. Currently, it relies on me to update the bundled Releases of Linuxmint by run make releases and then publish to github and then release new version of apt-smart. Unfortunately I cannot update it manually in time when new version of Linuxmint is released. This happened when Linux Mint 19.3 Tricia was released several months ago (see #4), obviously it should not happen again. So any suggestion?

P.S. as I said above, if you ran into similar problem, you can run make releases to update bundled Releases to get it work.
(see b7efb9d)

Output list of up-to-date Ubuntu mirrors

Since I have updated from the main Ubuntu repository, I can only use up to date mirrors without crashing my system.

I need to filter the list generated from apt-smart to only show up to date mirrors.

Maybe the list should be in a different format so I can use it like in ilikenwf/apt-fast#79.

distribution_codename() seems broken on Ubuntu 22.04

attempting to test apt-smart on the latest Ubuntu LTS, and it fails in the most basic use case, can't seem to detect the release name from /etc/apt/sources.list, even though it's the default config:

# docker run -it ubuntu:22.04
root@31c59159a087:/# apt update && apt install -y python3-pip
[ apt installing ]
root@31c59159a087:/# pip install apt-smart
[ pip installing ]
root@31c59159a087:/# apt-smart -a
2022-05-16 16:45:57 31c59159a087 apt_smart[4205] INFO Changing mirror of local system (31c59159a087) to best available mirror ..
2022-05-16 16:45:57 31c59159a087 apt_smart.cli[4205] ERROR Encountered unexpected exception! Aborting ..
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/apt_smart/cli.py", line 211, in main
    callback()
  File "/usr/local/lib/python3.10/dist-packages/apt_smart/__init__.py", line 589, in change_mirror
    new_mirror = self.best_mirror
  File "/usr/local/lib/python3.10/dist-packages/property_manager3/__init__.py", line 784, in __get__
    value = super(custom_property, self).__get__(obj, type)
  File "/usr/local/lib/python3.10/dist-packages/apt_smart/__init__.py", line 203, in best_mirror
    logger.debug("Selecting best %s mirror ..", self.distributor_id.capitalize())
  File "/usr/local/lib/python3.10/dist-packages/property_manager3/__init__.py", line 784, in __get__
    value = super(custom_property, self).__get__(obj, type)
  File "/usr/local/lib/python3.10/dist-packages/apt_smart/__init__.py", line 313, in distributor_id
    return self.release.distributor_id
  File "/usr/local/lib/python3.10/dist-packages/property_manager3/__init__.py", line 784, in __get__
    value = super(custom_property, self).__get__(obj, type)
  File "/usr/local/lib/python3.10/dist-packages/apt_smart/__init__.py", line 447, in release
    return coerce_release(self.distribution_codename)
  File "/usr/local/lib/python3.10/dist-packages/property_manager3/__init__.py", line 784, in __get__
    value = super(custom_property, self).__get__(obj, type)
  File "/usr/local/lib/python3.10/dist-packages/apt_smart/__init__.py", line 298, in distribution_codename
    raise EnvironmentError("Failed to determine the distribution codename using apt's package resource list!")
OSError: Failed to determine the distribution codename using apt's package resource list!

note that this could probably be fixed by resolving issue #10.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.