The build action is used to build certain packages in a given copr. ---
Ok this is a first attempt to the build-copr action in the CLI.
Again, not tested :-)
copr_cli/subcommands.py | 36 ++++++++++++++++++++++++++++++++++++ coprcli-setup.py | 1 + 2 files changed, 37 insertions(+)
diff --git a/copr_cli/subcommands.py b/copr_cli/subcommands.py index ce267a2..7264250 100644 --- a/copr_cli/subcommands.py +++ b/copr_cli/subcommands.py @@ -107,3 +107,39 @@ 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('names', 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.names), + 'memory': args.memory, + 'timeout': args.timeout + } + + req = requests.post(URL, params=user, data=data) + output = json.loads(req.text) + if req.status_code == 200: + print 'Something went wrong:\n {0}'.format(output['error']) + else: + print 'Build submitted' 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'