Blame SOURCES/gnome-shell-python3.patch

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