jlec 14/06/07 20:33:40 Modified: ngxtop-0.0.2-py3.patch Log: app-admin/ngxtop: Add py3 compatibility, #512380 (Portage version: 2.2.10/cvs/Linux x86_64, signed Manifest commit with key B9D4F231BD1558AB!)
Revision Changes Path 1.2 app-admin/ngxtop/files/ngxtop-0.0.2-py3.patch file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-admin/ngxtop/files/ngxtop-0.0.2-py3.patch?rev=1.2&view=markup plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-admin/ngxtop/files/ngxtop-0.0.2-py3.patch?rev=1.2&content-type=text/plain diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-admin/ngxtop/files/ngxtop-0.0.2-py3.patch?r1=1.1&r2=1.2 Index: ngxtop-0.0.2-py3.patch =================================================================== RCS file: /var/cvsroot/gentoo-x86/app-admin/ngxtop/files/ngxtop-0.0.2-py3.patch,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ngxtop-0.0.2-py3.patch 4 Jun 2014 13:08:29 -0000 1.1 +++ ngxtop-0.0.2-py3.patch 7 Jun 2014 20:33:40 -0000 1.2 @@ -1,20 +1,7 @@ - ngxtop/config_parser.py | 4 ++-- - ngxtop/ngxtop.py | 4 ++-- - 2 files changed, 4 insertions(+), 4 deletions(-) - diff --git a/ngxtop/config_parser.py b/ngxtop/config_parser.py -index b8e4804..40b23c9 100644 +index f6999cf..7c0d79a 100644 --- a/ngxtop/config_parser.py +++ b/ngxtop/config_parser.py -@@ -8,7 +8,7 @@ import subprocess - from pyparsing import Literal, Word, ZeroOrMore, OneOrMore, Group, \ - printables, quotedString, pythonStyleComment, removeQuotes - --from utils import choose_one, error_exit -+from .utils import choose_one, error_exit - - - REGEX_SPECIAL_CHARS = r'([\.\*\+\?\|\(\)\{\}\[\]])' @@ -106,7 +106,7 @@ def detect_log_config(arguments): log_formats = dict(get_log_formats(config_str)) @@ -24,18 +11,35 @@ if format_name == 'combined': return log_path, LOG_FORMAT_COMBINED if format_name not in log_formats: -diff --git a/ngxtop/ngxtop.py b/ngxtop/ngxtop.py -index afb5bc3..8667b8b 100755 ---- a/ngxtop/ngxtop.py -+++ b/ngxtop/ngxtop.py -@@ -74,8 +74,8 @@ except ImportError: - from docopt import docopt - import tabulate +@@ -115,7 +115,7 @@ def detect_log_config(arguments): --from config_parser import detect_log_config, detect_config_path, extract_variables, build_pattern --from utils import error_exit -+from .config_parser import detect_log_config, detect_config_path, extract_variables, build_pattern -+from .utils import error_exit - - - DEFAULT_QUERIES = [ + # multiple access logs configured, offer to select one + print('Multiple access logs detected in configuration:') +- log_path = choose_one(access_logs.keys(), 'Select access log file to process: ') ++ log_path = choose_one(list(access_logs.keys()), 'Select access log file to process: ') + format_name = access_logs[log_path] + if format_name not in log_formats: + error_exit('Incorrect format name set in config for access log file "%s"' % log_path) +diff --git a/ngxtop/ngxtop.py b/ngxtop/ngxtop.py +old mode 100755 +new mode 100644 +diff --git a/ngxtop/utils.py b/ngxtop/utils.py +index ef61072..7bd9a2a 100644 +--- a/ngxtop/utils.py ++++ b/ngxtop/utils.py +@@ -5,6 +5,8 @@ def choose_one(choices, prompt): + for idx, choice in enumerate(choices): + print('%d. %s' % (idx + 1, choice)) + selected = None ++ if sys.version[0] == '3': ++ raw_input = input + while not selected or selected <= 0 or selected > len(choices): + selected = raw_input(prompt) + try: +@@ -16,4 +18,4 @@ def choose_one(choices, prompt): + + def error_exit(msg, status=1): + sys.stderr.write('Error: %s\n' % msg) +- sys.exit(status) +\ No newline at end of file ++ sys.exit(status)
