Best Python code snippet using autotest_python
compile_gwt_clients.py
Source:compile_gwt_clients.py
...74 logging.error('Copying old client: %s', err)75 else:76 logging.error('Compiled directory is gone, something went wrong')77 return False78def compile_and_install_client(project_client, extra_args='',79 install_client=True):80 """Compile the client into a temporary directory, if successful81 call install_completed_client to install the new client.82 @param project_client: project.client pair e.g. autotest.AfeClient83 @param install_client: Boolean, if True install the clients84 @return True if install and compile was successful False if it failed85 """86 java_args = {}87 java_args['compile_dir'] = _TMP_COMPILE_DIR88 java_args['app_dir'] = _DEFAULT_APP_DIR89 java_args['gwt_dir'] = find_gwt_dir()90 java_args['extra_args'] = extra_args91 java_args['project_client'] = project_client92 cmd = _COMPILE_LINE % java_args93 logging.info('Compiling client %s', project_client)94 try:95 utils.run(cmd, verbose=True)96 if install_client:97 return install_completed_client(java_args['compile_dir'],98 project_client)99 return True100 except error.CmdError:101 logging.error('Error compiling %s, leaving old client', project_client)102 return False103def compile_all_projects(extra_args=''):104 """Compile all projects available as defined by enumerate_projects.105 @returns list of failed client installations106 """107 failed_clients = []108 for project,clients in enumerate_projects().iteritems():109 for client in clients:110 project_client = '%s.%s' % (project, client)111 if not compile_and_install_client(project_client, extra_args):112 failed_clients.append(project_client)113 return failed_clients114def print_projects():115 logging.info('Projects that can be compiled:')116 for project,clients in enumerate_projects().iteritems():117 for client in clients:118 logging.info('%s.%s', project, client)119def main():120 logging_manager.configure_logging(CompileClientsLoggingConfig(),121 verbose=True)122 parser = optparse.OptionParser()123 parser.add_option('-l', '--list-projects',124 action='store_true', dest='list_projects',125 default=False,126 help='List all projects and clients that can be compiled')127 parser.add_option('-a', '--compile-all',128 action='store_true', dest='compile_all',129 default=False,130 help='Compile all available projects and clients')131 parser.add_option('-c', '--compile',132 dest='compile_list', action='store',133 help='List of clients to compiled (e.g. -c "x.X c.C")')134 parser.add_option('-e', '--extra-args',135 dest='extra_args', action='store',136 default='',137 help='Extra arguments to pass to java')138 parser.add_option('-d', '--no-install', dest='install_client',139 action='store_false', default=True,140 help='Do not install the clients just compile them')141 options, args = parser.parse_args()142 if len(sys.argv) < 2:143 parser.print_help()144 sys.exit(0)145 elif options.list_projects:146 print_projects()147 sys.exit(0)148 elif options.compile_all and options.compile_list:149 logging.error('Options -c and -a are mutually exclusive')150 parser.print_help()151 sys.exit(1)152 failed_clients = []153 if options.compile_all:154 failed_clients = compile_all_projects(options.extra_args)155 elif options.compile_list:156 for client in options.compile_list.split():157 if not compile_and_install_client(client, options.extra_args,158 options.install_client):159 failed_clients.append(client)160 if os.path.exists(_TMP_COMPILE_DIR):161 shutil.rmtree(_TMP_COMPILE_DIR)162 if failed_clients:163 logging.error('The following clients failed: %s',164 '\n'.join(failed_clients))165 sys.exit(1)166if __name__ == '__main__':...
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!!