Best Python code snippet using autotest_python
kernelexpand.py
Source:kernelexpand.py
...89def url_accessible(url):90 status = os.system("wget --spider -q '%s'" % (url))91 #print url + ": status=%d" % (status)92 return status == 093def select_kernel_components(components):94 new_components = []95 for component in components:96 new_patches = []97 for patch in component:98 if url_accessible(patch):99 new_patches.append(patch)100 break101 if not len(new_patches):102 new_patches.append(component[-1])103 new_components.append(new_patches)104 return new_components105def expand_classic(kernel, mirrors):106 components = decompose_kernel(kernel)107 if mirrors:108 components = mirror_kernel_components(mirrors, components)109 components = select_kernel_components(components)110 patches = []111 for component in components:112 patches.append(component[0])113 return patches114if __name__ == '__main__':115 from optparse import OptionParser116 parser = OptionParser()117 parser.add_option("-m", "--mirror", type="string", dest="mirror",118 action="append", nargs=2, help="mirror prefix")119 parser.add_option("-v", "--no-validate", dest="validate",120 action="store_false", default=True, help="prune invalid entries")121 def usage():122 parser.print_help()123 sys.exit(1)124 options, args = parser.parse_args()125 # Check for a kernel version126 if len(args) != 1:127 usage()128 kernel = args[0]129 #mirrors = [130 # [ 'http://www.kernel.org/pub/linux/kernel/v2.4',131 # 'http://kernel.beaverton.ibm.com/mirror/v2.4' ],132 # [ 'http://www.kernel.org/pub/linux/kernel/v2.6',133 # 'http://kernel.beaverton.ibm.com/mirror/v2.6' ],134 # [ 'http://www.kernel.org/pub/linux/kernel/people/akpm/patches',135 # 'http://kernel.beaverton.ibm.com/mirror/akpm' ],136 #]137 mirrors = options.mirror138 try:139 components = decompose_kernel(kernel)140 except NameError, e:141 sys.stderr.write(e.args[0] + "\n")142 sys.exit(1)143 if mirrors:144 components = mirror_kernel_components(mirrors, components)145 if options.validate:146 components = select_kernel_components(components)147 # Dump them out.148 for component in components:...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!