Module: check_mk
Branch: master
Commit: aee3121dfd0ba5bb01158eee9dc22a986f31df24
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=aee3121dfd0ba5…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Aug 28 08:12:42 2017 +0200
mkbackup: Fixed encoding when outputting not to tty
Change-Id: Ief5c498205dd910ff32aa220364d18ff9d6592d3
---
bin/mkbackup | 35 ++++++++++++++++++-----------------
1 file changed, 18 insertions(+), 17 deletions(-)
diff --git a/bin/mkbackup b/bin/mkbackup
index 96010a4..9513594 100755
--- a/bin/mkbackup
+++ b/bin/mkbackup
@@ -1832,7 +1832,7 @@ def mode_jobs(opts):
sys.stdout.write(fmt % ("Job-ID", "Title"))
sys.stdout.write("%s\n" % ("-" * 60))
for job_id, job_cfg in sorted(g_config["jobs"].items(), key=lambda (x, y):
x):
- sys.stdout.write(fmt % (job_id, job_cfg["title"]))
+ sys.stdout.write(fmt % (job_id,
job_cfg["title"].encode("utf-8")))
def mode_targets(opts):
@@ -1840,7 +1840,7 @@ def mode_targets(opts):
sys.stdout.write(fmt % ("Target-ID", "Title"))
sys.stdout.write("%s\n" % ("-" * 60))
for job_id, job_cfg in sorted(g_config["targets"].items(), key=lambda (x,
y): x):
- sys.stdout.write(fmt % (job_id, job_cfg["title"]))
+ sys.stdout.write(fmt % (job_id,
job_cfg["title"].encode("utf-8")))
def usage(error=None):
@@ -1967,18 +1967,19 @@ def main():
globals()["mode_%s" % mode_name](*mode_args, opts=opt_dict)
-try:
- main()
-except MKTerminate, e:
- sys.stderr.write("%s\n" % e)
- sys.exit(1)
-
-except KeyboardInterrupt:
- sys.stderr.write("Terminated.\n")
- sys.exit(0)
-
-except MKGeneralException, e:
- sys.stderr.write("%s\n" % e)
- if opt_debug:
- raise
- sys.exit(3)
+if __name__ == "__main__":
+ try:
+ main()
+ except MKTerminate, e:
+ sys.stderr.write("%s\n" % e)
+ sys.exit(1)
+
+ except KeyboardInterrupt:
+ sys.stderr.write("Terminated.\n")
+ sys.exit(0)
+
+ except MKGeneralException, e:
+ sys.stderr.write("%s\n" % e)
+ if opt_debug:
+ raise
+ sys.exit(3)