[copr] master: Implement the build action in the copr-cli (73c29a6)

pingou at fedoraproject.org pingou at fedoraproject.org
Mon Feb 11 10:07:28 UTC 2013


Repository : http://git.fedorahosted.org/cgit/copr.git

On branch  : master

>---------------------------------------------------------------

commit 73c29a65fef9307534ed86202908357ac7728cbc
Author: Pierre-Yves Chibon <pingou at pingoured.fr>
Date:   Sun Feb 3 20:47:56 2013 +0100

    Implement the build action in the copr-cli
    
    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(+), 0 deletions(-)

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'



More information about the copr-devel mailing list