|
|
c48c22 |
From c8bff2cb5f2b3f01dd3f98adb7e8358d604b3c47 Mon Sep 17 00:00:00 2001
|
|
|
c48c22 |
From: Yuri Konotopov <ykonotopov@gnome.org>
|
|
|
c48c22 |
Date: Sun, 10 May 2020 14:22:47 +0400
|
|
|
c48c22 |
Subject: [PATCH] connector: drop updates support in favour of Shell 3.36
|
|
|
c48c22 |
default behavior
|
|
|
c48c22 |
|
|
|
c48c22 |
Closes: https://gitlab.gnome.org/GNOME/chrome-gnome-shell/-/issues/19
|
|
|
c48c22 |
---
|
|
|
c48c22 |
connector/chrome-gnome-shell.py | 91 +--------------------------------
|
|
|
c48c22 |
1 file changed, 1 insertion(+), 90 deletions(-)
|
|
|
c48c22 |
|
|
|
c48c22 |
diff --git a/connector/chrome-gnome-shell.py b/connector/chrome-gnome-shell.py
|
|
|
c48c22 |
index 0bde4dd..6c84ba9 100755
|
|
|
c48c22 |
--- a/connector/chrome-gnome-shell.py
|
|
|
c48c22 |
+++ b/connector/chrome-gnome-shell.py
|
|
|
c48c22 |
@@ -23,12 +23,6 @@ import struct
|
|
|
c48c22 |
import sys
|
|
|
c48c22 |
import traceback
|
|
|
c48c22 |
|
|
|
c48c22 |
-REQUESTS_IMPORTED = True
|
|
|
c48c22 |
-try:
|
|
|
c48c22 |
- import requests
|
|
|
c48c22 |
-except ImportError:
|
|
|
c48c22 |
- REQUESTS_IMPORTED = False
|
|
|
c48c22 |
-
|
|
|
c48c22 |
CONNECTOR_VERSION = 10
|
|
|
c48c22 |
DEBUG_ENABLED = False
|
|
|
c48c22 |
|
|
|
c48c22 |
@@ -371,9 +365,7 @@ class ChromeGNOMEShell(Gio.Application):
|
|
|
c48c22 |
else:
|
|
|
c48c22 |
disable_version_check = False
|
|
|
c48c22 |
|
|
|
c48c22 |
- supports = ['notifications', "update-enabled"]
|
|
|
c48c22 |
- if REQUESTS_IMPORTED:
|
|
|
c48c22 |
- supports.append('update-check')
|
|
|
c48c22 |
+ supports = ['notifications']
|
|
|
c48c22 |
|
|
|
c48c22 |
self.send_message(
|
|
|
c48c22 |
{
|
|
|
c48c22 |
@@ -474,16 +466,6 @@ class ChromeGNOMEShell(Gio.Application):
|
|
|
c48c22 |
GLib.Variant.new_tuple(GLib.Variant.new_string(request['uuid'])),
|
|
|
c48c22 |
"status")
|
|
|
c48c22 |
|
|
|
c48c22 |
- elif request['execute'] == 'checkUpdate':
|
|
|
c48c22 |
- update_url = 'https://extensions.gnome.org/update-info/'
|
|
|
c48c22 |
- enabled_only = True
|
|
|
c48c22 |
- if 'url' in request:
|
|
|
c48c22 |
- update_url = request['url']
|
|
|
c48c22 |
-
|
|
|
c48c22 |
- if 'enabledOnly' in request:
|
|
|
c48c22 |
- enabled_only = request['enabledOnly']
|
|
|
c48c22 |
-
|
|
|
c48c22 |
- self.check_update(update_url, enabled_only)
|
|
|
c48c22 |
|
|
|
c48c22 |
elif request['execute'] == 'createNotification':
|
|
|
c48c22 |
Gio.DBusActionGroup.get(
|
|
|
c48c22 |
@@ -502,77 +484,6 @@ class ChromeGNOMEShell(Gio.Application):
|
|
|
c48c22 |
|
|
|
c48c22 |
debug('Execute: from %s' % request['execute'])
|
|
|
c48c22 |
|
|
|
c48c22 |
- def check_update(self, update_url, enabled_only):
|
|
|
c48c22 |
- result = self.shell_proxy.call_sync(
|
|
|
c48c22 |
- "ListExtensions",
|
|
|
c48c22 |
- None,
|
|
|
c48c22 |
- Gio.DBusCallFlags.NONE,
|
|
|
c48c22 |
- -1,
|
|
|
c48c22 |
- None
|
|
|
c48c22 |
- )
|
|
|
c48c22 |
-
|
|
|
c48c22 |
- extensions = result.unpack()[0]
|
|
|
c48c22 |
- settings = Gio.Settings.new(SHELL_SCHEMA)
|
|
|
c48c22 |
- enabled_extensions = settings.get_strv(ENABLED_EXTENSIONS_KEY)
|
|
|
c48c22 |
-
|
|
|
c48c22 |
- if extensions:
|
|
|
c48c22 |
- http_request = {
|
|
|
c48c22 |
- 'shell_version': self.shell_proxy.get_cached_property("ShellVersion").unpack(),
|
|
|
c48c22 |
- 'installed': {}
|
|
|
c48c22 |
- }
|
|
|
c48c22 |
-
|
|
|
c48c22 |
- for uuid in extensions:
|
|
|
c48c22 |
- # gnome-shell/js/misc/extensionUtils.js
|
|
|
c48c22 |
- # EXTENSION_TYPE.PER_USER = 2
|
|
|
c48c22 |
- if is_uuid(uuid) and extensions[uuid]['type'] == 2 and (not enabled_only or uuid in enabled_extensions):
|
|
|
c48c22 |
- try:
|
|
|
c48c22 |
- http_request['installed'][uuid] = {
|
|
|
c48c22 |
- 'version': int(extensions[uuid]['version'])
|
|
|
c48c22 |
- }
|
|
|
c48c22 |
- except (ValueError, KeyError):
|
|
|
c48c22 |
- http_request['installed'][uuid] = {
|
|
|
c48c22 |
- 'version': 1
|
|
|
c48c22 |
- }
|
|
|
c48c22 |
-
|
|
|
c48c22 |
- http_request['installed'] = json.dumps(http_request['installed'])
|
|
|
c48c22 |
-
|
|
|
c48c22 |
- proxies = Gio.ProxyResolver.get_default().lookup(update_url)
|
|
|
c48c22 |
- if proxies is not None:
|
|
|
c48c22 |
- proxy = proxies[0]
|
|
|
c48c22 |
- if proxy.startswith('direct'):
|
|
|
c48c22 |
- proxies = None
|
|
|
c48c22 |
- else:
|
|
|
c48c22 |
- proxies = {}
|
|
|
c48c22 |
- for scheme in ('http', 'https'):
|
|
|
c48c22 |
- proxies[scheme] = proxy
|
|
|
c48c22 |
-
|
|
|
c48c22 |
- try:
|
|
|
c48c22 |
- response = requests.get(
|
|
|
c48c22 |
- update_url,
|
|
|
c48c22 |
- params=http_request,
|
|
|
c48c22 |
- proxies=proxies,
|
|
|
c48c22 |
- timeout=5
|
|
|
c48c22 |
- )
|
|
|
c48c22 |
- response.raise_for_status()
|
|
|
c48c22 |
- self.send_message({
|
|
|
c48c22 |
- 'success': True,
|
|
|
c48c22 |
- 'extensions': extensions,
|
|
|
c48c22 |
- 'upgrade': response.json()}
|
|
|
c48c22 |
- )
|
|
|
c48c22 |
- except (
|
|
|
c48c22 |
- requests.ConnectionError, requests.HTTPError, requests.Timeout,
|
|
|
c48c22 |
- requests.TooManyRedirects, requests.RequestException, ValueError
|
|
|
c48c22 |
- ) as ex:
|
|
|
c48c22 |
- error_message = str(ex.message) if hasattr(ex, 'message') else str(ex)
|
|
|
c48c22 |
- log_error('Unable to check extensions updates: %s' % error_message)
|
|
|
c48c22 |
-
|
|
|
c48c22 |
- request_url = ex.response.url if ex.response is not None else ex.request.url
|
|
|
c48c22 |
- if request_url:
|
|
|
c48c22 |
- url_parameters = request_url.replace(update_url, "")
|
|
|
c48c22 |
- error_message = error_message.replace(url_parameters, "…")
|
|
|
c48c22 |
-
|
|
|
c48c22 |
- self.send_message({'success': False, 'message': error_message})
|
|
|
c48c22 |
-
|
|
|
c48c22 |
|
|
|
c48c22 |
if __name__ == '__main__':
|
|
|
c48c22 |
debug('Main. Use Ctrl+D to quit.')
|
|
|
c48c22 |
--
|
|
|
c48c22 |
2.29.2
|
|
|
c48c22 |
|