/usr/lib/python2.7/dist-packages/gtweak/egowrapper.py is in gnome-tweak-tool 3.22.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | # This file is part of gnome-tweak-tool.
#
# Copyright (c) 2011 John Stowers
#
# gnome-tweak-tool is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# gnome-tweak-tool is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with gnome-tweak-tool. If not, see <http://www.gnu.org/licenses/>.
import json
import logging
import gi
gi.require_version("Soup", "2.4")
from gi.repository import GObject
from gi.repository import Soup
class ExtensionsDotGnomeDotOrg(GObject.GObject):
__gsignals__ = {
"got-extensions": (GObject.SignalFlags.RUN_FIRST, GObject.TYPE_NONE,
(GObject.TYPE_PYOBJECT,)),
"got-extension-info": (GObject.SignalFlags.RUN_FIRST, GObject.TYPE_NONE,
(GObject.TYPE_PYOBJECT,GObject.TYPE_STRING)),
}
def __init__(self, shell_version_tuple):
GObject.GObject.__init__(self)
self._session = Soup.Session.new()
self._shell_version_tuple = shell_version_tuple
self._extensions = {}
def _query_extensions_finished(self, msg, url):
if msg.status_code == 200:
#server returns a list of extensions which may contain duplicates, dont know
resp = json.loads(msg.response_body.data)
print resp
for e in resp["extensions"]:
self._extensions[e["uuid"]] = e
self.emit("got-extensions", self._extensions)
def _query_extension_info_finished(self, msg, uuid):
if msg.status_code == 200:
self.emit("got-extension-info", json.loads(msg.response_body.data), uuid)
def query_extensions(self):
url = "https://extensions.gnome.org/extension-query/?"
ver = self._shell_version_tuple
if ver[1] % 2:
#if this is a development version (odd) then query the full version
url += "shell_version=%d.%d.%d&" % ver
else:
#else query in point releases up to the current version, and filter duplicates
#from the reply
url += "shell_version=%d.%d&" % (ver[0],ver[1])
for i in range(1,ver[2]+1):
url += "shell_version=%d.%d.%d&" % (ver[0],ver[1], i)
#non-paginated
url += "n_per_page=-1"
logging.debug("Query URL: %s" % url)
message = Soup.Message.new('GET', url)
message.connect("finished", self._query_extensions_finished, url)
self._session.queue_message(message, None, None)
def query_extension_info(self, extension_uuid):
if extension_uuid in self._extensions:
print "CACHED"
self.emit("got-extension-info", self._extensions[extension_uuid])
return
url = "https://extensions.gnome.org/extension-info/?uuid=%s" % extension_uuid
logging.debug("Query URL: %s" % url)
message = Soup.Message.new('GET', url)
message.connect("finished", self._query_extension_info_finished, extension_uuid)
self._session.queue_message(message, None, None)
def get_download_url(self, extinfo):
url = "https://extensions.gnome.org/download-extension/%s.shell-extension.zip?version_tag=%d"
#version tag is the pk in the shell_version_map
#url = url % (extinfo["uuid"],
if __name__ == "__main__":
import pprint
from gi.repository import Gtk, GLib
def _got_ext(ego, extensions):
print "="*80
pprint.pprint(extensions.values())
def _got_ext_info(ego, extension):
pprint.pprint(extension)
logging.basicConfig(format="%(levelname)-8s: %(message)s", level=logging.DEBUG)
e = ExtensionsDotGnomeDotOrg((3,4,1))
e.connect("got-extensions", _got_ext)
e.connect("got-extension-info", _got_ext_info)
e.query_extensions()
#e.query_extensions((3,4,0))
#e.query_extensions((3,3,2))
e.query_extension_info("user-theme@gnome-shell-extensions.gcampax.github.com")
Gtk.main()
|