From c5f8001c6f8aad82a6c54311d39111cfa64cd2b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= Date: Mon, 20 Mar 2017 17:11:32 +0100 Subject: [PATCH 1/3] cli: skip superfluous text -> bytes conversion on clufter's output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Respective outputs are already represented with bytes (as 'bytestring' protocol suggests), and moreover, such bytes cannot be "encoded" in Python 3 otherwise leading to AttributeError (bytes object has no attribute encode) exception. Note that this is only relevant in Python 3 context, which pcs uses by default in python3-charged distros (e.g. Fedora) and which is now supported in clufter (which enabled a discovery of this discrepancy): http://oss.clusterlabs.org/pipermail/users/2017-March/005323.html Signed-off-by: Jan Pokorný --- pcs/config.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pcs/config.py b/pcs/config.py index d7c30a21..8b5bb166 100644 --- a/pcs/config.py +++ b/pcs/config.py @@ -698,14 +698,14 @@ def config_import_cman(argv): config_backup_add_version_to_tarball(tarball) utils.tar_add_file_data( tarball, - clufter_args_obj.cib["passout"].encode("utf-8"), + clufter_args_obj.cib["passout"], "cib.xml", **file_list["cib.xml"]["attrs"] ) if output_format == "cluster.conf": utils.tar_add_file_data( tarball, - clufter_args_obj.ccs_pcmk["passout"].encode("utf-8"), + clufter_args_obj.ccs_pcmk["passout"], "cluster.conf", **file_list["cluster.conf"]["attrs"] ) @@ -726,7 +726,7 @@ def config_import_cman(argv): )("bytestring") utils.tar_add_file_data( tarball, - corosync_conf_data.encode("utf-8"), + corosync_conf_data, "corosync.conf", **file_list["corosync.conf"]["attrs"] ) @@ -744,7 +744,7 @@ def config_import_cman(argv): )("bytestring") utils.tar_add_file_data( tarball, - uidgid_data.encode("utf-8"), + uidgid_data, "uidgid.d/" + filename, **file_list["uidgid.d"]["attrs"] ) -- 2.11.0 From 647fc814f482f14c70fb569fd4fd3b494e57d7c9 Mon Sep 17 00:00:00 2001 From: Tomas Jelinek Date: Wed, 22 Mar 2017 18:41:33 +0100 Subject: [PATCH 2/3] fix writing clufter output to file with Python 3 --- pcs/config.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pcs/config.py b/pcs/config.py index 8b5bb166..b42c5983 100644 --- a/pcs/config.py +++ b/pcs/config.py @@ -676,7 +676,7 @@ def config_import_cman(argv): if output_format in ("pcs-commands", "pcs-commands-verbose"): ok, message = utils.write_file( dry_run_output, - clufter_args_obj.output["passout"] + clufter_args_obj.output["passout"].decode() ) if not ok: utils.err(message) @@ -845,7 +845,7 @@ def config_export_pcs_commands(argv, verbose=False): if output_file: ok, message = utils.write_file( output_file, - clufter_args_obj.output["passout"] + clufter_args_obj.output["passout"].decode() ) if not ok: utils.err(message) -- 2.11.0 From c5d73581c8bacfe992f863b49e5902fc33198503 Mon Sep 17 00:00:00 2001 From: Tomas Jelinek Date: Wed, 22 Mar 2017 18:03:09 +0100 Subject: [PATCH 3/3] do not colorize clufter output if saved to a file Clufter improved detecting if the color mode should be enabled so we can left the decision to clufter completely. --- pcs/config.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pcs/config.py b/pcs/config.py index b42c5983..04ef02f1 100644 --- a/pcs/config.py +++ b/pcs/config.py @@ -627,8 +627,6 @@ def config_import_cman(argv): "batch": True, "sys": "linux", "dist": dist, - # Make it work on RHEL6 as well for sure - "color": "always" if sys.stdout.isatty() else "never" } if interactive: if "EDITOR" not in os.environ: @@ -802,8 +800,6 @@ def config_export_pcs_commands(argv, verbose=False): "batch": True, "sys": "linux", "dist": dist, - # Make it work on RHEL6 as well for sure - "color": "always" if sys.stdout.isatty() else "never", "coro": settings.corosync_conf_file, "ccs": settings.cluster_conf_file, "start_wait": "60", -- 2.11.0