From 29024cfdd5f131c7e3085cbddf9bd1cf60359960 Mon Sep 17 00:00:00 2001 From: "Kaleb S. KEITHLEY" Date: Wed, 28 Mar 2018 10:14:39 -0400 Subject: core/build/various: python3 compat, prepare for python2 -> python3 Note 1) we're not supposed to be using #!/usr/bin/env python, see https://fedoraproject.org/wiki/Packaging:Guidelines?rd=Packaging/Guidelines#Shebang_lines Note 2) we're also not supposed to be using "!/usr/bin/python, see https://fedoraproject.org/wiki/Changes/Avoid_usr_bin_python_in_RPM_Build#Quick_Opt-Out The previous patch (https://review.gluster.org/19767) tried to do too much in one patch, so it was abandoned. This patch does two things: 1) minor cleanup of configure(.ac) to explicitly use python2 2) change all the shebang lines to #!/usr/bin/python2 and add them where they were missing based on warnings emitted during rpmbuild. In a follow-up patch python2 will eventually be changed to python3. Before that python2-isms (e.g. print, string.join(), etc.) need to be converted to python3. Some of those can be rewritten in version agnostic python. E.g. print statements become print() with "from __future_ import print_function". The python 2to3 utility will be used for some of those. Also Aravinda has given guidance in the comments to the first patch for changes. updates: #411 Change-Id: I471730962b2526022115a1fc33629fb078b74338 Signed-off-by: Kaleb S. KEITHLEY --- extras/cliutils/README.md | 4 ++-- extras/create_new_xlator/generate_xlator.py | 2 +- extras/distributed-testing/distributed-test-runner.py | 2 +- extras/failed-tests.py | 2 +- extras/geo-rep/schedule_georep.py.in | 2 +- extras/git-branch-diff.py | 2 +- extras/hook-scripts/S40ufo-stop.py | 2 +- extras/profiler/glusterfs-profiler | 2 +- extras/prot_filter.py | 2 +- extras/quota/xattr_analysis.py | 4 ++-- extras/rebalance.py | 2 +- extras/snap_scheduler/conf.py.in | 1 + extras/snap_scheduler/gcron.py | 2 +- extras/snap_scheduler/snap_scheduler.py | 2 +- 14 files changed, 16 insertions(+), 15 deletions(-) (limited to 'extras') diff --git a/extras/cliutils/README.md b/extras/cliutils/README.md index ccb60802c3d..2e0ffe772c7 100644 --- a/extras/cliutils/README.md +++ b/extras/cliutils/README.md @@ -81,7 +81,7 @@ to address the following issues Create a file in `$LIBEXEC/glusterfs/peer_message.py` with following content. - #!/usr/bin/env python + #!/usr/bin/python2 from gluster.cliutils import Cmd, runcli, execute_in_peers, node_output_ok class NodeHello(Cmd): @@ -149,7 +149,7 @@ Now users can use `gluster-message` instead of calling Following example uses prettytable library, which can be installed using `pip install prettytable` or `dnf install python-prettytable` - #!/usr/bin/env python + #!/usr/bin/python2 from prettytable import PrettyTable from gluster.cliutils import Cmd, runcli, execute_in_peers, node_output_ok diff --git a/extras/create_new_xlator/generate_xlator.py b/extras/create_new_xlator/generate_xlator.py index 2dbf470eafb..c51c3a41a22 100755 --- a/extras/create_new_xlator/generate_xlator.py +++ b/extras/create_new_xlator/generate_xlator.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python2 import os import re import sys diff --git a/extras/distributed-testing/distributed-test-runner.py b/extras/distributed-testing/distributed-test-runner.py index 9a74b7ab5c5..68418fabfaf 100755 --- a/extras/distributed-testing/distributed-test-runner.py +++ b/extras/distributed-testing/distributed-test-runner.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/python2 from __future__ import absolute_import from __future__ import division diff --git a/extras/failed-tests.py b/extras/failed-tests.py index 476e24331e5..8391d229b45 100755 --- a/extras/failed-tests.py +++ b/extras/failed-tests.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python2 import blessings import requests diff --git a/extras/geo-rep/schedule_georep.py.in b/extras/geo-rep/schedule_georep.py.in index 1887fe7ba87..6462d8fdba7 100644 --- a/extras/geo-rep/schedule_georep.py.in +++ b/extras/geo-rep/schedule_georep.py.in @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/python2 """ Schedule Geo-replication ------------------------ diff --git a/extras/git-branch-diff.py b/extras/git-branch-diff.py index c8d74ec9f31..c9e9dd0da06 100755 --- a/extras/git-branch-diff.py +++ b/extras/git-branch-diff.py @@ -1,4 +1,4 @@ -#!/bin/env python +#!/bin/python2 """ Copyright (c) 2016 Red Hat, Inc. diff --git a/extras/hook-scripts/S40ufo-stop.py b/extras/hook-scripts/S40ufo-stop.py index 107f1968355..48ee1c788b6 100755 --- a/extras/hook-scripts/S40ufo-stop.py +++ b/extras/hook-scripts/S40ufo-stop.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/python2 import os from optparse import OptionParser diff --git a/extras/profiler/glusterfs-profiler b/extras/profiler/glusterfs-profiler index 65d445864aa..9c76d5b379c 100755 --- a/extras/profiler/glusterfs-profiler +++ b/extras/profiler/glusterfs-profiler @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/python2 # Copyright (c) 2006-2012 Red Hat, Inc. # This file is part of GlusterFS. diff --git a/extras/prot_filter.py b/extras/prot_filter.py index 7dccacf155e..290792697a2 100755 --- a/extras/prot_filter.py +++ b/extras/prot_filter.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python2 """ Copyright (c) 2013 Red Hat, Inc. diff --git a/extras/quota/xattr_analysis.py b/extras/quota/xattr_analysis.py index d3d1a74170b..512fcd39b88 100755 --- a/extras/quota/xattr_analysis.py +++ b/extras/quota/xattr_analysis.py @@ -1,5 +1,5 @@ -#!/usr/bin/python -# Below script has to purpose +#!/usr/bin/python2 +# Below script has two purposes # 1. Display xattr of entire FS tree in a human readable form # 2. Display all the directory where contri and size mismatch. # (If there are any directory with contri and size mismatch that are not dirty diff --git a/extras/rebalance.py b/extras/rebalance.py index 9579e5616ad..b2ec6a52290 100755 --- a/extras/rebalance.py +++ b/extras/rebalance.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python2 import atexit import copy diff --git a/extras/snap_scheduler/conf.py.in b/extras/snap_scheduler/conf.py.in index 6dcca0534a7..e04b6cb008b 100644 --- a/extras/snap_scheduler/conf.py.in +++ b/extras/snap_scheduler/conf.py.in @@ -1,3 +1,4 @@ +#!/usr/bin/python2 # # Copyright (c) 2016 Red Hat, Inc. # This file is part of GlusterFS. diff --git a/extras/snap_scheduler/gcron.py b/extras/snap_scheduler/gcron.py index d72057861ff..3f2ba388ccc 100755 --- a/extras/snap_scheduler/gcron.py +++ b/extras/snap_scheduler/gcron.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/python2 # # Copyright (c) 2015 Red Hat, Inc. # This file is part of GlusterFS. diff --git a/extras/snap_scheduler/snap_scheduler.py b/extras/snap_scheduler/snap_scheduler.py index c6600a4a3d7..a22c0bccbf3 100755 --- a/extras/snap_scheduler/snap_scheduler.py +++ b/extras/snap_scheduler/snap_scheduler.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/python2 # # Copyright (c) 2015 Red Hat, Inc. # This file is part of GlusterFS. -- cgit