The build action is used to build certain packages in a given copr. --- copr_cli/subcommands.py | 37 +++++++++++++++++++++++++++++++++++++ coprcli-setup.py | 1 + 2 files changed, 38 insertions(+)
diff --git a/copr_cli/subcommands.py b/copr_cli/subcommands.py index c1af50a..c0013db 100644 --- a/copr_cli/subcommands.py +++ b/copr_cli/subcommands.py @@ -109,3 +109,40 @@ class AddCopr(Command): print output['message'] else: print 'Something went wrong:\n {0}'.format(output['error']) + + +class Build(Command): + """ Build a new package into a given copr. """ + + log = logging.getLogger(__name__) + + def get_parser(self, prog_name): + parser = super(type(self), self).get_parser(prog_name) + parser.add_argument('copr') + parser.add_argument('pkgs', nargs='+', action='append') + parser.add_argument('--memory', dest='memory', + help="") + parser.add_argument('--timeout', dest='timeout', + help="") + return parser + + def take_action(self, args): + user = set_user() + URL = '{0}/coprs/detail/{1}/{2}/new_build/'.format( + copr_api_url, + user['username'], + args.copr) + + data = {'pkgs': ' '.join(args.pkgs[0]), + 'memory': args.memory, + 'timeout': args.timeout + } + + req = requests.post(URL, + auth=(user['username'], user['token']), + data=data) + output = json.loads(req.text) + if req.status_code != 200: + print 'Something went wrong:\n {0}'.format(output['error']) + else: + print output['message'] diff --git a/coprcli-setup.py b/coprcli-setup.py index a7a40d3..0084494 100644 --- a/coprcli-setup.py +++ b/coprcli-setup.py @@ -30,6 +30,7 @@ requires = [ subcommands = [ 'list = copr_cli.subcommands:List', 'add-copr = copr_cli.subcommands:AddCopr', + 'build-copr = copr_cli.subcommands:Build', ]
__name__ = 'copr-cli'
---
I'm still planning to move this into the configuration file but in the mean while this allows us to move forward.
copr_cli/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/copr_cli/main.py b/copr_cli/main.py index 24118b7..a0c7a8a 100644 --- a/copr_cli/main.py +++ b/copr_cli/main.py @@ -12,7 +12,7 @@ from cliff.commandmanager import CommandManager __version__ = '0.1.0' __description__ = "CLI tool to run copr"
-copr_url = 'http://localhost:5000' +copr_url = 'http://copr-fe.cloud.fedoraproject.org/' copr_api_url = '{0}/api'.format(copr_url)
----- Original Message -----
I'm still planning to move this into the configuration file but in the mean while this allows us to move forward.
copr_cli/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/copr_cli/main.py b/copr_cli/main.py index 24118b7..a0c7a8a 100644 --- a/copr_cli/main.py +++ b/copr_cli/main.py @@ -12,7 +12,7 @@ from cliff.commandmanager import CommandManager __version__ = '0.1.0' __description__ = "CLI tool to run copr"
-copr_url = 'http://localhost:5000' +copr_url = 'http://copr-fe.cloud.fedoraproject.org/' copr_api_url = '{0}/api'.format(copr_url)
-- 1.8.1.2
Both of these patches seem to be fine. Please go ahead and commit.
copr-devel@lists.fedorahosted.org