From 2d19233628817ed9472ca652fed992c6897a1bff Mon Sep 17 00:00:00 2001 From: Antonio Terceiro Date: Thu, 20 Feb 2014 11:46:51 -0300 Subject: Imported Upstream version 0.10 --- .coveragerc | 14 +++ .testr.conf | 3 + COPYING | 165 ++++++++++++++++++++++++++++++++++++ MANIFEST.in | 4 + PKG-INFO | 2 +- ci-build | 11 +++ entry_points.ini | 5 ++ lava/device/commands.py | 10 +++ lava/device/tests/test_commands.py | 16 ++++ lava/helper/command.py | 16 ++++ lava/job/commands.py | 20 +++++ lava/tool/__init__.py | 2 +- lava_scheduler_tool/commands.py | 22 +++++ lava_tool.egg-info/PKG-INFO | 2 +- lava_tool.egg-info/SOURCES.txt | 3 + lava_tool.egg-info/entry_points.txt | 5 ++ lava_tool.egg-info/top_level.txt | 2 +- 17 files changed, 298 insertions(+), 4 deletions(-) create mode 100644 .coveragerc create mode 100644 .testr.conf create mode 100644 COPYING diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..3a39dfe --- /dev/null +++ b/.coveragerc @@ -0,0 +1,14 @@ +[run] +branch = True +source = . +omit = + setup* + */tests/* + +[report] +precision = 2 +show_missing = True + +[html] +title = Code Coverage of lava-tool +directory = lava_tool_coverage diff --git a/.testr.conf b/.testr.conf new file mode 100644 index 0000000..81694cb --- /dev/null +++ b/.testr.conf @@ -0,0 +1,3 @@ +[DEFAULT] +test_command=python -m subunit.run $IDLIST +test_id_list_default=lava_tool.tests.test_suite diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..fc8a5de --- /dev/null +++ b/COPYING @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/MANIFEST.in b/MANIFEST.in index f778a43..e269e45 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,7 @@ +include COPYING +include INSTALL +include .coveragerc +include .testr.conf include ci-build include entry_points.ini include HACKING diff --git a/PKG-INFO b/PKG-INFO index 0c4cbb9..91cb643 100644 --- a/PKG-INFO +++ b/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: lava-tool -Version: 0.8.2 +Version: 0.10 Summary: Command line utility for Linaro validation services Home-page: https://launchpad.net/lava-tool Author: Zygmunt Krynicki diff --git a/ci-build b/ci-build index 714c5da..7e5df25 100755 --- a/ci-build +++ b/ci-build @@ -6,6 +6,11 @@ COVERAGE_REPORT_DIR="lava_tool_coverage" set -e +if which pep8 >/dev/null 2>&1; then + # check style before anything + pep8 --ignore E501,W291 lava* +fi + if test -z "$VIRTUAL_ENV"; then set -x virtualenv $VENV_DIR @@ -56,3 +61,9 @@ fi python-coverage run -m unittest lava_tool.tests.test_suite 2>/dev/null && python-coverage html ./integration-tests + +# if we reached this point we are good +set +x +echo +echo '\o/ all tests passed!' +echo diff --git a/entry_points.ini b/entry_points.ini index 2266d9e..069ea4e 100644 --- a/entry_points.ini +++ b/entry_points.ini @@ -14,6 +14,7 @@ init = lava.commands:init submit = lava.commands:submit run = lava.commands:run status = lava.job.commands:status +details = lava.job.commands:details update = lava.commands:update script = lava.script.commands:script @@ -25,6 +26,7 @@ resubmit-job = lava_scheduler_tool.commands:resubmit_job cancel-job = lava_scheduler_tool.commands:cancel_job job-output = lava_scheduler_tool.commands:job_output job-status = lava_scheduler_tool.commands:job_status +job-details = lava_scheduler_tool.commands:job_details backup=lava_dashboard_tool.commands:backup bundles=lava_dashboard_tool.commands:bundles data_views=lava_dashboard_tool.commands:data_views @@ -45,6 +47,7 @@ resubmit-job = lava_scheduler_tool.commands:resubmit_job cancel-job = lava_scheduler_tool.commands:cancel_job job-output = lava_scheduler_tool.commands:job_output job-status = lava_scheduler_tool.commands:job_status +job-details = lava_scheduler_tool.commands:job_details [lava.dashboard.commands] backup=lava_dashboard_tool.commands:backup @@ -80,12 +83,14 @@ version=lava_dashboard_tool.commands:version new = lava.job.commands:new submit = lava.job.commands:submit status = lava.job.commands:status +details = lava.job.commands:details run = lava.job.commands:run [lava.device.commands] add = lava.device.commands:add remove = lava.device.commands:remove config = lava.device.commands:config +list = lava.device.commands:list [lava.testdef.commands] new = lava.testdef.commands:new diff --git a/lava/device/commands.py b/lava/device/commands.py index a8ce66d..a3a790a 100644 --- a/lava/device/commands.py +++ b/lava/device/commands.py @@ -30,6 +30,7 @@ from lava.helper.command import ( from lava.helper.dispatcher import ( get_device_file, get_devices_path, + get_devices, ) from lava.tool.command import CommandGroup from lava.tool.errors import CommandError @@ -120,3 +121,12 @@ class config(BaseCommand): edit_file(device_conf) else: raise CommandError("Cannot edit file '{0}'".format(real_file_name)) + + +class list(BaseCommand): + """Lists configured devices.""" + + def invoke(self): + device_list = map(lambda d: d.hostname, get_devices()) + for device in sorted(device_list): + print device diff --git a/lava/device/tests/test_commands.py b/lava/device/tests/test_commands.py index 91b204f..22a652a 100644 --- a/lava/device/tests/test_commands.py +++ b/lava/device/tests/test_commands.py @@ -32,6 +32,7 @@ from lava.device.commands import ( add, config, remove, + list, ) from lava.helper.tests.helper_test import HelperTest from lava.tool.errors import CommandError @@ -180,3 +181,18 @@ class ConfigCommanTests(HelperTest): # Hopefully tests are not run as root. config_command = config(self.parser, self.args) self.assertRaises(CommandError, config_command.invoke) + + +class ListCommandTests(HelperTest): + + class FakeDevice(object): + def __init__(self, hostname): + self.hostname = hostname + + @patch('lava.device.commands.get_devices', create=True) + def test_list_devices(self, get_devices): + get_devices.return_value = [ListCommandTests.FakeDevice('foo'), ListCommandTests.FakeDevice('bar')] + command = list(self.parser, self.args) + command.invoke() + + get_devices.assert_any_call() diff --git a/lava/helper/command.py b/lava/helper/command.py index a990f29..8dc64e9 100644 --- a/lava/helper/command.py +++ b/lava/helper/command.py @@ -164,6 +164,22 @@ class BaseCommand(Command): except xmlrpclib.Fault, exc: raise CommandError(str(exc)) + def details(self, job_id): + """Retrieves the details of a LAVA job. + + :param job_id: The ID of the job to look up. + """ + job_id = str(job_id) + + try: + server = self.authenticated_server() + job_details = server.scheduler.job_details(job_id) + + print >> sys.stdout, "\nDetails of job {0}:\n".format(job_id) + print >> sys.stdout, job_details + except xmlrpclib.Fault, exc: + raise CommandError(str(exc)) + def create_tar_repo_job(self, job_file, testdef_file, tar_content): """Creates a job file based on the tar-repo template. diff --git a/lava/job/commands.py b/lava/job/commands.py index 9535320..cfb0560 100644 --- a/lava/job/commands.py +++ b/lava/job/commands.py @@ -105,3 +105,23 @@ class status(BaseCommand): super(status, self).status(self.args.JOB_ID) else: raise CommandError("It is necessary to specify a job id.") + + +class details(BaseCommand): + + """Retrieves the details of a job.""" + + @classmethod + def register_arguments(cls, parser): + super(details, cls).register_arguments(parser) + parser.add_argument("JOB_ID", + help=("Prints information about the provided " + "job id."), + nargs="?", + default=None) + + def invoke(self): + if self.args.JOB_ID: + super(details, self).details(self.args.JOB_ID) + else: + raise CommandError("It is necessary to specify a job id.") diff --git a/lava/tool/__init__.py b/lava/tool/__init__.py index 736d6f7..0f26dab 100644 --- a/lava/tool/__init__.py +++ b/lava/tool/__init__.py @@ -24,4 +24,4 @@ lava.tool Generic code for command line utilities for LAVA """ -__version__ = (0, 8, 2, "final", 0) +__version__ = (0, 10, 0, "final", 0) diff --git a/lava_scheduler_tool/commands.py b/lava_scheduler_tool/commands.py index 5844538..3529617 100644 --- a/lava_scheduler_tool/commands.py +++ b/lava_scheduler_tool/commands.py @@ -149,3 +149,25 @@ class job_status(Command): print "Job ID: %s\nJob Status: %s\nBundle SHA1: %s" % \ (str(self.args.JOB_ID), job_status['job_status'], job_status['bundle_sha1']) + + +class job_details(Command): + """ + Get job details, if it existed, from the scheduler. + """ + + @classmethod + def register_arguments(cls, parser): + super(job_details, cls).register_arguments(parser) + parser.add_argument("SERVER") + parser.add_argument("JOB_ID", + help="Job ID to find the details") + + def invoke(self): + server = AuthenticatingServerProxy( + self.args.SERVER, auth_backend=KeyringAuthBackend()) + job_details = server.scheduler.job_details(self.args.JOB_ID) + + print "Details of job {0}: \n".format(str(self.args.JOB_ID)) + for detail in job_details: + print "%s: %s" % (detail, job_details[detail]) diff --git a/lava_tool.egg-info/PKG-INFO b/lava_tool.egg-info/PKG-INFO index 0c4cbb9..91cb643 100644 --- a/lava_tool.egg-info/PKG-INFO +++ b/lava_tool.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: lava-tool -Version: 0.8.2 +Version: 0.10 Summary: Command line utility for Linaro validation services Home-page: https://launchpad.net/lava-tool Author: Zygmunt Krynicki diff --git a/lava_tool.egg-info/SOURCES.txt b/lava_tool.egg-info/SOURCES.txt index 4e164b3..d89f612 100644 --- a/lava_tool.egg-info/SOURCES.txt +++ b/lava_tool.egg-info/SOURCES.txt @@ -1,3 +1,6 @@ +.coveragerc +.testr.conf +COPYING HACKING INSTALL MANIFEST.in diff --git a/lava_tool.egg-info/entry_points.txt b/lava_tool.egg-info/entry_points.txt index 2266d9e..069ea4e 100644 --- a/lava_tool.egg-info/entry_points.txt +++ b/lava_tool.egg-info/entry_points.txt @@ -14,6 +14,7 @@ init = lava.commands:init submit = lava.commands:submit run = lava.commands:run status = lava.job.commands:status +details = lava.job.commands:details update = lava.commands:update script = lava.script.commands:script @@ -25,6 +26,7 @@ resubmit-job = lava_scheduler_tool.commands:resubmit_job cancel-job = lava_scheduler_tool.commands:cancel_job job-output = lava_scheduler_tool.commands:job_output job-status = lava_scheduler_tool.commands:job_status +job-details = lava_scheduler_tool.commands:job_details backup=lava_dashboard_tool.commands:backup bundles=lava_dashboard_tool.commands:bundles data_views=lava_dashboard_tool.commands:data_views @@ -45,6 +47,7 @@ resubmit-job = lava_scheduler_tool.commands:resubmit_job cancel-job = lava_scheduler_tool.commands:cancel_job job-output = lava_scheduler_tool.commands:job_output job-status = lava_scheduler_tool.commands:job_status +job-details = lava_scheduler_tool.commands:job_details [lava.dashboard.commands] backup=lava_dashboard_tool.commands:backup @@ -80,12 +83,14 @@ version=lava_dashboard_tool.commands:version new = lava.job.commands:new submit = lava.job.commands:submit status = lava.job.commands:status +details = lava.job.commands:details run = lava.job.commands:run [lava.device.commands] add = lava.device.commands:add remove = lava.device.commands:remove config = lava.device.commands:config +list = lava.device.commands:list [lava.testdef.commands] new = lava.testdef.commands:new diff --git a/lava_tool.egg-info/top_level.txt b/lava_tool.egg-info/top_level.txt index a2bffe4..d297271 100644 --- a/lava_tool.egg-info/top_level.txt +++ b/lava_tool.egg-info/top_level.txt @@ -1,4 +1,4 @@ +lava_scheduler_tool lava_dashboard_tool lava_tool -lava_scheduler_tool lava -- cgit v1.2.3