linuxmint / cinnamon

A Linux desktop featuring a traditional layout, built from modern technology and introducing brand new innovative features.
GNU General Public License v2.0
4.56k stars 745 forks source link

Unable to download applets, themes, desklets and extensions when using network proxy #7945

Open jesperloehr opened 6 years ago

jesperloehr commented 6 years ago

Issue After upgrading from Cinnamon 3.8.8 to 3.8.9 it is not possible to refresh cache or download when using Applets, Themes, Desklets or Extensions in System Settings. It gives the error: "An error occured while trying to access the server. Please try again in a little while. Details: timed out."

Steps to reproduce I only have internet access through a proxy server. Proxy is configured in network settings.

Expected behaviour The System Settings application should use the configured proxy.

Other information I identified the problem is from a change in /usr/share/cinnamon/cinnamon-settings/bin/Spices.py installed from the cinnamon-common package. In 3.8.9 it has been changed to use http.client.HTTPSConnection to fetch updates and there is no code that checks for the proxy configuration.

def _url_retrieve(self, url, outfd, reporthook, binary):
    #Like the one in urllib. Unlike urllib.retrieve url_retrieve
    #can be interrupted. KeyboardInterrupt exception is raised when
    #interrupted.
    count = 0
    blockSize = 1024 * 8
    parsed_url = urlparse(url)
    host = parsed_url.netloc
    try:
        connection = HTTPSConnection(host, timeout=15)
        headers = { "Accept-Encoding": "identity", "Host": host, "User-Agent": "Python/3" }
        connection.request("GET", parsed_url.path, headers=headers)
        urlobj = connection.getresponse()
        assert urlobj.getcode() == 200

In 3.8.8 it used urllib.request.urlopen.

def _url_retrieve(self, url, outfd, reporthook, binary):
    #Like the one in urllib. Unlike urllib.retrieve url_retrieve
    #can be interrupted. KeyboardInterrupt exception is raised when
    #interrupted.
    count = 0
    blockSize = 1024 * 8
    try:
        with urlopen(url, timeout=15) as urlobj:
            assert urlobj.getcode() == 200

Proxy configuration is configured for urllib.request in /usr/share/cinnamon/cinnamon-settings/cinnamon-settings.py.

if __name__ == "__main__":
    import signal

    ps = proxygsettings.get_proxy_settings()
    if ps:
        proxy = urllib.ProxyHandler(ps)
    else:
        proxy = urllib.ProxyHandler()
    urllib.install_opener(urllib.build_opener(proxy))

Replacing /usr/share/cinnamon/cinnamon-settings/bin/Spices.py with the the version from 3.8.8 solves the problem for me.

hylkevds commented 5 years ago

Just ran into the same problem. Reverting the change to _url_retrieve made the download work again.

ivanblanc commented 5 years ago

Thanks a lot, that helped me to solve the issue on Ubuntu. Btw, just copying the latest version of Spices.py does the magic.

jesperloehr commented 5 years ago

I just looked at the latest version of Spices.py and I do not see this as fixed.