You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

266 lines
10 KiB

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