KVM test: physical_resources_check: Initialize output
[autotest-zwu.git] / cli / site_readme.py
blob3abbe2b2d7aac025eda2c65eddef6bd6d50d5784
2 # Copyright 2008 Google Inc. All Rights Reserved.
4 """
5 If you need to change the default behavior of some atest commands, you
6 can create a site_<topic>.py file to subclass some of the classes from
7 <topic>.py.
9 The following example would prevent the creation of platform labels.
10 """
12 import inspect, new, sys
14 from autotest_lib.cli import topic_common, label
17 class site_label(label.label):
18 pass
21 class site_label_create(label.label_create):
22 """Disable the platform option
23 atest label create <labels>|--blist <file>"""
24 def __init__(self):
25 super(site_label_create, self).__init__()
26 self.parser.remove_option("--platform")
29 def parse(self):
30 (options, leftover) = super(site_label_create, self).parse()
31 self.is_platform = False
32 return (options, leftover)
35 # The following boiler plate code should be added at the end to create
36 # all the other site_<topic>_<action> classes that do not modify their
37 # <topic>_<action> super class.
39 # Any classes we don't override in label should be copied automatically
40 for cls in [getattr(label, n) for n in dir(label) if not n.startswith("_")]:
41 if not inspect.isclass(cls):
42 continue
43 cls_name = cls.__name__
44 site_cls_name = 'site_' + cls_name
45 if hasattr(sys.modules[__name__], site_cls_name):
46 continue
47 bases = (site_label, cls)
48 members = {'__doc__': cls.__doc__}
49 site_cls = new.classobj(site_cls_name, bases, members)
50 setattr(sys.modules[__name__], site_cls_name, site_cls)