On Monday 11 of January 2016 22:20:29 Miroslav Suchy wrote: > Dne 10.1.2016 v 03:30 Pavel Raiskup napsal(a): > > --- > > cli/copr | 25 +++++++++++++++++++++++++ > > cli/copr_cli/main.py | 9 ++++++--- > > 2 files changed, 31 insertions(+), 3 deletions(-) > > create mode 100755 cli/copr > > > > diff --git a/cli/copr b/cli/copr > > new file mode 100755 > > index 0000000..a119b23 > > --- /dev/null > > +++ b/cli/copr > > @@ -0,0 +1,25 @@ > > +#! /bin/sh > > + > > +# Run copr-cli script directly from git. > > I do not want to support running copr-cli directly from git. What is the > benefit? If you want to test then commit your work, run "tito build > --rpm --test -i" and test is exactly how user will use it.
Ach, I personally dislike tito and building/installing the RPMs for testing purposes, also I wouldn't be worried about the support (it is just testing wrapper). Yeah, I'll keep that locally. > > class Commands(object): > > - def __init__(self): > > + def __init__(self, config): > > > > try: > > - self.client = CoprClient.create_from_file_config() > > + self.client = CoprClient.create_from_file_config(config) > > except (copr_exceptions.CoprNoConfException, > > copr_exceptions.CoprConfigException): > > print(no_config_warning) > > @@ -295,6 +295,9 @@ def setup_parser(): > > parser.add_argument("--debug", dest="debug", action="store_true", > > help="Enable debug output") > > > > + parser.add_argument("--config", dest="config", > > + help="Path to an alternative configuration file") > > + > > subparsers = parser.add_subparsers(title="actions") > > > > # create the parser for the "list" command > > @@ -422,7 +425,7 @@ def main(argv=sys.argv[1:]): > > if arg.debug: > > enable_debug() > > > > - commands = Commands() > > + commands = Commands(arg.config) > > getattr(commands, arg.func)(arg) > > > > except KeyboardInterrupt: > > > > > On the other hand this one is useful. > Can you please split it? Split done. Pavel
>From 79c09fd9b5df833590cc6c9c36da034b69b483f9 Mon Sep 17 00:00:00 2001 From: Pavel Raiskup <prais...@redhat.com> Date: Sun, 10 Jan 2016 03:25:14 +0100 Subject: [PATCH 1/3] [python] fix wrong check for list instance --- python/copr/client/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/copr/client/client.py b/python/copr/client/client.py index 79f233f..846017b 100644 --- a/python/copr/client/client.py +++ b/python/copr/client/client.py @@ -475,7 +475,7 @@ class CoprClient(UnicodeMixin): if not chroots: raise Exception("You should provide chroots") - if isinstance(chroots, list): + if not isinstance(chroots, list): chroots = [chroots] if isinstance(repos, list): -- 2.5.0
>From 289496092f427b5fa16ba0fe112eac776cabaaf8 Mon Sep 17 00:00:00 2001 From: Pavel Raiskup <prais...@redhat.com> Date: Tue, 12 Jan 2016 12:42:13 +0100 Subject: [PATCH 2/3] [cli] add --config option This simplifies running the copr client against other than default (https://copr.fedoraproject.org) Copr service. --- cli/copr_cli/main.py | 9 ++++++--- cli/man/copr-cli.1.asciidoc | 24 +++++++++++++----------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/cli/copr_cli/main.py b/cli/copr_cli/main.py index 8d55466..6dc8b9f 100644 --- a/cli/copr_cli/main.py +++ b/cli/copr_cli/main.py @@ -40,10 +40,10 @@ no_config_warning = """ class Commands(object): - def __init__(self): + def __init__(self, config): try: - self.client = CoprClient.create_from_file_config() + self.client = CoprClient.create_from_file_config(config) except (copr_exceptions.CoprNoConfException, copr_exceptions.CoprConfigException): print(no_config_warning) @@ -295,6 +295,9 @@ def setup_parser(): parser.add_argument("--debug", dest="debug", action="store_true", help="Enable debug output") + parser.add_argument("--config", dest="config", + help="Path to an alternative configuration file") + subparsers = parser.add_subparsers(title="actions") # create the parser for the "list" command @@ -422,7 +425,7 @@ def main(argv=sys.argv[1:]): if arg.debug: enable_debug() - commands = Commands() + commands = Commands(arg.config) getattr(commands, arg.func)(arg) except KeyboardInterrupt: diff --git a/cli/man/copr-cli.1.asciidoc b/cli/man/copr-cli.1.asciidoc index e173f84..c797453 100644 --- a/cli/man/copr-cli.1.asciidoc +++ b/cli/man/copr-cli.1.asciidoc @@ -10,7 +10,7 @@ copr-cli - command line interface for the Copr service SYNOPSIS -------- -copr-cli [-h] [--version] {list,create,build} ... +copr-cli [-h] [--version] [--config CONFIG] {list,create,build} ... DESCRIPTION ----------- @@ -28,6 +28,9 @@ show this help message and exit --version:: show the program's version number and exit +--config:: +path to an alternative configuration file (default is ~/.config/copr). + ACTIONS ------- @@ -175,24 +178,23 @@ format: username = msuchy login = Y57wcg==##fkfaxbkjhuoiebfafadl token = vbfseelqdebzedukgombekmuvbkqwo + copr_url = https://copr.fedoraproject.org Be aware that API tokens have an expiration date. The expiration date for your token is listed on the /api page. -If you are using a different instance for the Copr service, the API token is -available from http://your.copr.server/api/ +USING DIFFERENT COPR INSTANCE +----------------------------- -COPR URL --------- +If you plan to run `copr` client against non-default Copr instance, the API +token is available on the http://YOUR.COPR.URL/api/ page. You can either +replace your default `~/.config/copr` configuration file, or rather use +alternative file with a shell alias -You can alternatively specify a different URL for the Copr service. -Open the file `~/.config/copr` provide the `copr_url` setting: + alias your_copr='copr --config ~/.config/your-copr' - [copr-cli] - copr_url = https://copr.fedoraproject.org +inserted into your profile. -The value listed above is the default value. Only define copr_url only if -you use a different instance. AUTHORS ------- -- 2.5.0
>From 73db92d1da24cc1c0c7b3bd7b7066bdade603220 Mon Sep 17 00:00:00 2001 From: Pavel Raiskup <prais...@redhat.com> Date: Tue, 12 Jan 2016 12:45:16 +0100 Subject: [PATCH 3/3] [cli] wrapper for running from git --- cli/copr | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 cli/copr diff --git a/cli/copr b/cli/copr new file mode 100755 index 0000000..157fb10 --- /dev/null +++ b/cli/copr @@ -0,0 +1,22 @@ +#! /bin/sh + +# Run copr-cli script directly from git. +# Copyright (C) 2016 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +absdir="$(dirname "$(readlink -f "$0")")" +export PYTHONPATH="$absdir:$absdir/../python" +python -m copr_cli.main "$@" -- 2.5.0
_______________________________________________ copr-devel mailing list copr-devel@lists.fedorahosted.org https://lists.fedorahosted.org/admin/lists/copr-devel@lists.fedorahosted.org