your trying to get me to see the python script? is this the right way to do
it? I did it with 'man' before but now that I think of it running 'man
/usr/lib/command-not-found' is essentially running 'less
/usr/lib/command-not-found' except 'man/usr/lib/command-not-found' has the
hilighted line ' Manual page command-not-found line 1 (press h for help or
q to quit)'
$ more /usr/lib/command-not-found
#!/usr/bin/python3
# (c) Zygmunt Krynicki 2005, 2006, 2007, 2008
# Licensed under GPL, see COPYING for the whole text
from __future__ import absolute_import, print_function
__version__ = "0.3"
BUG_REPORT_URL = "
https://bugs.launchpad.net/command-not-found/+filebug"
try:
import sys
if sys.path and sys.path[0] == '/usr/lib':
# Avoid ImportError noise due to odd installation location.
sys.path.pop(0)
if sys.version < '3':
# We might end up being executed with Python 2 due to an old
# /etc/bash.bashrc.
import os
if "COMMAND_NOT_FOUND_FORCE_PYTHON2" not in os.environ:
os.execvp("python3", [sys.argv[0]] + sys.argv)
import gettext
import locale
from optparse import OptionParser
from CommandNotFound.util import crash_guard
from CommandNotFound import CommandNotFound
except KeyboardInterrupt:
import sys
sys.exit(127)
def enable_i18n():
cnf = gettext.translation("command-not-found", fallback=True)
kwargs = {}
if sys.version < '3':
kwargs["unicode"] = True
cnf.install(**kwargs)
try:
locale.setlocale(locale.LC_ALL, '')
except locale.Error:
locale.setlocale(locale.LC_ALL, 'C')
def fix_sys_argv(encoding=None):
"""
Fix sys.argv to have only unicode strings, not binary strings.
This is required by various places where such argument might be
automatically coerced to unicode string for formatting
"""
if encoding is None:
encoding = locale.getpreferredencoding()
sys.argv = [arg.decode(encoding) for arg in sys.argv]
class LocaleOptionParser(OptionParser):
"""
OptionParser is broken as its implementation of _get_encoding() uses
sys.getdefaultencoding() which is ascii, what it should be using is
locale.getpreferredencoding() which returns value based on LC_CTYPE
(most
likely) and allows for UTF-8 encoding to be used.
"""
def _get_encoding(self, file):
encoding = getattr(file, "encoding", None)
if not encoding:
encoding = locale.getpreferredencoding()
return encoding
def main():
enable_i18n()
if sys.version < '3':
fix_sys_argv()
parser = LocaleOptionParser(
version=__version__,
usage=_("%prog [options] <command-name>"))
parser.add_option('-d', '--data-dir', action='store',
default="/usr/share/command-not-found",
help=_("use this path to locate data fields"))
parser.add_option('--ignore-installed', '--ignore-installed',
action='store_true', default=False,
help=_("ignore local binaries and display the
available packages"))
parser.add_option('--no-failure-msg',
action='store_true', default=False,
help=_("don't print '<command-name>: command not
found'"))
(options, args) = parser.parse_args()
if len(args) == 1:
cnf = CommandNotFound(options.data_dir)
if not cnf.advise(args[0], options.ignore_installed) and not
options.no_failure_msg:
print(_("%s: command not found") % args[0], file=sys.stderr)
if __name__ == "__main__":
crash_guard(main, BUG_REPORT_URL, __version__)
:-)~MIKE~(-:
On Sun, Oct 12, 2014 at 7:07 PM, James Mcphee <
jmcphe@gmail.com> wrote:
> Sorry, it's not in bin. if [ -x /usr/lib/command-not-found -o -x
> /usr/share/command-not-found/command-not-found ]; then
>
> is the line in .bash.bashrc.
>
> On Sun, Oct 12, 2014 at 10:47 AM, Michael Havens <bmike1@gmail.com> wrote:
>
>> well... in the interim I got my memory chips so I shut down my computer
>> to put them in and found I got the wrong ones! they're two small. so I
>> restart the computer, get your message, and:
>>
>> bmike1@C521 ~ $ which command-not-found
>> bmike1@C521 ~ $ command-not-found
>> command-not-found: command not found
>> bmike1@C521 ~ $
>>
>>
>> :-)~MIKE~(-:
>>
>> On Sun, Oct 12, 2014 at 9:47 AM, James Mcphee <jmcphe@gmail.com> wrote:
>>
>>> Honestly, no :) Check your /etc/bash.bashrc. The default has a little
>>> conditional if the command you typed isn't found it runs that little python
>>> script to look for possible packages that might contain what you were
>>> trying to run. It's annoying an I tend to disable it so when I typo a
>>> command it doesn't slow me down doing the search. Find it with "which
>>> command-not-found" and you can read the python code, which doesn't really
>>> say much, but is interesting none-the-less.
>>>
>>> On Sun, Oct 12, 2014 at 9:40 AM, Michael Havens <bmike1@gmail.com>
>>> wrote:
>>>
>>>> no it isn't but as I was looking into this I tried running the man
>>>> page and get:
>>>> 'No manual entry for command-not-found'
>>>> but when I try to apt-get it:
>>>> 'command-not-found is already the newest version.'
>>>> Then I tried running it with the help option:
>>>> 'command-not-found: command not found'
>>>> Are you just messing with me, James?
>>>>
>>>> :-)~MIKE~(-:
>>>>
>>>> On Sun, Oct 12, 2014 at 5:50 AM, James Mcphee <jmcphe@gmail.com> wrote:
>>>>
>>>>> there's a command called "command-not-found", is that what you were
>>>>> thinking of to find the file in question?
>>>>>
>>>>> On Sun, Oct 12, 2014 at 1:38 AM, Michael Havens <bmike1@gmail.com>
>>>>> wrote:
>>>>>
>>>>>> Long ago I needed a file that was included in an apt package. If I
>>>>>> remember right there is a way to find out what package that file is a part
>>>>>> of and to extract it. Am I right? If so, how is it done?
>>>>>> :-)~MIKE~(-:
>>>>>>
>>>>>> ---------------------------------------------------
>>>>>> PLUG-discuss mailing list - PLUG-discuss@lists.phxlinux.org
>>>>>> To subscribe, unsubscribe, or to change your mail settings:
>>>>>> http://lists.phxlinux.org/mailman/listinfo/plug-discuss
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> James McPhee
>>>>> jmcphe@gmail.com
>>>>>
>>>>> ---------------------------------------------------
>>>>> PLUG-discuss mailing list - PLUG-discuss@lists.phxlinux.org
>>>>> To subscribe, unsubscribe, or to change your mail settings:
>>>>> http://lists.phxlinux.org/mailman/listinfo/plug-discuss
>>>>>
>>>>
>>>>
>>>> ---------------------------------------------------
>>>> PLUG-discuss mailing list - PLUG-discuss@lists.phxlinux.org
>>>> To subscribe, unsubscribe, or to change your mail settings:
>>>> http://lists.phxlinux.org/mailman/listinfo/plug-discuss
>>>>
>>>
>>>
>>>
>>> --
>>> James McPhee
>>> jmcphe@gmail.com
>>>
>>> ---------------------------------------------------
>>> PLUG-discuss mailing list - PLUG-discuss@lists.phxlinux.org
>>> To subscribe, unsubscribe, or to change your mail settings:
>>> http://lists.phxlinux.org/mailman/listinfo/plug-discuss
>>>
>>
>>
>> ---------------------------------------------------
>> PLUG-discuss mailing list - PLUG-discuss@lists.phxlinux.org
>> To subscribe, unsubscribe, or to change your mail settings:
>> http://lists.phxlinux.org/mailman/listinfo/plug-discuss
>>
>
>
>
> --
> James McPhee
> jmcphe@gmail.com
>
> ---------------------------------------------------
> PLUG-discuss mailing list - PLUG-discuss@lists.phxlinux.org
> To subscribe, unsubscribe, or to change your mail settings:
> http://lists.phxlinux.org/mailman/listinfo/plug-discuss
>
---------------------------------------------------
PLUG-discuss mailing list -
PLUG-discuss@lists.phxlinux.org
To subscribe, unsubscribe, or to change your mail settings:
http://lists.phxlinux.org/mailman/listinfo/plug-discuss