diff --git a/helpman b/helpman index f63688aba6873d9a9a3bdcc3eb31faf5df2ece3b..e27417e888642c30631fe0140dcf6fc9db2174e1 100755 --- a/helpman +++ b/helpman @@ -32,25 +32,31 @@ import os, errno import datetime import time import sys -import StringIO # Following executes os commands passed on to it def execute_command_I(full_command): - proc = subprocess.Popen(full_command,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True) + proc = subprocess.Popen(full_command,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True,universal_newlines=True) (out, err) = proc.communicate() if err: result.set_text(err) else: - select_manual_cbtext_III.remove_all() - s = StringIO.StringIO(out) - for line in s: - select_manual_cbtext_III.append_text(line.strip()) + select_manual_cbtext_III.remove_all() + try: + import StringIO + # from StringIO import StringIO + s = StringIO.StringIO(out) + except ImportError: + import io + from io import StringIO + s = io.StringIO(out) + for line in s: + select_manual_cbtext_III.append_text(line.strip()) def execute_command_II(full_command): - proc = subprocess.Popen(full_command,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True) + proc = subprocess.Popen(full_command,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True,universal_newlines=True) (out, err) = proc.communicate() # if err: # result.set_text(err) @@ -64,9 +70,9 @@ def execute_command_II(full_command): textbuffer.place_cursor(start) else: textbuffer.set_text("") - if smentry.get_text(): - result.set_text("No manual entry for " + smentry.get_text()) - else: + if smentry.get_text(): + result.set_text("No manual entry for " + smentry.get_text()) + else: result.set_text("") class Handler: @@ -74,56 +80,56 @@ class Handler: # Helpman comboboxtext and their respective changed actions. Calls the functions above with their respective parameters. def manual_type_cbtext_1_changed(self, comboboxtext): - result.set_text("") - smentry.set_text("") + result.set_text("") + smentry.set_text("") textbuffer.set_text("") - starting_with_cbtext_II.set_active(-1) - select_manual_cbtext_III.remove_all() + starting_with_cbtext_II.set_active(-1) + select_manual_cbtext_III.remove_all() def starting_with_cbtext_2_changed(self, comboboxtext): - result.set_text("") - smentry.set_text("") + result.set_text("") + smentry.set_text("") textbuffer.set_text("") - select_manual_cbtext_III.remove_all() - if manual_type_cbtext_I.get_active_text() and starting_with_cbtext_II.get_active_text(): - if starting_with_cbtext_II.get_active_text() == 'others': - dynamic_command = "(LC_COLLATE=en_US.utf8 && export LC_COLLATE && ls /usr/share/man/man" + str(manual_type_cbtext_I.get_active() + 1) + " ) | sed 's/\." + str(manual_type_cbtext_I.get_active() + 1) + ".*gz$//' | grep -v '^[A-Za-z0-9]'" - # print dynamic_command - result.set_text("") - execute_command_I(dynamic_command) - elif starting_with_cbtext_II.get_active_text() == 'all': - dynamic_command = "(LC_COLLATE=en_US.utf8 && export LC_COLLATE && ls /usr/share/man/man" + str(manual_type_cbtext_I.get_active() + 1) + " ) | sed 's/\." + str(manual_type_cbtext_I.get_active() + 1) + ".*gz$//' | grep -v '^$'" - # print dynamic_command - result.set_text("") - execute_command_I(dynamic_command) - else: - dynamic_command = "(LC_COLLATE=en_US.utf8 && export LC_COLLATE && ls /usr/share/man/man" + str(manual_type_cbtext_I.get_active() + 1) + " ) | sed 's/\." + str(manual_type_cbtext_I.get_active() + 1) + ".*gz$//' | grep -i '^" + starting_with_cbtext_II.get_active_text() + "'" - # print dynamic_command - result.set_text("") - execute_command_I(dynamic_command) - elif not manual_type_cbtext_I.get_active_text(): - result.set_text("Please Select Manual Type First !") + select_manual_cbtext_III.remove_all() + if manual_type_cbtext_I.get_active_text() and starting_with_cbtext_II.get_active_text(): + if starting_with_cbtext_II.get_active_text() == 'others': + dynamic_command = "(LC_COLLATE=en_US.utf8 && export LC_COLLATE && ls /usr/share/man/man" + str(manual_type_cbtext_I.get_active() + 1) + " ) | sed 's/\." + str(manual_type_cbtext_I.get_active() + 1) + ".*gz$//' | grep -v '^[A-Za-z0-9]'" + # print dynamic_command + result.set_text("") + execute_command_I(dynamic_command) + elif starting_with_cbtext_II.get_active_text() == 'all': + dynamic_command = "(LC_COLLATE=en_US.utf8 && export LC_COLLATE && ls /usr/share/man/man" + str(manual_type_cbtext_I.get_active() + 1) + " ) | sed 's/\." + str(manual_type_cbtext_I.get_active() + 1) + ".*gz$//' | grep -v '^$'" + # print dynamic_command + result.set_text("") + execute_command_I(dynamic_command) + else: + dynamic_command = "(LC_COLLATE=en_US.utf8 && export LC_COLLATE && ls /usr/share/man/man" + str(manual_type_cbtext_I.get_active() + 1) + " ) | sed 's/\." + str(manual_type_cbtext_I.get_active() + 1) + ".*gz$//' | grep -i '^" + starting_with_cbtext_II.get_active_text() + "'" + # print dynamic_command + result.set_text("") + execute_command_I(dynamic_command) + elif not manual_type_cbtext_I.get_active_text(): + result.set_text("Please Select Manual Type First !") def select_manual_cbtext_3_changed(self, comboboxtext): if select_manual_cbtext_III.get_active_text(): - if manual_type_cbtext_I.get_active_text(): - dynamic_command = "man --sections=" + str(manual_type_cbtext_I.get_active() + 1) + " " + select_manual_cbtext_III.get_active_text() + "|tee" - # print dynamic_command - execute_command_II(dynamic_command) - else: - dynamic_command = "man " + select_manual_cbtext_III.get_active_text() + "|tee" - # print dynamic_command - execute_command_II(dynamic_command) - else: - result.set_text("") + if manual_type_cbtext_I.get_active_text(): + dynamic_command = "man --sections=" + str(manual_type_cbtext_I.get_active() + 1) + " " + select_manual_cbtext_III.get_active_text() + "|tee" + # print dynamic_command + execute_command_II(dynamic_command) + else: + dynamic_command = "man " + select_manual_cbtext_III.get_active_text() + "|tee" + # print dynamic_command + execute_command_II(dynamic_command) + else: + result.set_text("") def detailsbutton(self, button): - ouraboutwindow.set_transient_for(window) - ouraboutwindow.run() - ouraboutwindow.hide() - # ouraboutwindow.destroy() + ouraboutwindow.set_transient_for(window) + ouraboutwindow.run() + ouraboutwindow.hide() + # ouraboutwindow.destroy() builder = Gtk.Builder() diff --git a/helpman.1.gz b/helpman.1.gz index 7c8461c95395868b28cff56b7481c6da90be8dfe..7f502f391d495501c41488598000c40218770637 100644 Binary files a/helpman.1.gz and b/helpman.1.gz differ diff --git a/helpman.glade b/helpman.glade index af6c6cd4db8a1d4a9debc4f5c9c62839614b02e2..43eb7e7c21ecb6238c0666bdcb51379877c9419a 100644 --- a/helpman.glade +++ b/helpman.glade @@ -11,7 +11,7 @@ <property name="icon">/usr/share/pixmaps/helpman.png</property> <property name="type_hint">dialog</property> <property name="has_resize_grip">True</property> - <property name="program_name">Helpman 1.0</property> + <property name="program_name">Helpman</property> <property name="copyright" translatable="yes">Files: * Copyright: 2017 Nathan SR <cquickcal@gmail.com> License: GPL-3+</property> diff --git a/setup.py b/setup.py index a7065bef13987057c4b08ef4ae51b25f96ce5f72..b17d67873947517203fe68fd90d301f1cef214a2 100644 --- a/setup.py +++ b/setup.py @@ -1,10 +1,10 @@ from distutils.core import setup setup(name = "helpman", -version = "1.0", -description = "helpman gives quick & easy access to 4000+ manuals / guides / tutorials", +version = "2.0", +description = "quick & easy access to 4000+ manuals / guides / tutorials", author = "Nathan SR", author_email = "cquickcal@gmail.com", -url = "https://sourceforge.net/projects/helpman-1/", +url = "https://git.fosscommunity.in/SRNathan/Helpman", license='GPLv3', scripts=['helpman'], data_files = [ ("lib/helpman", ["helpman.glade"]),