def update_tests_in_db(tests, dry_run=False, add_experimental=False, add_noncompliant=False, autotest_dir=None): """ Scans through all tests and add them to the database. This function invoked when -t supplied and for update_all. When test code is discovered in the file system new tests may be added @param tests: list of tests found in the filesystem. @param dry_run: not used at this time. @param add_experimental: add tests with experimental attribute set. @param add_noncompliant: attempt adding test with invalid control files. @param autotest_dir: prepended to path strings (see global_config.ini, COMMON, autotest_top_path). """ site_set_attributes_module = utils.import_site_module( __file__, 'autotest_lib.utils.site_test_importer_attributes') for test in tests: new_test = models.Test.objects.get_or_create( path=test.replace(autotest_dir, '').lstrip('/'))[0] logging.info("Processing %s", new_test.path) # Set the test's attributes data = tests[test] _set_attributes_clean(new_test, data) # Custom Attribute Update if site_set_attributes_module: site_set_attributes_module._set_attributes_custom(new_test, data) # This only takes place if --add-noncompliant is provided on the CLI if not new_test.name: test_new_test = test.split('/') if test_new_test[-1] == 'control': new_test.name = test_new_test[-2] else: control_name = "%s:%s" control_name %= (test_new_test[-2], test_new_test[-1]) new_test.name = control_name.replace('control.', '') # Experimental Check if not add_experimental and new_test.experimental: continue _log_or_execute(repr(new_test), new_test.save) add_label_dependencies(new_test) # save TestParameter for para_name in data.test_parameters: test_parameter = models.TestParameter.objects.get_or_create( test=new_test, name=para_name)[0] test_parameter.save()
Usage? Just run it. utils/build_externals.py """ import compileall, logging, os, shutil, sys, tempfile, time, urllib2 import subprocess, re try: import autotest.common as common except ImportError: import common from autotest_lib.client.common_lib import logging_config, logging_manager from autotest_lib.client.common_lib import utils from autotest_lib.utils import external_packages # bring in site packages as well utils.import_site_module(__file__, 'autotest_lib.utils.site_external_packages') # Where package source be fetched to relative to the top of the autotest tree. PACKAGE_DIR = 'ExternalSource' # Where packages will be installed to relative to the top of the autotest tree. INSTALL_DIR = 'site-packages' # Installs all packages, even if the system already has the version required INSTALL_ALL = False # Want to add more packages to fetch, build and install? See the class # definitions at the end of external_packages.py for examples of how to do it.
import httplib2, os, sys, traceback, cgi from django.http import HttpResponse, HttpResponsePermanentRedirect from django.http import HttpResponseServerError from django.template import Context, loader from autotest_lib.client.common_lib import utils from autotest_lib.frontend import views_common from autotest_lib.frontend.afe import models, rpc_handler, rpc_interface from autotest_lib.frontend.afe import rpc_utils moblab_rpc_interface = utils.import_site_module( __file__, 'autotest_lib.frontend.afe.moblab_rpc_interface', dummy=object()) # since moblab_rpc_interface is later in the list, its methods will # override those of rpc_interface rpc_handler_obj = rpc_handler.RpcHandler((rpc_interface, moblab_rpc_interface), document_module=rpc_interface) def handle_rpc(request): """Handle the RPC request. @param request: the RPC request. """ return rpc_handler_obj.handle_rpc_request(request) def rpc_documentation(request): """Return the rpc documentation. @param request: the RPC request.
This fetches external python libraries, builds them using your host's python and installs them under our own autotest/site-packages/ directory. Usage? Just run it. utils/build_externals.py """ import compileall, logging, os, shutil, sys, tempfile, time, urllib2 import subprocess, re import common from autotest_lib.client.common_lib import logging_config, logging_manager from autotest_lib.client.common_lib import utils from autotest_lib.utils import external_packages # bring in site packages as well utils.import_site_module(__file__, 'autotest_lib.utils.site_external_packages') # Where package source be fetched to relative to the top of the autotest tree. PACKAGE_DIR = 'ExternalSource' # Where packages will be installed to relative to the top of the autotest tree. INSTALL_DIR = 'site-packages' # Installs all packages, even if the system already has the version required INSTALL_ALL = False # Want to add more packages to fetch, build and install? See the class # definitions at the end of external_packages.py for examples of how to do it. class BuildExternalsLoggingConfig(logging_config.LoggingConfig):
import httplib2, sys, traceback, cgi from django.http import HttpResponse, HttpResponsePermanentRedirect from django.http import HttpResponseServerError from django.template import Context, loader from autotest_lib.client.common_lib import utils from autotest_lib.frontend import views_common from autotest_lib.frontend.afe import models, rpc_handler, rpc_interface from autotest_lib.frontend.afe import rpc_utils site_rpc_interface = utils.import_site_module(__file__, "autotest_lib.frontend.afe.site_rpc_interface", dummy=object()) # since site_rpc_interface is later in the list, its methods will override those # of rpc_interface rpc_handler_obj = rpc_handler.RpcHandler((rpc_interface, site_rpc_interface), document_module=rpc_interface) def handle_rpc(request): return rpc_handler_obj.handle_rpc_request(request) def rpc_documentation(request): return rpc_handler_obj.get_rpc_documentation() def model_documentation(request): model_names = ("Label", "Host", "Test", "User", "AclGroup", "Job", "AtomicGroup") return views_common.model_documentation(models, model_names) def redirect_with_extra_data(request, url, **kwargs):