From 43d1bcf978a652b5a1970500ee07c7aae45d2ab5 Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Fri, 13 Sep 2019 12:49:37 +0200 Subject: [PATCH 1/2] Implement katello-ssl-tool via console_scripts --- .travis/test.sh | 2 +- katello-ssl-tool | 60 ------------------------- katello_certs_tools/katello_ssl_tool.py | 12 +++-- setup.py | 9 +++- 4 files changed, 17 insertions(+), 66 deletions(-) delete mode 100644 katello-ssl-tool diff --git a/.travis/test.sh b/.travis/test.sh index 51a7a9f..8adeea7 100755 --- a/.travis/test.sh +++ b/.travis/test.sh @@ -7,7 +7,7 @@ export LC_ALL=en_US.UTF-8 TEST_ON_EL=$([ -f /etc/redhat-release ] && [ -x /usr/bin/yum ] && echo "true" || echo "false") if [[ "${TEST_ON_EL}" == "true" ]]; then - yum install -y docbook-utils openssl rpm-build + yum install -y docbook-utils openssl rpm-build python-setuptools fi docbook2man katello-ssl-tool.sgml diff --git a/katello-ssl-tool b/katello-ssl-tool deleted file mode 100644 index 31bbabe..0000000 --- a/katello-ssl-tool +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/python -# -# Copyright 2013 Red Hat, Inc. -# -# This software is licensed to you under the GNU General Public License, -# version 2 (GPLv2). There is NO WARRANTY for this software, express or -# implied, including the implied warranties of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 -# along with this software; if not, see -# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. -# -# Red Hat trademarks are not licensed under GPLv2. No permission is -# granted to use or replicate Red Hat trademarks that are incorporated -# in this software or its documentation. -# -# -# Katello SSL Maintenance Tool -# -# Generate and maintain SSL keys & certs. One can also build RPMs in the Katello -# product context. -# -# NOTE: this tool is geared for Katello product usage, but can be used outside of -# that context to some degree. -# -# Author: Todd Warner -# -# $Id$ - - -## language imports -import sys -import os - - -mod_name = os.path.basename(sys.argv[0]).replace('-', '_') -try: - mod = __import__("katello_certs_tools." + mod_name) -except KeyboardInterrupt: - sys.stderr.write("\nUser interrupted process.\n") - sys.exit(0) -except ImportError as e: - sys.stderr.write("Unable to load module %s\n" % mod_name) - sys.stderr.write(str(e) + "\n") - sys.exit(1) -mod = getattr(mod, mod_name) - - -#------------------------------------------------------------------------------- -if __name__ == '__main__': - try: - sys.exit(mod.main() or 0) - except KeyboardInterrupt: - sys.stderr.write("\nUser interrupted process.\n") - sys.exit(0) - except SystemExit: - raise - except: - sys.stderr.write("\nERROR: unhandled exception occurred:\n") - raise -#=============================================================================== diff --git a/katello_certs_tools/katello_ssl_tool.py b/katello_certs_tools/katello_ssl_tool.py index 0807ec6..9fb87ed 100644 --- a/katello_certs_tools/katello_ssl_tool.py +++ b/katello_certs_tools/katello_ssl_tool.py @@ -993,9 +993,9 @@ def main(): def writeError(e): sys.stderr.write('\nERROR: %s\n' % e) - ret = 0 try: - ret = _main() or 0 + _main() + ret = 0 # CA key set errors except GenPrivateCaKeyException as e: writeError(e) @@ -1041,5 +1041,11 @@ def writeError(e): except KatelloSslToolException as e: writeError(e) ret = 100 + except KeyboardInterrupt: + sys.stderr.write("\nUser interrupted process.\n") + ret = 0 + except: # noqa + sys.stderr.write("\nERROR: unhandled exception occurred:\n") + raise - return ret + sys.exit(ret) diff --git a/setup.py b/setup.py index 52c007d..11cf549 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,4 @@ -from distutils.core import setup +from setuptools import setup setup(name='Katello Certs Tools', version='2.6.1', @@ -7,5 +7,10 @@ author_email='tlestach@redhat.com', url='https://github.com/Katello/katello-certs-tools', packages=['katello_certs_tools'], - scripts=['katello-ssl-tool', 'katello-sudo-ssl-tool', 'katello-certs-sign', 'katello-certs-gen-rpm'], + scripts=['katello-sudo-ssl-tool', 'katello-certs-sign', 'katello-certs-gen-rpm'], + entry_points={ + 'console_scripts': [ + 'katello-ssl-tool = katello_certs_tools.katello_ssl_tool:main', + ], + }, data_files=[('share/man/man1', ['katello-ssl-tool.1'])]) From d697ce61d45adcfb0405e13284e96c5ca9b71c6d Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Sun, 24 May 2020 14:39:23 +0200 Subject: [PATCH 2/2] Drop katello-sudo-ssl-tool wrapper --- katello-sudo-ssl-tool | 3 --- setup.py | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) delete mode 100644 katello-sudo-ssl-tool diff --git a/katello-sudo-ssl-tool b/katello-sudo-ssl-tool deleted file mode 100644 index d2398eb..0000000 --- a/katello-sudo-ssl-tool +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -/usr/bin/sudo /usr/bin/katello-ssl-tool "$@" diff --git a/setup.py b/setup.py index 11cf549..a996c06 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ author_email='tlestach@redhat.com', url='https://github.com/Katello/katello-certs-tools', packages=['katello_certs_tools'], - scripts=['katello-sudo-ssl-tool', 'katello-certs-sign', 'katello-certs-gen-rpm'], + scripts=['katello-certs-sign', 'katello-certs-gen-rpm'], entry_points={ 'console_scripts': [ 'katello-ssl-tool = katello_certs_tools.katello_ssl_tool:main',