From 4a50d1b19f41eea5d609591a3628a7b5ac6cc8a8 Mon Sep 17 00:00:00 2001 From: Jimmy Tang Date: Mon, 19 Dec 2016 13:37:36 +0000 Subject: [PATCH] Make highlighter script work with python3 and log a better error than just the exit code when the highlighter fails --- highlighter-wrapper.py | 12 ++++++++---- pastebin.go | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/highlighter-wrapper.py b/highlighter-wrapper.py index ac9f55e..0656cb9 100755 --- a/highlighter-wrapper.py +++ b/highlighter-wrapper.py @@ -1,6 +1,10 @@ -#!/usr/bin/python +#!/usr/bin/env python + +try: + import pygments +except ImportError: + print(" Please install python pygments module") -import pygments from pygments import highlight from pygments.lexers import get_lexer_by_name, guess_lexer from pygments.formatters import HtmlFormatter @@ -65,13 +69,13 @@ def usage(err=0): def get_styles(): item = pygments.styles.get_all_styles() for items in item: - print items + print(items) sys.exit(0) def get_lexers(): item = pygments.lexers.get_all_lexers() for items in item: - print items[0]+";"+items[1][0] + print(items[0]+";"+items[1][0]) sys.exit(0) diff --git a/pastebin.go b/pastebin.go index 58dad70..b1b035d 100644 --- a/pastebin.go +++ b/pastebin.go @@ -191,7 +191,7 @@ func getSupportedLangs() { arg := "getlexers" out, err := exec.Command(configuration.Highlighter, arg).Output() if err != nil { - log.Fatal(err) + log.Fatal(err, string(out)) } // Loop lexers and add them to respectively map,