コード例 #1
0
ファイル: copr.py プロジェクト: tbabej/dnf-plugins-core
 def run(self, extcmds):
     try:
         subcommand = extcmds[0]
     except (ValueError, IndexError):
         logger.critical(
             _('Error: ') +
             _('exactly one parameter to '
               'playground command are required'))
         dnf.cli.commands.err_mini_usage(self.cli, self.cli.base.basecmd)
         raise dnf.cli.CliError(
             _('exactly one parameter to '
               'playground command are required'))
     chroot = self._guess_chroot()
     if subcommand == "enable":
         self._cmd_enable(chroot)
         logger.info(_("Playground repositories successfully enabled."))
     elif subcommand == "disable":
         self._cmd_disable()
         logger.info(_("Playground repositories successfully disabled."))
     elif subcommand == "upgrade":
         self._cmd_disable()
         self._cmd_enable(chroot)
         logger.info(_("Playground repositories successfully updated."))
     else:
         raise dnf.exceptions.Error(
             _('Unknown subcommand {}.').format(subcommand))
コード例 #2
0
ファイル: copr.py プロジェクト: whydoubt/dnf-plugins-core
 def run(self, extcmds):
     try:
         subcommand = extcmds[0]
     except (ValueError, IndexError):
         logger.critical(
             _('Error: ') + _('exactly one parameter to '
                              'playground command are required'))
         dnf.cli.commands.err_mini_usage(self.cli, self.cli.base.basecmd)
         raise dnf.cli.CliError(
             _('exactly one parameter to '
               'playground command are required'))
     chroot = self._guess_chroot()
     if subcommand == "enable":
         self._cmd_enable(chroot)
         logger.info(_("Playground repositories successfully enabled."))
     elif subcommand == "disable":
         self._cmd_disable()
         logger.info(_("Playground repositories successfully disabled."))
     elif subcommand == "upgrade":
         self._cmd_disable()
         self._cmd_enable(chroot)
         logger.info(_("Playground repositories successfully updated."))
     else:
         raise dnf.exceptions.Error(
             _('Unknown subcommand {}.').format(subcommand))
コード例 #3
0
 def doCheck(self, basecmd, extcmds):
     """Verify that conditions are met so that this command can run."""
     dnf.cli.commands.checkGPGKey(self.base, self.cli)
     try:
         self.parse_extcmds(extcmds)
     except ValueError:
         logger.critical(
             _('Error: Requires exactly one path to a kickstart file'))
         dnf.cli.commands.err_mini_usage(self.cli, basecmd)
         raise dnf.cli.CliError(
             _('exactly one path to a kickstart file required'))
     dnf.cli.commands.checkEnabledRepo(self.base, extcmds)
コード例 #4
0
 def doCheck(self, basecmd, extcmds):
     """Verify that conditions are met so that this command can run."""
     dnf.cli.commands.checkGPGKey(self.base, self.cli)
     try:
         self.parse_extcmds(extcmds)
     except ValueError:
         logger.critical(
             _('Error: Requires exactly one path to a kickstart file'))
         dnf.cli.commands.err_mini_usage(self.cli, basecmd)
         raise dnf.cli.CliError(
             _('exactly one path to a kickstart file required'))
     dnf.cli.commands.checkEnabledRepo(self.base, extcmds)
コード例 #5
0
ファイル: copr.py プロジェクト: fedora-copr/dnf-plugins-core
    def run(self):
        subcommand = self.opts.subcommand[0]

        if subcommand == "help":
            self.cli.optparser.print_help(self)
            return 0
        if subcommand == "list":
            if self.opts.available_by_user:
                self._list_user_projects(self.opts.available_by_user)
                return
            else:
                self._list_installed_repositories(self.base.conf.reposdir[0],
                                                  self.opts.enabled, self.opts.disabled)
                return

        try:
            project_name = self.opts.arg[0]
        except (ValueError, IndexError):
            logger.critical(
                _('Error: ') +
                _('exactly two additional parameters to '
                  'copr command are required'))
            self.cli.optparser.print_help(self)
            raise dnf.cli.CliError(
                _('exactly two additional parameters to '
                  'copr command are required'))
        try:
            chroot = self.opts.arg[1]
        except IndexError:
            chroot = self._guess_chroot(self.chroot_config)

        # commands without defined copr_username/copr_projectname
        if subcommand == "search":
            self._search(project_name)
            return

        try:
            copr_username, copr_projectname = project_name.split("/")
        except ValueError:
            logger.critical(
                _('Error: ') +
                _('use format `copr_username/copr_projectname` '
                  'to reference copr project'))
            raise dnf.cli.CliError(_('bad copr project format'))

        repo_filename = "{}/_copr_{}-{}.repo" \
                        .format(self.base.conf.get_reposdir, copr_username, copr_projectname)
        modules_repo_filename = "{}/_copr_modules_{}-{}.repo"\
                                .format(self.base.conf.get_reposdir, copr_username, copr_projectname)
        if subcommand == "enable":
            self._need_root()
            msg = _("""
You are about to enable a Copr repository. Please note that this
repository is not part of the main distribution, and quality may vary.

The Fedora Project does not exercise any power over the contents of
this repository beyond the rules outlined in the Copr FAQ at
<https://docs.pagure.org/copr.copr/user_documentation.html#what-i-can-build-in-copr>,
and packages are not held to any quality or security level.

Please do not file bug reports about these packages in Fedora
Bugzilla. In case of problems, contact the owner of this repository.

Do you want to continue?""")
            self._ask_user(msg)
            self._download_repo(project_name, repo_filename, chroot)
            self._add_modules_repofile(project_name, modules_repo_filename)
            logger.info(_("Repository successfully enabled."))
        elif subcommand == "disable":
            self._need_root()
            self._disable_repo(copr_username, copr_projectname)
            self._remove_repo(modules_repo_filename)
            logger.info(_("Repository successfully disabled."))
        elif subcommand == "remove":
            self._need_root()
            self._remove_repo(repo_filename)
            self._remove_repo(modules_repo_filename)
            logger.info(_("Repository successfully removed."))
        else:
            raise dnf.exceptions.Error(
                _('Unknown subcommand {}.').format(subcommand))
コード例 #6
0
ファイル: copr.py プロジェクト: tbabej/dnf-plugins-core
    def run(self, extcmds):
        try:
            subcommand = extcmds[0]
        except (ValueError, IndexError):
            dnf.cli.commands.err_mini_usage(self.cli, self.cli.base.basecmd)
            return 0
        if subcommand == "help":
            dnf.cli.commands.err_mini_usage(self.cli, self.cli.base.basecmd)
            return 0
        try:
            project_name = extcmds[1]
        except (ValueError, IndexError):
            logger.critical(
                _('Error: ') +
                _('exactly two additional parameters to '
                  'copr command are required'))
            dnf.cli.commands.err_mini_usage(self.cli, self.cli.base.basecmd)
            raise dnf.cli.CliError(
                _('exactly two additional parameters to '
                  'copr command are required'))
        try:
            chroot = extcmds[2]
        except IndexError:
            chroot = self._guess_chroot()
        repo_filename = "/etc/yum.repos.d/_copr_{}.repo" \
                        .format(project_name.replace("/", "-"))
        if subcommand == "enable":
            self._need_root()
            self._ask_user("""
You are about to enable a Copr repository. Please note that this
repository is not part of the main Fedora distribution, and quality
may vary.

The Fedora Project does not exercise any power over the contents of
this repository beyond the rules outlined in the Copr FAQ at
<https://fedorahosted.org/copr/wiki/UserDocs#WhatIcanbuildinCopr>, and
packages are not held to any quality or security level.

Please do not file bug reports about these packages in Fedora
Bugzilla. In case of problems, contact the owner of this repository.

Do you want to continue? [y/N]: """)
            self._download_repo(project_name, repo_filename, chroot)
            logger.info(_("Repository successfully enabled."))
        elif subcommand == "disable":
            self._need_root()
            self._remove_repo(repo_filename)
            logger.info(_("Repository successfully disabled."))
        elif subcommand == "list":
            #http://copr.fedoraproject.org/api/coprs/ignatenkobrain/
            api_path = "/api/coprs/{}/".format(project_name)

            res = dnfpluginscore.lib.urlopen(self, None, self.copr_url + api_path, 'w+')
            try:
                json_parse = json.loads(res.read())
            except ValueError:
                raise dnf.exceptions.Error(
                    _("Can't parse repositories for username '{}'.")
                    .format(project_name))
            self._check_json_output(json_parse)
            section_text = _("List of {} coprs").format(project_name)
            self._print_match_section(section_text)
            i = 0
            while i < len(json_parse["repos"]):
                msg = "{0}/{1} : ".format(project_name,
                                          json_parse["repos"][i]["name"])
                desc = json_parse["repos"][i]["description"]
                if not desc:
                    desc = _("No description given")
                msg = self.base.output.fmtKeyValFill(ucd(msg), desc)
                print(msg)
                i += 1
        elif subcommand == "search":
            #http://copr.fedoraproject.org/api/coprs/search/tests/
            api_path = "/api/coprs/search/{}/".format(project_name)

            res = dnfpluginscore.lib.urlopen(self, None, self.copr_url + api_path, 'w+')
            try:
                json_parse = json.loads(res.read())
            except ValueError:
                raise dnf.exceptions.Error(_("Can't parse search for '{}'."
                                            ).format(project_name))
            self._check_json_output(json_parse)
            section_text = _("Matched: {}").format(project_name)
            self._print_match_section(section_text)
            i = 0
            while i < len(json_parse["repos"]):
                msg = "{0}/{1} : ".format(json_parse["repos"][i]["username"],
                                          json_parse["repos"][i]["coprname"])
                desc = json_parse["repos"][i]["description"]
                if not desc:
                    desc = _("No description given.")
                msg = self.base.output.fmtKeyValFill(ucd(msg), desc)
                print(msg)
                i += 1
        else:
            raise dnf.exceptions.Error(
                _('Unknown subcommand {}.').format(subcommand))
コード例 #7
0
ファイル: copr.py プロジェクト: clin1234/dnf-plugins-core
    def run(self):
        subcommand = self.opts.subcommand[0]

        if subcommand == "help":
            self.cli.optparser.print_help(self)
            return 0
        if subcommand == "list":
            if self.opts.available_by_user:
                self._list_user_projects(self.opts.available_by_user)
                return
            else:
                self._list_installed_repositories(self.base.conf.reposdir[0],
                                                  self.opts.enabled,
                                                  self.opts.disabled)
                return

        try:
            project_name = self.opts.arg[0]
        except (ValueError, IndexError):
            logger.critical(
                _('Error: ') + _('exactly two additional parameters to '
                                 'copr command are required'))
            self.cli.optparser.print_help(self)
            raise dnf.cli.CliError(
                _('exactly two additional parameters to '
                  'copr command are required'))
        try:
            chroot = self.opts.arg[1]
            if len(self.opts.arg) > 2:
                raise dnf.exceptions.Error(_('Too many arguments.'))
            self.chroot_parts = chroot.split("-")
            if len(self.chroot_parts) < 3:
                raise dnf.exceptions.Error(
                    _('Bad format of optional chroot. The format is '
                      'distribution-version-architecture.'))
        except IndexError:
            chroot = self._guess_chroot()
            self.chroot_parts = chroot.split("-")

        # commands without defined copr_username/copr_projectname
        if subcommand == "search":
            self._search(project_name)
            return

        project = project_name.split("/")
        if len(project) not in [2, 3]:
            logger.critical(
                _('Error: ') + _('use format `copr_username/copr_projectname` '
                                 'to reference copr project'))
            raise dnf.cli.CliError(_('bad copr project format'))
        elif len(project) == 2:
            copr_username = project[0]
            copr_projectname = project[1]
        else:
            copr_username = project[1]
            copr_projectname = project[2]
            project_name = copr_username + "/" + copr_projectname

        repo_filename = "{0}/_copr:{1}:{2}:{3}.repo".format(
            self.base.conf.get_reposdir, self.copr_hostname,
            self._sanitize_username(copr_username), copr_projectname)
        if subcommand == "enable":
            self._need_root()
            info = _("""
Enabling a Copr repository. Please note that this repository is not part
of the main distribution, and quality may vary.

The Fedora Project does not exercise any power over the contents of
this repository beyond the rules outlined in the Copr FAQ at
<https://docs.pagure.org/copr.copr/user_documentation.html#what-i-can-build-in-copr>,
and packages are not held to any quality or security level.

Please do not file bug reports about these packages in Fedora
Bugzilla. In case of problems, contact the owner of this repository.
""")
            project = '/'.join(
                [self.copr_hostname, copr_username, copr_projectname])
            msg = "Do you really want to enable {0}?".format(project)
            self._ask_user(info, msg)
            self._download_repo(project_name, repo_filename)
            logger.info(_("Repository successfully enabled."))
            self._runtime_deps_warning(copr_username, copr_projectname)
        elif subcommand == "disable":
            self._need_root()
            self._disable_repo(copr_username, copr_projectname)
            logger.info(_("Repository successfully disabled."))
        elif subcommand == "remove":
            self._need_root()
            self._remove_repo(copr_username, copr_projectname)
            logger.info(_("Repository successfully removed."))

        else:
            raise dnf.exceptions.Error(
                _('Unknown subcommand {}.').format(subcommand))
コード例 #8
0
ファイル: copr.py プロジェクト: clin1234/dnf-plugins-core
    def configure(self):
        if self.cli.command.opts.command != "copr":
            return
        copr_hub = None
        copr_plugin_config = ConfigParser()
        config_files = []
        config_path = self.base.conf.pluginconfpath[0]

        default_config_file = os.path.join(config_path, PLUGIN_CONF + ".conf")
        if os.path.isfile(default_config_file):
            config_files.append(default_config_file)

            copr_plugin_config.read(default_config_file)
            if copr_plugin_config.has_option('main', 'distribution') and\
                    copr_plugin_config.has_option('main', 'releasever'):
                distribution = copr_plugin_config.get('main', 'distribution')
                releasever = copr_plugin_config.get('main', 'releasever')
                self.chroot_config = [distribution, releasever]
            else:
                self.chroot_config = [False, False]

        for filename in os.listdir(
                os.path.join(config_path, PLUGIN_CONF + ".d")):
            if filename.endswith('.conf'):
                config_file = os.path.join(config_path, PLUGIN_CONF + ".d",
                                           filename)
                config_files.append(config_file)

        project = []
        if len(self.opts.arg):
            project = self.opts.arg[0].split("/")

        if len(project) == 3 and self.opts.hub:
            logger.critical(
                _('Error: ') +
                _('specify Copr hub either with `--hub` or using '
                  '`copr_hub/copr_username/copr_projectname` format'))
            raise dnf.cli.CliError(_('multiple hubs specified'))

        # Copr hub was not specified, using default hub `fedora`
        elif not self.opts.hub and len(project) != 3:
            self.copr_hostname = self.default_hostname
            self.copr_url = self.default_url

        # Copr hub specified with hub/user/project format
        elif len(project) == 3:
            copr_hub = project[0]

        else:
            copr_hub = self.opts.hub

        # Try to find hub in a config file
        if config_files and copr_hub:
            self.copr_url = None
            copr_plugin_config.read(sorted(config_files, reverse=True))
            hostname = self._read_config_item(copr_plugin_config, copr_hub,
                                              'hostname', None)

            if hostname:
                protocol = self._read_config_item(copr_plugin_config, copr_hub,
                                                  'protocol',
                                                  self.default_protocol)
                port = self._read_config_item(copr_plugin_config, copr_hub,
                                              'port', self.default_port)

                self.copr_hostname = hostname
                self.copr_url = protocol + "://" + hostname
                if int(port) != self.default_port:
                    self.copr_url += ":" + port
                    self.copr_hostname += ":" + port

        if not self.copr_url:
            if '://' not in copr_hub:
                self.copr_hostname = copr_hub
                self.copr_url = self.default_protocol + "://" + copr_hub
            else:
                self.copr_hostname = copr_hub.split('://', 1)[1]
                self.copr_url = copr_hub
コード例 #9
0
    def run(self):
        subcommand = self.opts.subcommand[0]
        if subcommand == "help":
            self.cli.optparser.print_help(self)
            return 0
        try:
            project_name = self.opts.arg[0]
        except (ValueError, IndexError):
            logger.critical(
                _('Error: ') +
                _('exactly two additional parameters to '
                  'copr command are required'))
            self.cli.optparser.print_help(self)
            raise dnf.cli.CliError(
                _('exactly two additional parameters to '
                  'copr command are required'))
        try:
            chroot = self.opts.arg[1]
        except IndexError:
            chroot = self._guess_chroot(self.chroot_config)

        # commands without defined copr_username/copr_projectname
        if subcommand == "list":
            self._list_user_projects(project_name)
            return
        if subcommand == "search":
            self._search(project_name)
            return

        try:
            copr_username, copr_projectname = project_name.split("/")
        except ValueError:
            logger.critical(
                _('Error: ') +
                _('use format `copr_username/copr_projectname` '
                  'to reference copr project'))
            raise dnf.cli.CliError(_('bad copr project format'))

        repo_filename = "{}/_copr_{}-{}.repo" \
                        .format(self.base.conf.get_reposdir, copr_username, copr_projectname)
        if subcommand == "enable":
            self._need_root()
            self._ask_user("""
You are about to enable a Copr repository. Please note that this
repository is not part of the main distribution, and quality may vary.

The Fedora Project does not exercise any power over the contents of
this repository beyond the rules outlined in the Copr FAQ at
<https://fedorahosted.org/copr/wiki/UserDocs#WhatIcanbuildinCopr>, and
packages are not held to any quality or security level.

Please do not file bug reports about these packages in Fedora
Bugzilla. In case of problems, contact the owner of this repository.

Do you want to continue? [y/N]: """)
            self._download_repo(project_name, repo_filename, chroot)
            logger.info(_("Repository successfully enabled."))
        elif subcommand == "disable":
            self._need_root()
            self._disable_repo(copr_username, copr_projectname)
            logger.info(_("Repository successfully disabled."))
        elif subcommand == "remove":
            self._need_root()
            self._remove_repo(repo_filename)
            logger.info(_("Repository successfully removed."))

        else:
            raise dnf.exceptions.Error(
                _('Unknown subcommand {}.').format(subcommand))
コード例 #10
0
ファイル: copr.py プロジェクト: rbuj/dnf-plugins-core
    def run(self, extcmds):
        try:
            subcommand = extcmds[0]
        except (ValueError, IndexError):
            dnf.cli.commands.err_mini_usage(self.cli, self.cli.base.basecmd)
            return 0
        if subcommand == "help":
            dnf.cli.commands.err_mini_usage(self.cli, self.cli.base.basecmd)
            return 0
        try:
            project_name = extcmds[1]
        except (ValueError, IndexError):
            logger.critical(
                _('Error: ') +
                _('exactly two additional parameters to '
                  'copr command are required'))
            dnf.cli.commands.err_mini_usage(self.cli, self.cli.base.basecmd)
            raise dnf.cli.CliError(
                _('exactly two additional parameters to '
                  'copr command are required'))
        try:
            chroot = extcmds[2]
        except IndexError:
            chroot = self._guess_chroot()

        # commands without defined copr_username/copr_projectname
        if subcommand == "list":
            self._list_user_projects(project_name)
            return
        if subcommand == "search":
            self._search(project_name)
            return

        try:
            copr_username, copr_projectname = project_name.split("/")
        except ValueError:
            logger.critical(
                _('Error: ') +
                _('use format `copr_username/copr_projectname` '
                  'to reference copr project'))
            raise dnf.cli.CliError(_('bad copr project format'))

        repo_filename = "/etc/yum.repos.d/_copr_{}-{}.repo" \
                        .format(copr_username, copr_projectname)
        if subcommand == "enable":
            self._need_root()
            self._ask_user("""
You are about to enable a Copr repository. Please note that this
repository is not part of the main Fedora distribution, and quality
may vary.

The Fedora Project does not exercise any power over the contents of
this repository beyond the rules outlined in the Copr FAQ at
<https://fedorahosted.org/copr/wiki/UserDocs#WhatIcanbuildinCopr>, and
packages are not held to any quality or security level.

Please do not file bug reports about these packages in Fedora
Bugzilla. In case of problems, contact the owner of this repository.

Do you want to continue? [y/N]: """)
            self._download_repo(project_name, repo_filename, chroot)
            logger.info(_("Repository successfully enabled."))
        elif subcommand == "disable":
            self._need_root()
            self._disable_repo(copr_username, copr_projectname)
            logger.info(_("Repository successfully disabled."))
        elif subcommand == "remove":
            self._need_root()
            self._remove_repo(repo_filename)
            logger.info(_("Repository successfully removed."))

        else:
            raise dnf.exceptions.Error(
                _('Unknown subcommand {}.').format(subcommand))
コード例 #11
0
    def configure(self):
        copr_hub = None
        copr_plugin_config = ConfigParser()
        config_files = []
        config_path = self.base.conf.pluginconfpath[0]

        default_config_file = os.path.join(config_path, PLUGIN_CONF + ".conf")
        if os.path.isfile(default_config_file):
            config_files.append(default_config_file)

            copr_plugin_config.read(default_config_file)
            if copr_plugin_config.has_option('main', 'distribution') and\
                    copr_plugin_config.has_option('main', 'releasever'):
                distribution = copr_plugin_config.get('main', 'distribution')
                releasever = copr_plugin_config.get('main', 'releasever')
                self.chroot_config = [distribution, releasever]
            else:
                self.chroot_config = [False, False]

        for filename in os.listdir(os.path.join(config_path, PLUGIN_CONF + ".d")):
            if filename.endswith('.conf'):
                config_file = os.path.join(config_path, PLUGIN_CONF + ".d", filename)
                config_files.append(config_file)

        project = []
        if len(self.opts.arg):
            project = self.opts.arg[0].split("/")

        if len(project) == 3 and self.opts.hub:
            logger.critical(
                _('Error: ') +
                _('specify Copr hub either with `--hub` or using '
                  '`copr_hub/copr_username/copr_projectname` format')
            )
            raise dnf.cli.CliError(_('multiple hubs specified'))

        # Copr hub was not specified, using default hub `fedora`
        elif not self.opts.hub and len(project) != 3:
            self.copr_hostname = self.default_hostname
            self.copr_url = self.default_url

        # Copr hub specified with hub/user/project format
        elif len(project) == 3:
            copr_hub = project[0]

        else:
            copr_hub = self.opts.hub

        # Try to find hub in a config file
        if config_files and copr_hub:
            self.copr_url = None
            copr_plugin_config.read(sorted(config_files, reverse=True))
            hostname = self._read_config_item(copr_plugin_config, copr_hub, 'hostname', None)

            if hostname:
                protocol = self._read_config_item(copr_plugin_config, copr_hub, 'protocol',
                                                  self.default_protocol)
                port = self._read_config_item(copr_plugin_config, copr_hub, 'port',
                                              self.default_port)

                self.copr_hostname = hostname
                self.copr_url = protocol + "://" + hostname
                if int(port) != self.default_port:
                    self.copr_url += ":" + port
                    self.copr_hostname += ":" + port

        if not self.copr_url:
            self.copr_hostname = copr_hub
            self.copr_url = self.default_protocol + "://" + copr_hub
コード例 #12
0
ファイル: copr.py プロジェクト: ncoghlan/dnf-plugins-core
    def run(self, extcmds):
        try:
            subcommand = extcmds[0]
        except (ValueError, IndexError):
            dnf.cli.commands.err_mini_usage(self.cli, self.cli.base.basecmd)
            return 0
        if subcommand == "help":
            dnf.cli.commands.err_mini_usage(self.cli, self.cli.base.basecmd)
            return 0
        try:
            project_name = extcmds[1]
        except (ValueError, IndexError):
            logger.critical(
                _('Error: ') + _('exactly two additional parameters to '
                                 'copr command are required'))
            dnf.cli.commands.err_mini_usage(self.cli, self.cli.base.basecmd)
            raise dnf.cli.CliError(
                _('exactly two additional parameters to '
                  'copr command are required'))
        try:
            chroot = extcmds[2]
        except IndexError:
            chroot = self._guess_chroot()
        repo_filename = "/etc/yum.repos.d/_copr_{}.repo" \
                        .format(project_name.replace("/", "-"))
        if subcommand == "enable":
            self._need_root()
            self._ask_user("""
You are about to enable a Copr repository. Please note that this
repository is not part of the main Fedora distribution, and quality
may vary.

The Fedora Project does not exercise any power over the contents of
this repository beyond the rules outlined in the Copr FAQ at
<https://fedorahosted.org/copr/wiki/UserDocs#WhatIcanbuildinCopr>, and
packages are not held to any quality or security level.

Please do not file bug reports about these packages in Fedora
Bugzilla. In case of problems, contact the owner of this repository.

Do you want to continue? [y/N]: """)
            self._download_repo(project_name, repo_filename, chroot)
            logger.info(_("Repository successfully enabled."))
        elif subcommand == "disable":
            self._need_root()
            self._remove_repo(repo_filename)
            logger.info(_("Repository successfully disabled."))
        elif subcommand == "list":
            #http://copr.fedoraproject.org/api/coprs/ignatenkobrain/
            api_path = "/api/coprs/{}/".format(project_name)

            res = dnfpluginscore.lib.urlopen(self, None,
                                             self.copr_url + api_path, 'w+')
            try:
                json_parse = json.loads(res.read())
            except ValueError:
                raise dnf.exceptions.Error(
                    _("Can't parse repositories for username '{}'.").format(
                        project_name))
            self._check_json_output(json_parse)
            section_text = _("List of {} coprs").format(project_name)
            self._print_match_section(section_text)
            i = 0
            while i < len(json_parse["repos"]):
                msg = "{0}/{1} : ".format(project_name,
                                          json_parse["repos"][i]["name"])
                desc = json_parse["repos"][i]["description"]
                if not desc:
                    desc = _("No description given")
                msg = self.base.output.fmtKeyValFill(ucd(msg), desc)
                print(msg)
                i += 1
        elif subcommand == "search":
            #http://copr.fedoraproject.org/api/coprs/search/tests/
            api_path = "/api/coprs/search/{}/".format(project_name)

            res = dnfpluginscore.lib.urlopen(self, None,
                                             self.copr_url + api_path, 'w+')
            try:
                json_parse = json.loads(res.read())
            except ValueError:
                raise dnf.exceptions.Error(
                    _("Can't parse search for '{}'.").format(project_name))
            self._check_json_output(json_parse)
            section_text = _("Matched: {}").format(project_name)
            self._print_match_section(section_text)
            i = 0
            while i < len(json_parse["repos"]):
                msg = "{0}/{1} : ".format(json_parse["repos"][i]["username"],
                                          json_parse["repos"][i]["coprname"])
                desc = json_parse["repos"][i]["description"]
                if not desc:
                    desc = _("No description given.")
                msg = self.base.output.fmtKeyValFill(ucd(msg), desc)
                print(msg)
                i += 1
        else:
            raise dnf.exceptions.Error(
                _('Unknown subcommand {}.').format(subcommand))