示例#1
0
    def do_config(self, line):
        (cmd, args, line) = self.parseline(line)
        # logs
        if cmd in ['debuglevel', 'errorlevel']:
            opts = self._shlex_split(args)
            if not opts:
                self.verbose_logger.log(logginglevels.INFO_2, '%s: %s', cmd,
                                        getattr(self.base.conf, cmd))
            else:
                val = opts[0]
                try:
                    val = int(val)
                except ValueError:
                    self.logger.critical(
                        'Value %s for %s cannot be made to an int', val, cmd)
                    return
                setattr(self.base.conf, cmd, val)
                if cmd == 'debuglevel':
                    logginglevels.setDebugLevel(val)
                elif cmd == 'errorlevel':
                    logginglevels.setErrorLevel(val)
        # bools
        elif cmd in ['gpgcheck', 'repo_gpgcheck', 'obsoletes', 'assumeyes']:
            opts = self._shlex_split(args)
            if not opts:
                self.verbose_logger.log(logginglevels.INFO_2, '%s: %s', cmd,
                                        getattr(self.base.conf, cmd))
            else:
                value = opts[0]
                if value.lower() not in BOOLEAN_STATES:
                    self.logger.critical('Value %s for %s is not a Boolean',
                                         value, cmd)
                    return False
                value = BOOLEAN_STATES[value.lower()]
                setattr(self.base.conf, cmd, value)
                if cmd == 'obsoletes':
                    self.base.up = None

        elif cmd in ['exclude']:
            args = args.replace(',', ' ')
            opts = self._shlex_split(args)
            if not opts:
                msg = '%s: ' % cmd
                msg = msg + ' '.join(getattr(self.base.conf, cmd))
                self.verbose_logger.log(logginglevels.INFO_2, msg)
                return False
            else:
                setattr(self.base.conf, cmd, opts)
                if self.base.pkgSack:  # kill the pkgSack
                    self.base.pkgSack = None
                self.base.up = None  # reset the updates
                # reset the transaction set, we have to or we shall surely die!
                self.base.closeRpmDB()
        else:
            self.do_help('config')
 def do_config(self, line):
     (cmd, args, line) = self.parseline(line)
     # logs
     if cmd in ['debuglevel', 'errorlevel']:
         opts = self._shlex_split(args)
         if not opts:
             self.verbose_logger.log(logginglevels.INFO_2, '%s: %s', cmd,
                 getattr(self.base.conf, cmd))
         else:
             val = opts[0]
             try:
                 val = int(val)
             except ValueError:
                 self.logger.critical('Value %s for %s cannot be made to an int', val, cmd)
                 return
             setattr(self.base.conf, cmd, val)
             if cmd == 'debuglevel':
                 logginglevels.setDebugLevel(val)
             elif cmd == 'errorlevel':
                 logginglevels.setErrorLevel(val)
     # bools
     elif cmd in ['gpgcheck', 'repo_gpgcheck', 'obsoletes', 'assumeyes']:
         opts = self._shlex_split(args)
         if not opts:
             self.verbose_logger.log(logginglevels.INFO_2, '%s: %s', cmd,
                 getattr(self.base.conf, cmd))
         else:
             value = opts[0]
             if value.lower() not in BOOLEAN_STATES:
                 self.logger.critical('Value %s for %s is not a Boolean', value, cmd)
                 return False
             value = BOOLEAN_STATES[value.lower()]
             setattr(self.base.conf, cmd, value)
             if cmd == 'obsoletes':
                 self.base.up = None
     
     elif cmd in ['exclude']:
         args = args.replace(',', ' ')
         opts = self._shlex_split(args)
         if not opts:
             msg = '%s: ' % cmd
             msg = msg + ' '.join(getattr(self.base.conf, cmd))
             self.verbose_logger.log(logginglevels.INFO_2, msg)
             return False
         else:
             setattr(self.base.conf, cmd, opts)
             if self.base.pkgSack:       # kill the pkgSack
                 self.base.pkgSack = None
             self.base.up = None         # reset the updates
             # reset the transaction set, we have to or we shall surely die!
             self.base.closeRpmDB() 
     else:
         self.do_help('config')
示例#3
0
    def do_config(self, line):
        (cmd, args, line) = self.parseline(line)
        # logs
        if cmd in ["debuglevel", "errorlevel"]:
            opts = self._shlex_split(args)
            if not opts:
                self.verbose_logger.log(logginglevels.INFO_2, "%s: %s", cmd, getattr(self.base.conf, cmd))
            else:
                val = opts[0]
                try:
                    val = int(val)
                except ValueError:
                    self.logger.critical("Value %s for %s cannot be made to an int", val, cmd)
                    return
                setattr(self.base.conf, cmd, val)
                if cmd == "debuglevel":
                    logginglevels.setDebugLevel(val)
                elif cmd == "errorlevel":
                    logginglevels.setErrorLevel(val)
        # bools
        elif cmd in ["gpgcheck", "repo_gpgcheck", "obsoletes", "assumeyes"]:
            opts = self._shlex_split(args)
            if not opts:
                self.verbose_logger.log(logginglevels.INFO_2, "%s: %s", cmd, getattr(self.base.conf, cmd))
            else:
                value = opts[0]
                if value.lower() not in BOOLEAN_STATES:
                    self.logger.critical("Value %s for %s is not a Boolean", value, cmd)
                    return False
                value = BOOLEAN_STATES[value.lower()]
                setattr(self.base.conf, cmd, value)
                if cmd == "obsoletes":
                    self.base.up = None

        elif cmd in ["exclude"]:
            args = args.replace(",", " ")
            opts = self._shlex_split(args)
            if not opts:
                msg = "%s: " % cmd
                msg = msg + " ".join(getattr(self.base.conf, cmd))
                self.verbose_logger.log(logginglevels.INFO_2, msg)
                return False
            else:
                setattr(self.base.conf, cmd, opts)
                if self.base.pkgSack:  # kill the pkgSack
                    self.base.pkgSack = None
                self.base.up = None  # reset the updates
                # reset the transaction set, we have to or we shall surely die!
                self.base.closeRpmDB()
        else:
            self.do_help("config")
示例#4
0
文件: shell.py 项目: akozumpl/yum
 def do_config(self, line):
     """Configure yum shell options.
     
     :param line: the remainder of the line, containing an option,
        and then optionally a value in the form [option] [value].
        Valid options are one of the following: debuglevel,
        errorlevel, obsoletes, gpgcheck, assumeyes, exclude.  If no
        value is given, print the current value.  If a value is
        supplied, set the option to the given value.
     """
     (cmd, args, line) = self.parseline(line)
     # logs
     if cmd in ['debuglevel', 'errorlevel']:
         opts = self._shlex_split(args)
         if not opts:
             self.verbose_logger.log(logginglevels.INFO_2, '%s: %s', cmd,
                 getattr(self.base.conf, cmd))
         else:
             val = opts[0]
             try:
                 val = int(val)
             except ValueError:
                 self.logger.critical('Value %s for %s cannot be made to an int', val, cmd)
                 return
             setattr(self.base.conf, cmd, val)
             if cmd == 'debuglevel':
                 logginglevels.setDebugLevel(val)
             elif cmd == 'errorlevel':
                 logginglevels.setErrorLevel(val)
     # bools
     elif cmd in ['gpgcheck', 'repo_gpgcheck', 'obsoletes', 'assumeyes']:
         opts = self._shlex_split(args)
         if not opts:
             self.verbose_logger.log(logginglevels.INFO_2, '%s: %s', cmd,
                 getattr(self.base.conf, cmd))
         else:
             value = opts[0]
             if value.lower() not in BOOLEAN_STATES:
                 self.logger.critical('Value %s for %s is not a Boolean', value, cmd)
                 return False
             value = BOOLEAN_STATES[value.lower()]
             setattr(self.base.conf, cmd, value)
             if cmd == 'obsoletes':
                 self.base.up = None
     
     elif cmd in ['exclude']:
         args = args.replace(',', ' ')
         opts = self._shlex_split(args)
         if not opts:
             msg = '%s: ' % cmd
             msg = msg + ' '.join(getattr(self.base.conf, cmd))
             self.verbose_logger.log(logginglevels.INFO_2, msg)
             return False
         else:
             setattr(self.base.conf, cmd, opts)
             if self.base.pkgSack:       # kill the pkgSack
                 self.base.pkgSack = None
             self.base.up = None         # reset the updates
             # reset the transaction set, we have to or we shall surely die!
             self.base.closeRpmDB() 
     else:
         self.do_help('config')
示例#5
0
文件: shell.py 项目: wenjiedeng/yum
    def do_config(self, line):
        """Configure yum shell options.
        
        :param line: the remainder of the line, containing an option,
           and then optionally a value in the form [option] [value].
           Valid options are one of the following: debuglevel,
           errorlevel, obsoletes, gpgcheck, assumeyes, exclude.  If no
           value is given, print the current value.  If a value is
           supplied, set the option to the given value.
        """
        self.result = 0
        (cmd, args, line) = self.parseline(line)
        # logs
        if cmd in ['debuglevel', 'errorlevel']:
            opts = self._shlex_split(args)
            if not opts:
                self.verbose_logger.log(logginglevels.INFO_2, '%s: %s', cmd,
                                        getattr(self.base.conf, cmd))
            else:
                val = opts[0]
                try:
                    val = int(val)
                except ValueError:
                    self.logger.critical(
                        'Value %s for %s cannot be made to an int', val, cmd)
                    self.result = 1
                    return
                setattr(self.base.conf, cmd, val)
                if cmd == 'debuglevel':
                    logginglevels.setDebugLevel(val)
                elif cmd == 'errorlevel':
                    logginglevels.setErrorLevel(val)
        # bools
        elif cmd in ['gpgcheck', 'repo_gpgcheck', 'obsoletes', 'assumeyes']:
            opts = self._shlex_split(args)
            if not opts:
                self.verbose_logger.log(logginglevels.INFO_2, '%s: %s', cmd,
                                        getattr(self.base.conf, cmd))
            else:
                value = opts[0]
                if value.lower() not in BOOLEAN_STATES:
                    self.logger.critical('Value %s for %s is not a Boolean',
                                         value, cmd)
                    self.result = 1
                    return False
                value = BOOLEAN_STATES[value.lower()]
                setattr(self.base.conf, cmd, value)
                if cmd == 'obsoletes':
                    self.base.up = None

        elif cmd in ['exclude']:
            args = args.replace(',', ' ')
            opts = self._shlex_split(args)
            if not opts:
                msg = '%s: ' % cmd
                msg = msg + ' '.join(getattr(self.base.conf, cmd))
                self.verbose_logger.log(logginglevels.INFO_2, msg)
                return False
            else:
                setattr(self.base.conf, cmd, opts)
                if self.base.pkgSack:  # kill the pkgSack
                    self.base.pkgSack = None
                self.base.up = None  # reset the updates
                # reset the transaction set, we have to or we shall surely die!
                self.base.closeRpmDB()
        else:
            self.do_help('config')