Blame SOURCES/gnome-shell-python3.patch

cd52c0
From 5e252bd9d9c64cae3ef153338dfdd7638c4cd9e5 Mon Sep 17 00:00:00 2001
cd52c0
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
cd52c0
Date: Thu, 14 Jun 2018 17:11:30 +0200
cd52c0
Subject: [PATCH] build: Revert Python3 port
cd52c0
cd52c0
This is mostly a revert of commit be3c3c64c1, with slight adjustments
cd52c0
due to the build system switch.
cd52c0
---
cd52c0
 meson.build                       |  2 +-
cd52c0
 src/gnome-shell-extension-tool.in | 40 +++++++++++++++---------------
cd52c0
 src/gnome-shell-perf-tool.in      | 41 ++++++++++++++++---------------
cd52c0
 3 files changed, 42 insertions(+), 41 deletions(-)
cd52c0
cd52c0
diff --git a/meson.build b/meson.build
cd52c0
index 978ed6506..663a4d06f 100644
cd52c0
--- a/meson.build
cd52c0
+++ b/meson.build
cd52c0
@@ -137,7 +137,7 @@ if get_option('man')
cd52c0
 endif
cd52c0
 
cd52c0
 mutter_typelibdir = mutter_dep.get_pkgconfig_variable('typelibdir')
cd52c0
-python = find_program('python3')
cd52c0
+python = find_program('python2')
cd52c0
 sassc = find_program('sassc')
cd52c0
 
cd52c0
 cc = meson.get_compiler('c')
cd52c0
diff --git a/src/gnome-shell-extension-tool.in b/src/gnome-shell-extension-tool.in
cd52c0
index f6c37629c..ab9c951ba 100755
cd52c0
--- a/src/gnome-shell-extension-tool.in
cd52c0
+++ b/src/gnome-shell-extension-tool.in
cd52c0
@@ -14,7 +14,7 @@ except ImportError:
cd52c0
     try:
cd52c0
         import simplejson as json
cd52c0
     except ImportError:
cd52c0
-        print('The Python simplejson module is required')
cd52c0
+        print 'The Python simplejson module is required'
cd52c0
         sys.exit(1)
cd52c0
 
cd52c0
 from gi.repository import Gio, GLib
cd52c0
@@ -88,36 +88,36 @@ function disable() {
cd52c0
 }
cd52c0
 
cd52c0
 def create_extension():
cd52c0
-    print()
cd52c0
-    print('''Name should be a very short (ideally descriptive) string.
cd52c0
+    print
cd52c0
+    print '''Name should be a very short (ideally descriptive) string.
cd52c0
 Examples are: "Click To Focus",  "Adblock", "Shell Window Shrinker".
cd52c0
-''')
cd52c0
-    name = input('Name: ').strip()
cd52c0
-    print()
cd52c0
-    print('''Description is a single-sentence explanation of what your extension does.
cd52c0
+'''
cd52c0
+    name = raw_input('Name: ').strip()
cd52c0
+    print
cd52c0
+    print '''Description is a single-sentence explanation of what your extension does.
cd52c0
 Examples are: "Make windows visible on click", "Block advertisement popups"
cd52c0
               "Animate windows shrinking on minimize"
cd52c0
-''')
cd52c0
-    description = input('Description: ').strip()
cd52c0
+'''
cd52c0
+    description = raw_input('Description: ').strip()
cd52c0
     underifier = re.compile('[^A-Za-z]')
cd52c0
     sample_uuid = underifier.sub('_', name)
cd52c0
     # TODO use evolution data server
cd52c0
     hostname = socket.gethostname()
cd52c0
     sample_uuid = sample_uuid + '@' + hostname
cd52c0
 
cd52c0
-    print()
cd52c0
-    print('''Uuid is a globally-unique identifier for your extension.
cd52c0
+    print
cd52c0
+    print '''Uuid is a globally-unique identifier for your extension.
cd52c0
 This should be in the format of an email address (foo.bar@extensions.example.com), but
cd52c0
 need not be an actual email address, though it's a good idea to base the uuid on your
cd52c0
 email address.  For example, if your email address is janedoe@example.com, you might
cd52c0
-use an extension title clicktofocus@janedoe.example.com.''')
cd52c0
-    uuid = input('Uuid [%s]: ' % (sample_uuid, )).strip()
cd52c0
+use an extension title clicktofocus@janedoe.example.com.'''
cd52c0
+    uuid = raw_input('Uuid [%s]: ' % (sample_uuid, )).strip()
cd52c0
     if uuid == '':
cd52c0
         uuid = sample_uuid
cd52c0
 
cd52c0
     extension_path = os.path.join(os.path.expanduser('~/.local'), 'share', 'gnome-shell', 'extensions', uuid)
cd52c0
     if os.path.exists(extension_path):
cd52c0
-        print("Extension path %r already exists" % (extension_path, ))
cd52c0
+        print "Extension path %r already exists" % (extension_path, )
cd52c0
         sys.exit(0)
cd52c0
     os.makedirs(extension_path)
cd52c0
     meta = { 'name': name,
cd52c0
@@ -132,13 +132,13 @@ use an extension title clicktofocus@janedoe.example.com.''')
cd52c0
         f.write(json.write(meta) + '\n')
cd52c0
     f.close()
cd52c0
 
cd52c0
-    for filename, contents in SAMPLE_EXTENSION_FILES.items():
cd52c0
+    for filename, contents in SAMPLE_EXTENSION_FILES.iteritems():
cd52c0
         path = os.path.join(extension_path, filename)
cd52c0
         f = open(path, 'w')
cd52c0
         f.write(contents)
cd52c0
         f.close()
cd52c0
 
cd52c0
-    print("Created extension in %r" % (extension_path, ))
cd52c0
+    print "Created extension in %r" % (extension_path, )
cd52c0
     extensionjs_path = os.path.join(extension_path, 'extension.js')
cd52c0
     subprocess.Popen(['xdg-open', extensionjs_path])
cd52c0
 
cd52c0
@@ -149,19 +149,19 @@ def enable_extension(uuid):
cd52c0
     extensions = settings.get_strv(ENABLED_EXTENSIONS_KEY)
cd52c0
 
cd52c0
     if uuid in extensions:
cd52c0
-        print("%r is already enabled." % (uuid,), file=sys.stderr)
cd52c0
+        print >> sys.stderr, "%r is already enabled." % (uuid,)
cd52c0
         sys.exit(1)
cd52c0
 
cd52c0
     extensions.append(uuid)
cd52c0
     settings.set_strv(ENABLED_EXTENSIONS_KEY, extensions)
cd52c0
-    print("%r is now enabled." % (uuid,), file=sys.stderr)
cd52c0
+    print >> sys.stderr, "%r is now enabled." % (uuid,)
cd52c0
 
cd52c0
 def disable_extension(uuid):
cd52c0
     settings = Gio.Settings(schema='org.gnome.shell')
cd52c0
     extensions = settings.get_strv(ENABLED_EXTENSIONS_KEY)
cd52c0
 
cd52c0
     if uuid not in extensions:
cd52c0
-        print("%r is not enabled or installed." % (uuid,), file=sys.stderr)
cd52c0
+        print >> sys.stderr, "%r is not enabled or installed." % (uuid,)
cd52c0
         sys.exit(1)
cd52c0
 
cd52c0
     # Use a while loop here to remove *all* mentions instances
cd52c0
@@ -170,7 +170,7 @@ def disable_extension(uuid):
cd52c0
         extensions.remove(uuid)
cd52c0
 
cd52c0
     settings.set_strv(ENABLED_EXTENSIONS_KEY, extensions)
cd52c0
-    print("%r is now disabled." % (uuid,), file=sys.stderr)
cd52c0
+    print >> sys.stderr, "%r is now disabled." % (uuid,)
cd52c0
 
cd52c0
 def reload_extension(uuid):
cd52c0
     settings = Gio.Settings(schema='org.gnome.shell')
cd52c0
diff --git a/src/gnome-shell-perf-tool.in b/src/gnome-shell-perf-tool.in
cd52c0
index b2a4521a3..55bfdf39f 100755
cd52c0
--- a/src/gnome-shell-perf-tool.in
cd52c0
+++ b/src/gnome-shell-perf-tool.in
cd52c0
@@ -14,14 +14,15 @@ import subprocess
cd52c0
 import sys
cd52c0
 import tempfile
cd52c0
 import base64
cd52c0
-from configparser import RawConfigParser
cd52c0
+from ConfigParser import RawConfigParser
cd52c0
 import hashlib
cd52c0
 import hmac
cd52c0
-from http import client
cd52c0
-from urllib import parse
cd52c0
+import httplib
cd52c0
+import urlparse
cd52c0
+import urllib
cd52c0
 
cd52c0
 def show_version(option, opt_str, value, parser):
cd52c0
-    print("GNOME Shell Performance Test @VERSION@")
cd52c0
+    print "GNOME Shell Performance Test @VERSION@"
cd52c0
     sys.exit()
cd52c0
 
cd52c0
 def wait_for_dbus_name(wait_name):
cd52c0
@@ -40,7 +41,7 @@ def wait_for_dbus_name(wait_name):
cd52c0
                                   None)
cd52c0
 
cd52c0
     def on_timeout():
cd52c0
-        print("\nFailed to start %s: timed out" % (wait_name,))
cd52c0
+        print "\nFailed to start %s: timed out" % (wait_name,)
cd52c0
         sys.exit(1)
cd52c0
     GLib.timeout_add_seconds(7, on_timeout)
cd52c0
 
cd52c0
@@ -130,15 +131,15 @@ def upload_performance_report(report_text):
cd52c0
         base_url = config.get('upload', 'url')
cd52c0
         system_name = config.get('upload', 'name')
cd52c0
         secret_key = config.get('upload', 'key')
cd52c0
-    except Exception as e:
cd52c0
-        print("Can't read upload configuration from %s: %s" % (config_file, str(e)))
cd52c0
+    except Exception, e:
cd52c0
+        print "Can't read upload configuration from %s: %s" % (config_file, str(e))
cd52c0
         sys.exit(1)
cd52c0
 
cd52c0
     # Determine host, port and upload URL from provided data, we're
cd52c0
     # a bit extra-careful about normalization since the URL is part
cd52c0
     # of the signature.
cd52c0
 
cd52c0
-    split = parse.urlsplit(base_url)
cd52c0
+    split = urlparse.urlsplit(base_url)
cd52c0
     scheme = split[0].lower()
cd52c0
     netloc = split[1]
cd52c0
     base_path = split[2]
cd52c0
@@ -150,7 +151,7 @@ def upload_performance_report(report_text):
cd52c0
         host, port = m.group(1), None
cd52c0
 
cd52c0
     if scheme != "http":
cd52c0
-        print("'%s' is not a HTTP URL" % base_url)
cd52c0
+        print "'%s' is not a HTTP URL" % base_url
cd52c0
         sys.exit(1)
cd52c0
 
cd52c0
     if port is None:
cd52c0
@@ -165,7 +166,7 @@ def upload_performance_report(report_text):
cd52c0
         normalized_base = "%s://%s:%d%s" % (scheme, host, port, base_path)
cd52c0
 
cd52c0
     upload_url = normalized_base + '/system/%s/upload' % system_name
cd52c0
-    upload_path = parse.urlsplit(upload_url)[2] # path portion
cd52c0
+    upload_path = urlparse.urlsplit(upload_url)[2] # path portion
cd52c0
 
cd52c0
     # Create signature based on upload URL and the report data
cd52c0
 
cd52c0
@@ -173,7 +174,7 @@ def upload_performance_report(report_text):
cd52c0
     h = hmac.new(secret_key, digestmod=hashlib.sha1)
cd52c0
     h.update(signature_data)
cd52c0
     h.update(report_text)
cd52c0
-    signature = parse.quote(base64.b64encode(h.digest()), "~")
cd52c0
+    signature = urllib.quote(base64.b64encode(h.digest()), "~")
cd52c0
 
cd52c0
     headers = {
cd52c0
         'User-Agent': 'gnome-shell-performance-tool/@VERSION@',
cd52c0
@@ -181,15 +182,15 @@ def upload_performance_report(report_text):
cd52c0
         'X-Shell-Signature': 'HMAC-SHA1 ' + signature
cd52c0
     };
cd52c0
 
cd52c0
-    connection = client.HTTPConnection(host, port)
cd52c0
+    connection = httplib.HTTPConnection(host, port)
cd52c0
     connection.request('POST', upload_path, report_text, headers)
cd52c0
     response = connection.getresponse()
cd52c0
 
cd52c0
     if response.status == 200:
cd52c0
-        print("Performance report upload succeeded")
cd52c0
+        print "Performance report upload succeeded"
cd52c0
     else:
cd52c0
-        print("Performance report upload failed with status %d" % response.status)
cd52c0
-        print(response.read())
cd52c0
+        print "Performance report upload failed with status %d" % response.status
cd52c0
+        print response.read()
cd52c0
 
cd52c0
 def gnome_hwtest_log(*args):
cd52c0
     command = ['gnome-hwtest-log', '-t', 'gnome-shell-perf-tool']
cd52c0
@@ -206,7 +207,7 @@ def run_performance_test():
cd52c0
 
cd52c0
     start_perf_helper()
cd52c0
 
cd52c0
-    for i in range(0, iters):
cd52c0
+    for i in xrange(0, iters):
cd52c0
         # We create an empty temporary file that the shell will overwrite
cd52c0
         # with the contents.
cd52c0
         handle, output_file = tempfile.mkstemp(".json", "gnome-shell-perf.")
cd52c0
@@ -305,12 +306,12 @@ def run_performance_test():
cd52c0
         gnome_hwtest_log('--finished')
cd52c0
     else:
cd52c0
         # Write a human readable summary
cd52c0
-        print('------------------------------------------------------------')
cd52c0
+        print '------------------------------------------------------------';
cd52c0
         for metric in sorted(metric_summaries.keys()):
cd52c0
             summary = metric_summaries[metric]
cd52c0
-            print("#", summary['description'])
cd52c0
-            print(metric, ", ".join((str(x) for x in summary['values'])))
cd52c0
-        print('------------------------------------------------------------')
cd52c0
+            print "#", summary['description']
cd52c0
+            print metric, ", ".join((str(x) for x in summary['values']))
cd52c0
+        print '------------------------------------------------------------';
cd52c0
 
cd52c0
     return True
cd52c0
 
cd52c0
-- 
cd52c0
2.17.1
cd52c0