Logo Search packages:      
Sourcecode: yum version File versions  Download package

def cli::YumBaseCli::parseCommands (   self,
  mycommands = [] 
)

reads self.cmds and parses them out to make sure that the requested 
base command + argument makes any sense at all

Definition at line 312 of file cli.py.

00312                                           :
        """reads self.cmds and parses them out to make sure that the requested 
        base command + argument makes any sense at all""" 

        self.log(3, 'Yum Version: %s' % self.conf.getConfigOption('yumversion'))
        self.log(3, 'COMMAND: %s' % self.cmdstring)
        self.log(3, 'Installroot: %s' % self.conf.getConfigOption('installroot'))
        if len(self.conf.getConfigOption('commands')) == 0 and len(self.cmds) < 1:
            self.cmds = self.conf.getConfigOption('commands')
        else:
            self.conf.setConfigOption('commands', self.cmds)
        if len(self.cmds) < 1:
            self.errorlog(0, _('You need to give some command'))
            self.usage()
            raise CliError
            
        self.basecmd = self.cmds[0] # our base command
        self.extcmds = self.cmds[1:] # out extended arguments/commands
        
        if len(self.extcmds) > 0:
            self.log(3, 'Ext Commands:\n')
            for arg in self.extcmds:
                self.log(3, '   %s' % arg)
        
        if self.basecmd not in ['update', 'install','info', 'list', 'erase',
                                'grouplist', 'groupupdate', 'groupinstall',
                                'groupremove', 'groupinfo', 'makecache',
                                'clean', 'remove', 'provides', 'check-update',
                                'search', 'upgrade', 'whatprovides',
                                'localinstall', 'localupdate',
                                'resolvedep', 'shell', 'deplist']:
            self.usage()
            raise CliError
    
        if self.conf.getConfigOption('uid') != 0:
            if self.basecmd in ['install', 'update', 'clean', 'upgrade','erase', 
                                'groupupdate', 'groupinstall', 'remove',
                                'groupremove', 'importkey', 'makecache', 
                                'localinstall', 'localupdate']:
                self.errorlog(0, _('You need to be root to perform this command.'))
                raise CliError

        if self.basecmd in ['install', 'update', 'upgrade', 'groupinstall',
                            'groupupdate', 'localinstall', 'localupdate']:

            if not self.gpgKeyCheck():
                for repo in self.repos.listEnabled():
                    if repo.gpgcheck and repo.gpgkey == '':
                        msg = _("""
You have enabled checking of packages via GPG keys. This is a good thing. 
However, you do not have any GPG public keys installed. You need to download
the keys for packages you wish to install and install them.
You can do that by running the command:
    rpm --import public.gpg.key


Alternatively you can specify the url to the key you would like to use
for a repository in the 'gpgkey' option in a repository section and yum 
will install it for you.

For more information contact your distribution or package provider.
""")
                        self.errorlog(0, msg)
                        raise CliError

                
        if self.basecmd in ['install', 'erase', 'remove', 'localinstall', 'localupdate', 'deplist']:
            if len(self.extcmds) == 0:
                self.errorlog(0, _('Error: Need to pass a list of pkgs to %s') % self.basecmd)
                self.usage()
                raise CliError
    
        elif self.basecmd in ['provides', 'search', 'whatprovides']:
            if len(self.extcmds) == 0:
                self.errorlog(0, _('Error: Need an item to match'))
                self.usage()
                raise CliError
                
        elif self.basecmd in ['groupupdate', 'groupinstall', 'groupremove', 'groupinfo']:
            if len(self.extcmds) == 0:
                self.errorlog(0, _('Error: Need a group or list of groups'))
                self.usage()
                raise CliError
                
        elif self.basecmd == 'clean':
            if len(self.extcmds) == 0:
                self.errorlog(0,
                    _('Error: clean requires an option: headers, packages, cache, metadata, all'))
            for cmd in self.extcmds:
                if cmd not in ['headers', 'packages', 'metadata', 'cache', 'dbcache', 'all']:
                    self.usage()
                    raise CliError
                    
        elif self.basecmd == 'shell':
            if len(self.extcmds) == 0:
                self.log(3, "No argument to shell")
                pass
            elif len(self.extcmds) == 1:
                self.log(3, "Filename passed to shell: %s" % self.extcmds[0])              
                if not os.path.isfile(self.extcmds[0]):
                    self.errorlog(
                        0, _("File: %s given has argument to shell does not exists." % self.extcmds))
                    self.usage()
                    raise CliError
            else:
                self.errorlog(0,_("Error: more than one file given as argument to shell."))
                self.usage()
                raise CliError
              
        elif self.basecmd in ['list', 'check-update', 'info', 'update', 'upgrade',
                              'grouplist', 'makecache', 'resolvedep']:
            pass
    
        else:
            self.usage()
            raise CliError


    def doShell(self):


Generated by  Doxygen 1.6.0   Back to index