1
# Copyright (C) 2010, 2011 Linaro
3
# Author: James Tunnicliffe <james.tunnicliffe@linaro.org>
5
# This file is part of Linaro CI CLI.
7
# Linaro CI CLI is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation, either version 3 of the License, or
10
# (at your option) any later version.
12
# Linaro CI CLI is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
17
# You should have received a copy of the GNU General Public License
18
# along with Linaro Image Tools. If not, see <http://www.gnu.org/licenses/>.
21
from base_command import BaseCommandNeedsAuth, CommandFailed
26
Defines the lci add command
29
class Command(BaseCommandNeedsAuth):
31
parameters = self._args_to_params(args)
33
print "Add task with params %s" % parameters
35
r = self.post("CIJobLoop", parameters)
37
# TODO: server side needs to check that the job name is unique at some
39
if r.status_code != requests.codes.ok:
40
raise CommandFailed(self.name, parameters, r)
42
def _args_to_params(self, parameters):
43
# lci add <VCS URL> [--file-name file_name] [--class-name class_name]
45
parser = argparse.ArgumentParser(description='Linaro CI: Add task.',
46
prog=self.program_name)
47
parser.add_argument('vcs_url', type=str,
48
help='URL to check out test configuration from.')
49
parser.add_argument('--file-name', type=str,
50
default=defaults.file_name,
51
help='Name of the configuration file.'
52
' Default is %s' % defaults.file_name)
53
parser.add_argument('--class-name', type=str,
54
default=defaults.class_name,
55
help='Name of the job class in the configuration file. '
56
'Default is %s' % defaults.class_name)
57
parser.add_argument('--run', action='store_true',
58
help='Enqueue job immediately')
60
args = parser.parse_args(parameters)