client/rhel/yum-rhn-plugin/rhnplugin.py | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-)
New commits: commit b15b3d2c5cfb6ba04380f8da4b896874dbec024c Author: Michael Mraka michael.mraka@redhat.com Date: Fri Aug 5 11:03:06 2011 +0200
parse commandline on our own
optparse can't skip unknown options properly fixing Traceback (most recent call last): File "/usr/bin/yum", line 29, in ? yummain.user_main(sys.argv[1:], exit_code=True) ... File "/usr/share/yum-plugins/rhnplugin.py", line 100, in init_hook (filt_opts, filt_commands) = filt_parser.parse_args() File "/usr/lib64/python2.4/optparse.py", line 1275, in parse_args stop = self._process_args(largs, rargs, values) File "/usr/lib64/python2.4/optparse.py", line 1319, in _process_args self._process_short_opts(rargs, values) File "/usr/lib64/python2.4/optparse.py", line 1403, in _process_short_opts if option.takes_value(): AttributeError: 'NoneType' object has no attribute 'takes_value'
diff --git a/client/rhel/yum-rhn-plugin/rhnplugin.py b/client/rhel/yum-rhn-plugin/rhnplugin.py index c1dc20f..331d79a 100644 --- a/client/rhel/yum-rhn-plugin/rhnplugin.py +++ b/client/rhel/yum-rhn-plugin/rhnplugin.py @@ -22,7 +22,6 @@ except ImportError: pycurl = None
from iniparse import INIConfig -from optparse import OptionParser
import gettext t = gettext.translation('yum-rhn-plugin', fallback=True) @@ -52,10 +51,6 @@ COMMUNICATION_ERROR = _("There was an error communicating with RHN.")
from M2Crypto.SSL import SSLError
-class FilterOptionParser(OptionParser): - def error(self, msg): - pass - def init_hook(conduit): """ Plugin initialization hook. We setup the RHN channels here. @@ -91,24 +86,23 @@ def init_hook(conduit): return
# check commands and options which don't need network communication - filt_parser = FilterOptionParser(add_help_option=False) - filt_parser.add_option('', '--version', action="store_true") - filt_parser.add_option('', '--help', action="store_true") - filt_parser.add_option('-C', '--cacheonly', action="store_true") - (filt_opts, filt_commands) = filt_parser.parse_args() - if filt_opts.version or filt_opts.help or filt_commands == []: + cmd_args = sys.argv[1:] + if ('--help' in cmd_args + or '--version' in cmd_args + or cmd_args == []): rhn_enabled = False conduit.info(10, _("Either --version, --help or no commands entered") + "\n" + RHN_DISABLED) return - if filt_commands[0] == 'clean': + if 'clean' in cmd_args: addCachedRepos(conduit) conduit.info(10, _("Cleaning") + "\n" + RHN_DISABLED) # cleanup cached login info if os.path.exists(pcklAuthFileName): os.unlink(pcklAuthFileName) return - if filt_opts.cacheonly: + if ('-C' in cmd_args + or '--cacheonly' in cmd_args): rhn_enabled = False addCachedRepos(conduit) conduit.info(10, _("Using list of RHN repos from cache") +
spacewalk-commits@lists.fedorahosted.org