[packages/mysql-utilities] fixes for mysqluc not to invoke every /usr/bin/*.py with --help

glen glen at pld-linux.org
Fri Oct 5 00:19:55 CEST 2012


commit 520bb0518a5b599a2cc03cd1970328022fa65f9f
Author: Elan Ruusamäe <glen at delfi.ee>
Date:   Fri Oct 5 01:18:46 2012 +0300

    fixes for mysqluc not to invoke every /usr/bin/*.py with --help

 mysql-utilities.spec |  6 ++++++
 paths.patch          | 42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+)
---
diff --git a/mysql-utilities.spec b/mysql-utilities.spec
index b3876b8..88e2cdc 100644
--- a/mysql-utilities.spec
+++ b/mysql-utilities.spec
@@ -14,6 +14,7 @@ BuildRequires:	python-Sphinx >= 1.0
 BuildRequires:	python-devel >= 1:2.4
 BuildRequires:	rpm-pythonprov
 BuildRequires:	rpmbuild(macros) >= 1.566
+BuildRequires:	sed >= 4.0
 Requires:	python-mysql-connector
 BuildArch:	noarch
 BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
@@ -29,6 +30,11 @@ mv mysql-workbench-gpl-*-src/ext/%{name}/* .
 %patch0 -p1
 %patch1 -p1
 
+# build static list of mysql utilities
+# because otherwise it will try to run python --help for every *.py it finds from /usr/bin!
+for py in scripts/*.py; do basename $py .py; done > scripts.manifest
+%{__sed} -i -e "s/'HERE BE DRAGONS'/'$(xargs < scripts.manifest)'/" mysql/utilities/common/utilities.py
+
 %build
 v=$(head -n1 CHANGES.txt | awk '{print $2}')
 test "$v" = "%{version}"
diff --git a/paths.patch b/paths.patch
index 2e7cc49..bae01c9 100644
--- a/paths.patch
+++ b/paths.patch
@@ -20,3 +20,45 @@
      
      # Try the default by itself
      if os.path.isfile(os.path.join(default_path, needle)):
+--- mysql-utilities-1.1.0/./mysql/utilities/command/utilitiesconsole.py~	2012-09-26 23:50:42.000000000 +0300
++++ mysql-utilities-1.1.0/./mysql/utilities/command/utilitiesconsole.py	2012-10-05 00:48:39.151811044 +0300
+@@ -263,8 +263,8 @@
+         """
+         import subprocess
+         
+-        if not os.path.splitext(command.lower()) == '.py':
+-            command += '.py'
++#        if not os.path.splitext(command.lower()) == '.py':
++#            command += '.py'
+         if not command.lower().startswith('mysql'):
+             command = 'mysql' + command
+         cmd = 'python ' + os.path.join(self.utils.util_path, command)
+--- mysql-utilities-1.1.0/./mysql/utilities/common/utilities.py	2012-10-05 00:53:12.070889308 +0300
++++ mysql-utilities-1.1.0/./mysql/utilities/common/utilities.py	2012-10-05 00:53:12.070889308 +0300
+@@ -95,13 +95,14 @@
+         
+         This method builds a list of utilities.
+         """
+-        files = os.listdir(self.util_path)
++        files = 'HERE BE DRAGONS'.split(' ')
+         for file in files:
++            # XXX mysql devs: RTFM: splitext always returns len(parts) == 2
+             parts = os.path.splitext(file)
+             # Only accept python files - not .pyc and others
+-            if (len(parts) == 2 and parts[1] == '.py' and \
++            if (parts[1] == '.py' and \
+                 parts[0] not in _EXCLUDE_UTILS) or \
+-               (len(parts) ==1 and parts[0] not in _EXCLUDE_UTILS):
++               (parts[1] == '' and parts[0] not in _EXCLUDE_UTILS):
+                 util_name = parts[0]
+                 util_info = self._get_util_info(self.util_path, util_name)
+                 self.util_list.append(util_info)
+@@ -136,7 +137,7 @@
+ 
+         # Get the --help output for the utility
+         util_cmd = "python " + os.path.join(util_path,
+-                                            util_name+'.py') + " --help"
++                                            util_name) + " --help"
+         file = tempfile.TemporaryFile()
+         proc = subprocess.Popen(util_cmd, shell=True,
+                                 stdout=file, stderr=file)
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/mysql-utilities.git/commitdiff/520bb0518a5b599a2cc03cd1970328022fa65f9f



More information about the pld-cvs-commit mailing list