How to use quiet method in localstack

Best Python code snippet using localstack_python

make_distrib.py

Source:make_distrib.py Github

copy

Full Screen

1# Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights2# reserved. Use of this source code is governed by a BSD-style license that3# can be found in the LICENSE file.4from date_util import *5from file_util import *6from make_cmake import process_cmake_template7from optparse import OptionParser8import os9import re10import shlex11import subprocess12import git_util as git13import sys14import tarfile15import zipfile16def create_zip_archive(input_dir):17 """ Creates a zip archive of the specified input directory. """18 zip_file = input_dir + '.zip'19 zf = zipfile.ZipFile(zip_file, 'w', zipfile.ZIP_DEFLATED, True)20 def addDir(dir):21 for f in os.listdir(dir):22 full_path = os.path.join(dir, f)23 if os.path.isdir(full_path):24 addDir(full_path)25 else:26 zf.write(full_path, os.path.relpath(full_path, \27 os.path.join(input_dir, os.pardir)))28 addDir(input_dir)29 zf.close()30def create_tar_archive(input_dir, format):31 """ Creates a tar archive of the specified input directory. """32 # Supported formats include "gz" and "bz2".33 tar_file = input_dir + '.tar.' + format34 tf = tarfile.open(tar_file, "w:" + format)35 tf.add(input_dir, arcname=os.path.basename(input_dir))36 tf.close()37def create_7z_archive(input_dir, format):38 """ Creates a 7z archive of the specified input directory. """39 # CEF_COMMAND_7ZIP might be "c:\Program Files (x86)\7Zip\7z.exe" or /usr/bin/7za40 # or simply 7z if the user knows that it's in the PATH var. Supported formats41 # depend on the 7za version -- check the 7-zip documentation for details.42 command = os.environ['CEF_COMMAND_7ZIP']43 working_dir = os.path.abspath(os.path.join(input_dir, os.pardir))44 tar_file = None45 if format in ('xz', 'gzip', 'bzip2'):46 # These formats only support one file per archive. Create a tar file first.47 tar_file = input_dir + '.tar'48 run('"%s" a -ttar -y %s %s' % (command, tar_file, input_dir), working_dir)49 zip_file = tar_file + '.' + format50 zip_input = tar_file51 else:52 zip_file = input_dir + '.' + format53 zip_input = input_dir54 # Create the compressed archive.55 run('"%s" a -t%s -y %s %s' % (command, format, zip_file, zip_input), working_dir)56 if not tar_file is None:57 remove_file(tar_file)58def create_output_dir(name, parent_dir):59 """ Creates an output directory and adds the path to the archive list. """60 output_dir = os.path.abspath(os.path.join(parent_dir, name))61 remove_dir(output_dir, options.quiet)62 make_dir(output_dir, options.quiet)63 archive_dirs.append(output_dir)64 return output_dir65def get_readme_component(name):66 """ Loads a README file component. """67 paths = []68 # platform directory69 if platform == 'windows':70 platform_cmp = 'win'71 elif platform == 'macosx':72 platform_cmp = 'mac'73 elif platform == 'linux':74 platform_cmp = 'linux'75 paths.append(os.path.join(script_dir, 'distrib', platform_cmp))76 # shared directory77 paths.append(os.path.join(script_dir, 'distrib'))78 # load the file if it exists79 for path in paths:80 file = os.path.join(path, 'README.' +name + '.txt')81 if path_exists(file):82 return read_file(file)83 raise Exception('Readme component not found: ' + name)84def create_readme():85 """ Creates the README.TXT file. """86 # gather the components87 header_data = get_readme_component('header')88 mode_data = get_readme_component(mode)89 redistrib_data = get_readme_component('redistrib')90 footer_data = get_readme_component('footer')91 # format the file92 data = header_data + '\n\n' + mode_data + '\n\n' + redistrib_data + '\n\n' + footer_data93 data = data.replace('$CEF_URL$', cef_url)94 data = data.replace('$CEF_REV$', cef_rev)95 data = data.replace('$CEF_VER$', cef_ver)96 data = data.replace('$CHROMIUM_URL$', chromium_url)97 data = data.replace('$CHROMIUM_REV$', chromium_rev)98 data = data.replace('$CHROMIUM_VER$', chromium_ver)99 data = data.replace('$DATE$', date)100 if platform == 'windows':101 platform_str = 'Windows'102 elif platform == 'macosx':103 platform_str = 'Mac OS-X'104 elif platform == 'linux':105 platform_str = 'Linux'106 data = data.replace('$PLATFORM$', platform_str)107 if mode == 'standard':108 distrib_type = 'Standard'109 distrib_desc = 'This distribution contains all components necessary to build and distribute an\n' \110 'application using CEF on the ' + platform_str + ' platform. Please see the LICENSING\n' \111 'section of this document for licensing terms and conditions.'112 elif mode == 'minimal':113 distrib_type = 'Minimal'114 distrib_desc = 'This distribution contains the minimial components necessary to build and\n' \115 'distribute an application using CEF on the ' + platform_str + ' platform. Please see\n' \116 'the LICENSING section of this document for licensing terms and conditions.'117 elif mode == 'client':118 distrib_type = 'Client'119 if platform == 'linux':120 client_app = 'cefsimple'121 else:122 client_app = 'cefclient'123 distrib_desc = 'This distribution contains a release build of the ' + client_app + ' sample application\n' \124 'for the ' + platform_str + ' platform. Please see the LICENSING section of this document for\n' \125 'licensing terms and conditions.'126 data = data.replace('$DISTRIB_TYPE$', distrib_type)127 data = data.replace('$DISTRIB_DESC$', distrib_desc)128 write_file(os.path.join(output_dir, 'README.txt'), data)129 if not options.quiet:130 sys.stdout.write('Creating README.TXT file.\n')131def create_fuzed_gtest(tests_dir):132 """ Generate a fuzed version of gtest and build the expected directory structure. """133 src_gtest_dir = os.path.join(src_dir, 'testing', 'gtest')134 run('%s fuse_gtest_files.py \"%s\"' % (sys.executable, tests_dir),135 os.path.join(src_gtest_dir, 'scripts'))136 if not options.quiet:137 sys.stdout.write('Building gtest directory structure.\n')138 target_gtest_dir = os.path.join(tests_dir, 'gtest')139 gtest_header = os.path.join(target_gtest_dir, 'gtest.h')140 gtest_cpp = os.path.join(target_gtest_dir, 'gtest-all.cc')141 if not os.path.exists(gtest_header):142 raise Exception('Generated file not found: %s' % gtest_header)143 if not os.path.exists(gtest_cpp):144 raise Exception('Generated file not found: %s' % gtest_cpp)145 # gtest header file at tests/gtest/include/gtest/gtest.h146 target_gtest_header_dir = os.path.join(target_gtest_dir, 'include', 'gtest')147 make_dir(target_gtest_header_dir, options.quiet)148 move_file(gtest_header, target_gtest_header_dir, options.quiet)149 # gtest source file at tests/gtest/src/gtest-all.cc150 target_gtest_cpp_dir = os.path.join(target_gtest_dir, 'src')151 make_dir(target_gtest_cpp_dir, options.quiet)152 move_file(gtest_cpp, target_gtest_cpp_dir, options.quiet)153 # gtest LICENSE file at tests/gtest/LICENSE154 copy_file(os.path.join(src_gtest_dir, 'LICENSE'), target_gtest_dir, options.quiet)155 # CEF README file at tests/gtest/README.cef156 copy_file(os.path.join(cef_dir, 'tests', 'gtest', 'README.cef.in'),157 os.path.join(target_gtest_dir, 'README.cef'), options.quiet)158def transfer_gypi_files(src_dir, gypi_paths, gypi_path_prefix, dst_dir, quiet):159 """ Transfer files from one location to another. """160 for path in gypi_paths:161 src = os.path.join(src_dir, path)162 dst = os.path.join(dst_dir, path.replace(gypi_path_prefix, ''))163 dst_path = os.path.dirname(dst)164 make_dir(dst_path, quiet)165 copy_file(src, dst, quiet)166def normalize_headers(file, new_path = ''):167 """ Normalize headers post-processing. Remove the path component from any168 project include directives. """169 data = read_file(file)170 data = re.sub(r'''#include \"(?!include\/)[a-zA-Z0-9_\/]+\/+([a-zA-Z0-9_\.]+)\"''', \171 "// Include path modified for CEF Binary Distribution.\n#include \""+new_path+"\\1\"", data)172 write_file(file, data)173def eval_transfer_file(cef_dir, script_dir, transfer_cfg, output_dir, quiet):174 """ Transfer files based on the specified configuration. """175 if not path_exists(transfer_cfg):176 return177 configs = eval_file(transfer_cfg)178 for cfg in configs:179 dst = os.path.join(output_dir, cfg['target'])180 # perform a copy if source is specified181 if not cfg['source'] is None:182 src = os.path.join(cef_dir, cfg['source'])183 dst_path = os.path.dirname(dst)184 make_dir(dst_path, quiet)185 copy_file(src, dst, quiet)186 # place a readme file in the destination directory187 readme = os.path.join(dst_path, 'README-TRANSFER.txt')188 if not path_exists(readme):189 copy_file(os.path.join(script_dir, 'distrib/README-TRANSFER.txt'), readme)190 open(readme, 'ab').write(cfg['source']+"\n")191 # perform any required post-processing192 if 'post-process' in cfg:193 post = cfg['post-process']194 if post == 'normalize_headers':195 new_path = ''196 if cfg.has_key('new_header_path'):197 new_path = cfg['new_header_path']198 normalize_headers(dst, new_path)199def transfer_files(cef_dir, script_dir, transfer_cfg_dir, mode, output_dir, quiet):200 # Non-mode-specific transfers.201 transfer_cfg = os.path.join(transfer_cfg_dir, 'transfer.cfg')202 eval_transfer_file(cef_dir, script_dir, transfer_cfg, output_dir, quiet)203 # Mode-specific transfers.204 transfer_cfg = os.path.join(transfer_cfg_dir, 'transfer_%s.cfg' % mode)205 eval_transfer_file(cef_dir, script_dir, transfer_cfg, output_dir, quiet)206def combine_libs(build_dir, libs, dest_lib):207 """ Combine multiple static libraries into a single static library. """208 cmdline = 'msvs_env.bat win%s python combine_libs.py -o "%s"' % (platform_arch, dest_lib)209 for lib in libs:210 lib_path = os.path.join(build_dir, lib)211 for path in get_files(lib_path): # Expand wildcards in |lib_path|.212 if not path_exists(path):213 raise Exception('File not found: ' + path)214 cmdline = cmdline + ' "%s"' % path215 run(cmdline, os.path.join(cef_dir, 'tools'))216def run(command_line, working_dir):217 """ Run a command. """218 sys.stdout.write('-------- Running "'+command_line+'" in "'+\219 working_dir+'"...'+"\n")220 args = shlex.split(command_line.replace('\\', '\\\\'))221 return subprocess.check_call(args, cwd=working_dir, env=os.environ,222 shell=(sys.platform == 'win32'))223# cannot be loaded as a module224if __name__ != "__main__":225 sys.stderr.write('This file cannot be loaded as a module!')226 sys.exit()227# parse command-line options228disc = """229This utility builds the CEF Binary Distribution.230"""231parser = OptionParser(description=disc)232parser.add_option('--output-dir', dest='outputdir', metavar='DIR',233 help='output directory [required]')234parser.add_option('--distrib-subdir', dest='distribsubdir',235 help='name of the subdirectory for the distribution',236 default='')237parser.add_option('--allow-partial',238 action='store_true', dest='allowpartial', default=False,239 help='allow creation of partial distributions')240parser.add_option('--no-symbols',241 action='store_true', dest='nosymbols', default=False,242 help='don\'t create symbol files')243parser.add_option('--no-docs',244 action='store_true', dest='nodocs', default=False,245 help='don\'t create documentation')246parser.add_option('--no-archive',247 action='store_true', dest='noarchive', default=False,248 help='don\'t create archives for output directories')249parser.add_option('--ninja-build',250 action='store_true', dest='ninjabuild', default=False,251 help='build was created using ninja')252parser.add_option('--x64-build',253 action='store_true', dest='x64build', default=False,254 help='create a 64-bit binary distribution')255parser.add_option('--arm-build',256 action='store_true', dest='armbuild', default=False,257 help='create an ARM binary distribution')258parser.add_option('--minimal',259 action='store_true', dest='minimal', default=False,260 help='include only release build binary files')261parser.add_option('--client',262 action='store_true', dest='client', default=False,263 help='include only the sample application')264parser.add_option('-q', '--quiet',265 action='store_true', dest='quiet', default=False,266 help='do not output detailed status information')267(options, args) = parser.parse_args()268# Test the operating system.269platform = '';270if sys.platform == 'win32':271 platform = 'windows'272elif sys.platform == 'darwin':273 platform = 'macosx'274elif sys.platform.startswith('linux'):275 platform = 'linux'276# the outputdir option is required277if options.outputdir is None:278 parser.print_help(sys.stderr)279 sys.exit()280if options.minimal and options.client:281 print 'Cannot specify both --minimal and --client'282 parser.print_help(sys.stderr)283 sys.exit()284if options.x64build and options.armbuild:285 print 'Cannot specify both --x64-build and --arm-build'286 parser.print_help(sys.stderr)287 sys.exit()288if options.armbuild and platform != 'linux':289 print '--arm-build is only supported on Linux.'290 sys.exit()291if not options.ninjabuild:292 print 'Ninja build is required on all platforms'293 sys.exit()294# script directory295script_dir = os.path.dirname(__file__)296# CEF root directory297cef_dir = os.path.abspath(os.path.join(script_dir, os.pardir))298# src directory299src_dir = os.path.abspath(os.path.join(cef_dir, os.pardir))300if not git.is_checkout(cef_dir):301 raise Exception('Not a valid checkout: %s' % (cef_dir))302# retrieve information for CEF303cef_url = git.get_url(cef_dir)304cef_rev = git.get_hash(cef_dir)305cef_commit_number = git.get_commit_number(cef_dir)306if not git.is_checkout(src_dir):307 raise Exception('Not a valid checkout: %s' % (src_dir))308# retrieve information for Chromium309chromium_url = git.get_url(src_dir)310chromium_rev = git.get_hash(src_dir)311date = get_date()312# Read and parse the version file (key=value pairs, one per line)313args = {}314read_version_file(os.path.join(cef_dir, 'VERSION'), args)315read_version_file(os.path.join(cef_dir, '../chrome/VERSION'), args)316cef_ver = '%s.%s.%s.g%s' % (args['CEF_MAJOR'], args['BUILD'], cef_commit_number, cef_rev[:7])317chromium_ver = args['MAJOR']+'.'+args['MINOR']+'.'+args['BUILD']+'.'+args['PATCH']318# list of output directories to be archived319archive_dirs = []320if options.x64build:321 platform_arch = '64'322elif options.armbuild:323 platform_arch = 'arm'324else:325 platform_arch = '32'326# output directory327output_dir_base = 'cef_binary_' + cef_ver328if options.distribsubdir == '':329 output_dir_name = output_dir_base + '_' + platform + platform_arch330else:331 output_dir_name = options.distribsubdir332if options.minimal:333 mode = 'minimal'334 output_dir_name = output_dir_name + '_minimal'335elif options.client:336 mode = 'client'337 output_dir_name = output_dir_name + '_client'338else:339 mode = 'standard'340output_dir = create_output_dir(output_dir_name, options.outputdir)341# create the README.TXT file342create_readme()343# transfer the LICENSE.txt file344copy_file(os.path.join(cef_dir, 'LICENSE.txt'), output_dir, options.quiet)345# read the variables list from the autogenerated cef_paths.gypi file346cef_paths = eval_file(os.path.join(cef_dir, 'cef_paths.gypi'))347cef_paths = cef_paths['variables']348# read the variables list from the manually edited cef_paths2.gypi file349cef_paths2 = eval_file(os.path.join(cef_dir, 'cef_paths2.gypi'))350cef_paths2 = cef_paths2['variables']351# Determine the build directory suffix. CEF uses a consistent directory naming352# scheme for GN via GetAllPlatformConfigs in gn_args.py.353if options.x64build:354 build_dir_suffix = '_GN_x64'355elif options.armbuild:356 build_dir_suffix = '_GN_arm'357else:358 build_dir_suffix = '_GN_x86'359# Determine the build directory paths.360out_dir = os.path.join(src_dir, 'out')361build_dir_debug = os.path.join(out_dir, 'Debug' + build_dir_suffix)362build_dir_release = os.path.join(out_dir, 'Release' + build_dir_suffix)363if mode == 'standard' or mode == 'minimal':364 # create the include directory365 include_dir = os.path.join(output_dir, 'include')366 make_dir(include_dir, options.quiet)367 # create the cmake directory368 cmake_dir = os.path.join(output_dir, 'cmake')369 make_dir(cmake_dir, options.quiet)370 # create the libcef_dll_wrapper directory371 libcef_dll_dir = os.path.join(output_dir, 'libcef_dll')372 make_dir(libcef_dll_dir, options.quiet)373 # transfer common include files374 transfer_gypi_files(cef_dir, cef_paths2['includes_common'], \375 'include/', include_dir, options.quiet)376 transfer_gypi_files(cef_dir, cef_paths2['includes_capi'], \377 'include/', include_dir, options.quiet)378 transfer_gypi_files(cef_dir, cef_paths2['includes_wrapper'], \379 'include/', include_dir, options.quiet)380 transfer_gypi_files(cef_dir, cef_paths['autogen_cpp_includes'], \381 'include/', include_dir, options.quiet)382 transfer_gypi_files(cef_dir, cef_paths['autogen_capi_includes'], \383 'include/', include_dir, options.quiet)384 # Transfer generated include files.385 generated_includes = [386 'cef_pack_resources.h',387 'cef_pack_strings.h',388 ]389 for include in generated_includes:390 # Debug and Release build should be the same so grab whichever exists.391 src_path = os.path.join(build_dir_release, 'includes', 'include', include)392 if not os.path.exists(src_path):393 src_path = os.path.join(build_dir_debug, 'includes', 'include', include)394 if not os.path.exists(src_path):395 raise Exception('Missing generated header file: %s' % include)396 copy_file(src_path, os.path.join(include_dir, include), options.quiet)397 # transfer common libcef_dll_wrapper files398 transfer_gypi_files(cef_dir, cef_paths2['libcef_dll_wrapper_sources_base'], \399 'libcef_dll/', libcef_dll_dir, options.quiet)400 transfer_gypi_files(cef_dir, cef_paths2['libcef_dll_wrapper_sources_common'], \401 'libcef_dll/', libcef_dll_dir, options.quiet)402 transfer_gypi_files(cef_dir, cef_paths['autogen_client_side'], \403 'libcef_dll/', libcef_dll_dir, options.quiet)404 # transfer additional files405 transfer_files(cef_dir, script_dir, os.path.join(script_dir, 'distrib'), \406 mode, output_dir, options.quiet)407 # process cmake templates408 variables = dict(cef_paths.items() + cef_paths2.items())409 process_cmake_template(os.path.join(cef_dir, 'CMakeLists.txt.in'), \410 os.path.join(output_dir, 'CMakeLists.txt'), \411 variables, options.quiet)412 process_cmake_template(os.path.join(cef_dir, 'cmake', 'cef_macros.cmake.in'), \413 os.path.join(cmake_dir, 'cef_macros.cmake'), \414 variables, options.quiet)415 process_cmake_template(os.path.join(cef_dir, 'cmake', 'cef_variables.cmake.in'), \416 os.path.join(cmake_dir, 'cef_variables.cmake'), \417 variables, options.quiet)418 process_cmake_template(os.path.join(cef_dir, 'cmake', 'FindCEF.cmake.in'), \419 os.path.join(cmake_dir, 'FindCEF.cmake'), \420 variables, options.quiet)421 process_cmake_template(os.path.join(cef_dir, 'libcef_dll', 'CMakeLists.txt.in'), \422 os.path.join(libcef_dll_dir, 'CMakeLists.txt'), \423 variables, options.quiet)424if mode == 'standard':425 # create the tests directory426 tests_dir = os.path.join(output_dir, 'tests')427 make_dir(tests_dir, options.quiet)428 # create the tests/shared directory429 shared_dir = os.path.join(tests_dir, 'shared')430 make_dir(shared_dir, options.quiet)431 # create the tests/cefclient directory432 cefclient_dir = os.path.join(tests_dir, 'cefclient')433 make_dir(cefclient_dir, options.quiet)434 # create the tests/cefsimple directory435 cefsimple_dir = os.path.join(tests_dir, 'cefsimple')436 make_dir(cefsimple_dir, options.quiet)437 # create the tests/ceftests directory438 ceftests_dir = os.path.join(tests_dir, 'ceftests')439 make_dir(ceftests_dir, options.quiet)440 # transfer common shared files441 transfer_gypi_files(cef_dir, cef_paths2['shared_sources_browser'], \442 'tests/shared/', shared_dir, options.quiet)443 transfer_gypi_files(cef_dir, cef_paths2['shared_sources_common'], \444 'tests/shared/', shared_dir, options.quiet)445 transfer_gypi_files(cef_dir, cef_paths2['shared_sources_renderer'], \446 'tests/shared/', shared_dir, options.quiet)447 transfer_gypi_files(cef_dir, cef_paths2['shared_sources_resources'], \448 'tests/shared/', shared_dir, options.quiet)449 # transfer common cefclient files450 transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_browser'], \451 'tests/cefclient/', cefclient_dir, options.quiet)452 transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_common'], \453 'tests/cefclient/', cefclient_dir, options.quiet)454 transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_renderer'], \455 'tests/cefclient/', cefclient_dir, options.quiet)456 transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_resources'], \457 'tests/cefclient/', cefclient_dir, options.quiet)458 # transfer common cefsimple files459 transfer_gypi_files(cef_dir, cef_paths2['cefsimple_sources_common'], \460 'tests/cefsimple/', cefsimple_dir, options.quiet)461 # transfer common ceftests files462 transfer_gypi_files(cef_dir, cef_paths2['ceftests_sources_common'], \463 'tests/ceftests/', ceftests_dir, options.quiet)464 # create the fuzed gtest version465 create_fuzed_gtest(tests_dir)466 # process cmake templates467 process_cmake_template(os.path.join(cef_dir, 'tests', 'cefclient', 'CMakeLists.txt.in'), \468 os.path.join(cefclient_dir, 'CMakeLists.txt'), \469 variables, options.quiet)470 process_cmake_template(os.path.join(cef_dir, 'tests', 'cefsimple', 'CMakeLists.txt.in'), \471 os.path.join(cefsimple_dir, 'CMakeLists.txt'), \472 variables, options.quiet)473 process_cmake_template(os.path.join(cef_dir, 'tests', 'gtest', 'CMakeLists.txt.in'), \474 os.path.join(tests_dir, 'gtest', 'CMakeLists.txt'), \475 variables, options.quiet)476 process_cmake_template(os.path.join(cef_dir, 'tests', 'ceftests', 'CMakeLists.txt.in'), \477 os.path.join(ceftests_dir, 'CMakeLists.txt'), \478 variables, options.quiet)479 # transfer gypi files480 copy_file(os.path.join(cef_dir, 'cef_paths.gypi'), \481 os.path.join(output_dir, 'cef_paths.gypi'), options.quiet)482 copy_file(os.path.join(cef_dir, 'cef_paths2.gypi'), \483 os.path.join(output_dir, 'cef_paths2.gypi'), options.quiet)484if platform == 'windows':485 binaries = [486 'chrome_elf.dll',487 'd3dcompiler_47.dll',488 'libcef.dll',489 'libEGL.dll',490 'libGLESv2.dll',491 'natives_blob.bin',492 'snapshot_blob.bin',493 # Should match the output path from media/cdm/ppapi/cdm_paths.gni.494 'WidevineCdm\\_platform_specific\\win_%s\\widevinecdmadapter.dll' % \495 ('x64' if options.x64build else 'x86'),496 ]497 libcef_dll_file = 'libcef.dll.lib'498 sandbox_libs = [499 'obj\\base\\allocator\\unified_allocator_shim\\*.obj',500 'obj\\base\\base.lib',501 'obj\\base\\base_static.lib',502 'obj\\base\\third_party\\dynamic_annotations\\dynamic_annotations.lib',503 'obj\\cef\\cef_sandbox.lib',504 'obj\\sandbox\\win\\sandbox.lib',505 ]506 valid_build_dir = None507 if mode == 'standard':508 # transfer Debug files509 build_dir = build_dir_debug510 if not options.allowpartial or path_exists(os.path.join(build_dir, 'libcef.dll')):511 valid_build_dir = build_dir512 dst_dir = os.path.join(output_dir, 'Debug')513 make_dir(dst_dir, options.quiet)514 copy_files(os.path.join(script_dir, 'distrib/win/*.dll'), dst_dir, options.quiet)515 for binary in binaries:516 copy_file(os.path.join(build_dir, binary), os.path.join(dst_dir, os.path.basename(binary)), options.quiet)517 copy_file(os.path.join(build_dir, libcef_dll_file), os.path.join(dst_dir, 'libcef.lib'), \518 options.quiet)519 combine_libs(build_dir, sandbox_libs, os.path.join(dst_dir, 'cef_sandbox.lib'));520 if not options.nosymbols:521 # create the symbol output directory522 symbol_output_dir = create_output_dir(output_dir_name + '_debug_symbols', options.outputdir)523 # transfer contents524 copy_file(os.path.join(build_dir, 'libcef.dll.pdb'), symbol_output_dir, options.quiet)525 else:526 sys.stderr.write("No Debug build files.\n")527 # transfer Release files528 build_dir = build_dir_release529 if not options.allowpartial or path_exists(os.path.join(build_dir, 'libcef.dll')):530 valid_build_dir = build_dir531 dst_dir = os.path.join(output_dir, 'Release')532 make_dir(dst_dir, options.quiet)533 copy_files(os.path.join(script_dir, 'distrib/win/*.dll'), dst_dir, options.quiet)534 for binary in binaries:535 copy_file(os.path.join(build_dir, binary), os.path.join(dst_dir, os.path.basename(binary)), options.quiet)536 if mode != 'client':537 copy_file(os.path.join(build_dir, libcef_dll_file), os.path.join(dst_dir, 'libcef.lib'), \538 options.quiet)539 combine_libs(build_dir, sandbox_libs, os.path.join(dst_dir, 'cef_sandbox.lib'));540 else:541 copy_file(os.path.join(build_dir, 'cefclient.exe'), dst_dir, options.quiet)542 if not options.nosymbols:543 # create the symbol output directory544 symbol_output_dir = create_output_dir(output_dir_name + '_release_symbols', options.outputdir)545 # transfer contents546 copy_file(os.path.join(build_dir, 'libcef.dll.pdb'), symbol_output_dir, options.quiet)547 else:548 sys.stderr.write("No Release build files.\n")549 if not valid_build_dir is None:550 # transfer resource files551 build_dir = valid_build_dir552 if mode == 'client':553 dst_dir = os.path.join(output_dir, 'Release')554 else:555 dst_dir = os.path.join(output_dir, 'Resources')556 make_dir(dst_dir, options.quiet)557 copy_file(os.path.join(build_dir, 'cef.pak'), dst_dir, options.quiet)558 copy_file(os.path.join(build_dir, 'cef_100_percent.pak'), dst_dir, options.quiet)559 copy_file(os.path.join(build_dir, 'cef_200_percent.pak'), dst_dir, options.quiet)560 copy_file(os.path.join(build_dir, 'cef_extensions.pak'), dst_dir, options.quiet)561 copy_file(os.path.join(build_dir, 'devtools_resources.pak'), dst_dir, options.quiet)562 copy_file(os.path.join(build_dir, 'icudtl.dat'), dst_dir, options.quiet)563 copy_dir(os.path.join(build_dir, 'locales'), os.path.join(dst_dir, 'locales'), options.quiet)564 if mode == 'standard' or mode == 'minimal':565 # transfer include files566 transfer_gypi_files(cef_dir, cef_paths2['includes_win'], \567 'include/', include_dir, options.quiet)568 # transfer additional files, if any569 transfer_files(cef_dir, script_dir, os.path.join(script_dir, 'distrib', 'win'), \570 mode, output_dir, options.quiet)571 if mode == 'standard':572 # transfer shared files573 transfer_gypi_files(cef_dir, cef_paths2['shared_sources_win'], \574 'tests/shared/', shared_dir, options.quiet)575 # transfer cefclient files576 transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_win'], \577 'tests/cefclient/', cefclient_dir, options.quiet)578 # transfer cefsimple files579 transfer_gypi_files(cef_dir, cef_paths2['cefsimple_sources_win'], \580 'tests/cefsimple/', cefsimple_dir, options.quiet)581 # transfer ceftests files582 transfer_gypi_files(cef_dir, cef_paths2['ceftests_sources_win'], \583 'tests/ceftests/', ceftests_dir, options.quiet)584 transfer_gypi_files(cef_dir, cef_paths2['ceftests_sources_views'], \585 'tests/ceftests/', ceftests_dir, options.quiet)586 if not options.nodocs:587 # generate doc files588 os.popen('make_cppdocs.bat '+cef_rev)589 src_dir = os.path.join(cef_dir, 'docs')590 if path_exists(src_dir):591 # create the docs output directory592 docs_output_dir = create_output_dir(output_dir_base + '_docs', options.outputdir)593 # transfer contents594 copy_dir(src_dir, docs_output_dir, options.quiet)595elif platform == 'macosx':596 valid_build_dir = None597 framework_name = 'Chromium Embedded Framework'598 if mode == 'standard':599 # transfer Debug files600 build_dir = build_dir_debug601 if not options.allowpartial or path_exists(os.path.join(build_dir, 'cefclient.app')):602 valid_build_dir = build_dir603 dst_dir = os.path.join(output_dir, 'Debug')604 make_dir(dst_dir, options.quiet)605 copy_dir(os.path.join(build_dir, 'cefclient.app/Contents/Frameworks/%s.framework' % framework_name), \606 os.path.join(dst_dir, '%s.framework' % framework_name), options.quiet)607 copy_file(os.path.join(script_dir, 'distrib/mac/widevinecdmadapter.plugin'), dst_dir, options.quiet)608 if not options.nosymbols:609 # create the symbol output directory610 symbol_output_dir = create_output_dir(output_dir_name + '_debug_symbols', options.outputdir)611 # The real dSYM already exists, just copy it to the output directory.612 # dSYMs are only generated when is_official_build=true or enable_dsyms=true.613 # See //build/config/mac/symbols.gni.614 copy_dir(os.path.join(build_dir, '%s.dSYM' % framework_name),615 os.path.join(symbol_output_dir, '%s.dSYM' % framework_name), options.quiet)616 # transfer Release files617 build_dir = build_dir_release618 if not options.allowpartial or path_exists(os.path.join(build_dir, 'cefclient.app')):619 valid_build_dir = build_dir620 dst_dir = os.path.join(output_dir, 'Release')621 make_dir(dst_dir, options.quiet)622 if mode != 'client':623 copy_dir(os.path.join(build_dir, 'cefclient.app/Contents/Frameworks/%s.framework' % framework_name), \624 os.path.join(dst_dir, '%s.framework' % framework_name), options.quiet)625 copy_file(os.path.join(script_dir, 'distrib/mac/widevinecdmadapter.plugin'), dst_dir, options.quiet)626 else:627 copy_dir(os.path.join(build_dir, 'cefclient.app'), os.path.join(dst_dir, 'cefclient.app'), options.quiet)628 if not options.nosymbols:629 # create the symbol output directory630 symbol_output_dir = create_output_dir(output_dir_name + '_release_symbols', options.outputdir)631 # The real dSYM already exists, just copy it to the output directory.632 # dSYMs are only generated when is_official_build=true or enable_dsyms=true.633 # See //build/config/mac/symbols.gni.634 copy_dir(os.path.join(build_dir, '%s.dSYM' % framework_name),635 os.path.join(symbol_output_dir, '%s.dSYM' % framework_name), options.quiet)636 if mode == 'standard' or mode == 'minimal':637 # transfer include files638 transfer_gypi_files(cef_dir, cef_paths2['includes_mac'], \639 'include/', include_dir, options.quiet)640 # transfer additional files, if any641 transfer_files(cef_dir, script_dir, os.path.join(script_dir, 'distrib', 'mac'), \642 mode, output_dir, options.quiet)643 if mode == 'standard':644 # transfer shared files645 transfer_gypi_files(cef_dir, cef_paths2['shared_sources_mac'], \646 'tests/shared/', shared_dir, options.quiet)647 transfer_gypi_files(cef_dir, cef_paths2['shared_sources_mac_helper'], \648 'tests/shared/', shared_dir, options.quiet)649 # transfer cefclient files650 transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_mac'], \651 'tests/cefclient/', cefclient_dir, options.quiet)652 # transfer cefclient/resources/mac files653 copy_dir(os.path.join(cef_dir, 'tests/cefclient/resources/mac'), \654 os.path.join(cefclient_dir, 'resources/mac'), \655 options.quiet)656 # transfer cefsimple files657 transfer_gypi_files(cef_dir, cef_paths2['cefsimple_sources_mac'], \658 'tests/cefsimple/', cefsimple_dir, options.quiet)659 transfer_gypi_files(cef_dir, cef_paths2['cefsimple_sources_mac_helper'], \660 'tests/cefsimple/', cefsimple_dir, options.quiet)661 # transfer cefsimple/mac files662 copy_dir(os.path.join(cef_dir, 'tests/cefsimple/mac'), \663 os.path.join(cefsimple_dir, 'mac'), \664 options.quiet)665 # transfer ceftests files666 transfer_gypi_files(cef_dir, cef_paths2['ceftests_sources_mac'], \667 'tests/ceftests/', ceftests_dir, options.quiet)668 transfer_gypi_files(cef_dir, cef_paths2['ceftests_sources_mac_helper'], \669 'tests/ceftests/', ceftests_dir, options.quiet)670 # transfer ceftests/resources/mac files671 copy_dir(os.path.join(cef_dir, 'tests/ceftests/resources/mac'), \672 os.path.join(ceftests_dir, 'resources/mac'), \673 options.quiet)674elif platform == 'linux':675 valid_build_dir = None676 if mode == 'standard':677 # transfer Debug files678 build_dir = build_dir_debug679 libcef_path = os.path.join(build_dir, 'libcef.so')680 if not options.allowpartial or path_exists(libcef_path):681 valid_build_dir = build_dir682 dst_dir = os.path.join(output_dir, 'Debug')683 make_dir(dst_dir, options.quiet)684 copy_file(os.path.join(build_dir, 'chrome_sandbox'), os.path.join(dst_dir, 'chrome-sandbox'), options.quiet)685 copy_file(libcef_path, dst_dir, options.quiet)686 copy_file(os.path.join(build_dir, 'libwidevinecdmadapter.so'), dst_dir, options.quiet)687 copy_file(os.path.join(build_dir, 'natives_blob.bin'), dst_dir, options.quiet)688 copy_file(os.path.join(build_dir, 'snapshot_blob.bin'), dst_dir, options.quiet)689 else:690 sys.stderr.write("No Debug build files.\n")691 # transfer Release files692 build_dir = build_dir_release693 libcef_path = os.path.join(build_dir, 'libcef.so')694 if not options.allowpartial or path_exists(libcef_path):695 valid_build_dir = build_dir696 dst_dir = os.path.join(output_dir, 'Release')697 make_dir(dst_dir, options.quiet)698 if mode == 'client':699 copy_file(os.path.join(build_dir, 'cefsimple'), dst_dir, options.quiet)700 copy_file(libcef_path, dst_dir, options.quiet)701 copy_file(os.path.join(build_dir, 'chrome_sandbox'), os.path.join(dst_dir, 'chrome-sandbox'), options.quiet)702 copy_file(os.path.join(build_dir, 'libwidevinecdmadapter.so'), dst_dir, options.quiet)703 copy_file(os.path.join(build_dir, 'natives_blob.bin'), dst_dir, options.quiet)704 copy_file(os.path.join(build_dir, 'snapshot_blob.bin'), dst_dir, options.quiet)705 else:706 sys.stderr.write("No Release build files.\n")707 if not valid_build_dir is None:708 # transfer resource files709 build_dir = valid_build_dir710 if mode == 'client':711 dst_dir = os.path.join(output_dir, 'Release')712 else:713 dst_dir = os.path.join(output_dir, 'Resources')714 make_dir(dst_dir, options.quiet)715 copy_file(os.path.join(build_dir, 'cef.pak'), dst_dir, options.quiet)716 copy_file(os.path.join(build_dir, 'cef_100_percent.pak'), dst_dir, options.quiet)717 copy_file(os.path.join(build_dir, 'cef_200_percent.pak'), dst_dir, options.quiet)718 copy_file(os.path.join(build_dir, 'cef_extensions.pak'), dst_dir, options.quiet)719 copy_file(os.path.join(build_dir, 'devtools_resources.pak'), dst_dir, options.quiet)720 copy_file(os.path.join(build_dir, 'icudtl.dat'), dst_dir, options.quiet)721 copy_dir(os.path.join(build_dir, 'locales'), os.path.join(dst_dir, 'locales'), options.quiet)722 if mode == 'standard' or mode == 'minimal':723 # transfer include files724 transfer_gypi_files(cef_dir, cef_paths2['includes_linux'], \725 'include/', include_dir, options.quiet)726 # transfer additional files, if any727 transfer_files(cef_dir, script_dir, os.path.join(script_dir, 'distrib', 'linux'), \728 mode, output_dir, options.quiet)729 if mode == 'standard':730 # transfer shared files731 transfer_gypi_files(cef_dir, cef_paths2['shared_sources_linux'], \732 'tests/shared/', shared_dir, options.quiet)733 # transfer cefclient files734 transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_linux'], \735 'tests/cefclient/', cefclient_dir, options.quiet)736 # transfer cefsimple files737 transfer_gypi_files(cef_dir, cef_paths2['cefsimple_sources_linux'], \738 'tests/cefsimple/', cefsimple_dir, options.quiet)739 # transfer ceftests files740 transfer_gypi_files(cef_dir, cef_paths2['ceftests_sources_linux'], \741 'tests/ceftests/', ceftests_dir, options.quiet)742 transfer_gypi_files(cef_dir, cef_paths2['ceftests_sources_views'], \743 'tests/ceftests/', ceftests_dir, options.quiet)744if not options.noarchive:745 # create an archive for each output directory746 archive_format = os.getenv('CEF_ARCHIVE_FORMAT', 'zip')747 if archive_format not in ('zip', 'tar.gz', 'tar.bz2'):748 raise Exception('Unsupported archive format: %s' % archive_format)749 if os.getenv('CEF_COMMAND_7ZIP', '') != '':750 archive_format = os.getenv('CEF_COMMAND_7ZIP_FORMAT', '7z')751 for dir in archive_dirs:752 if not options.quiet:753 sys.stdout.write("Creating %s archive for %s...\n" % (archive_format, os.path.basename(dir)))754 if archive_format == 'zip':755 create_zip_archive(dir)756 elif archive_format == 'tar.gz':757 create_tar_archive(dir, 'gz')758 elif archive_format == 'tar.bz2':759 create_tar_archive(dir, 'bz2')760 else:...

Full Screen

Full Screen

QuietZoneState.py

Source:QuietZoneState.py Github

copy

Full Screen

1from pandac.PandaModules import *2from direct.showbase.PythonUtil import Functor, PriorityCallbacks3from direct.task import Task4from toontown.distributed.ToontownMsgTypes import *5from otp.otpbase import OTPGlobals6from direct.directnotify import DirectNotifyGlobal7from direct.fsm import StateData8from direct.fsm import ClassicFSM, State9from direct.fsm import State10import ZoneUtil11class QuietZoneState(StateData.StateData):12 notify = DirectNotifyGlobal.directNotify.newCategory('QuietZoneState')13 Disable = False14 Queue = []15 def __init__(self, doneEvent):16 StateData.StateData.__init__(self, doneEvent)17 self.fsm = ClassicFSM.ClassicFSM('QuietZoneState', [State.State('off', self.enterOff, self.exitOff, ['waitForQuietZoneResponse']),18 State.State('waitForQuietZoneResponse', self.enterWaitForQuietZoneResponse, self.exitWaitForQuietZoneResponse, ['waitForZoneRedirect']),19 State.State('waitForZoneRedirect', self.enterWaitForZoneRedirect, self.exitWaitForZoneRedirect, ['waitForSetZoneResponse']),20 State.State('waitForSetZoneResponse', self.enterWaitForSetZoneResponse, self.exitWaitForSetZoneResponse, ['waitForSetZoneComplete']),21 State.State('waitForSetZoneComplete', self.enterWaitForSetZoneComplete, self.exitWaitForSetZoneComplete, ['waitForLocalAvatarOnShard']),22 State.State('waitForLocalAvatarOnShard', self.enterWaitForLocalAvatarOnShard, self.exitWaitForLocalAvatarOnShard, ['off'])], 'off', 'off')23 self._enqueueCount = 024 self.fsm.enterInitialState()25 def load(self):26 self.notify.debug('load()')27 def unload(self):28 self._dequeue()29 self.notify.debug('unload()')30 del self.fsm31 @classmethod32 def enqueueState(cls, state, requestStatus):33 cls.Queue = [(state, requestStatus)] + cls.Queue34 state._enqueueCount += 135 if len(cls.Queue) == 1:36 cls.startNextQueuedState()37 @classmethod38 def dequeueState(cls, state):39 s, requestStatus = cls.Queue.pop()40 s._enqueueCount -= 141 if len(cls.Queue) > 0:42 cls.startNextQueuedState()43 @classmethod44 def startNextQueuedState(cls):45 state, requestStatus = cls.Queue[-1]46 state._start(requestStatus)47 def _dequeue(self):48 newQ = []49 for item in self.__class__.Queue:50 state, requestStatus = item51 if state is not self:52 newQ.append(item)53 self.__class__.Queue = newQ54 def getEnterWaitForSetZoneResponseMsg(self):55 return 'enterWaitForSetZoneResponse-%s' % (id(self),)56 def getQuietZoneLeftEvent(self):57 return '%s-%s' % (base.cr.getQuietZoneLeftEvent(), id(self))58 def getSetZoneCompleteEvent(self):59 return 'setZoneComplete-%s' % (id(self),)60 def enter(self, requestStatus):61 self.notify.debug('enter(requestStatus=' + str(requestStatus) + ')')62 self._requestStatus = requestStatus63 self._leftQuietZoneCallbacks = None64 self._setZoneCompleteCallbacks = None65 self._leftQuietZoneLocalCallbacks = {}66 self._setZoneCompleteLocalCallbacks = {}67 self.enqueueState(self, requestStatus)68 return69 def _start(self, requestStatus):70 base.transitions.fadeScreen(1.0)71 self.fsm.request('waitForQuietZoneResponse')72 def getRequestStatus(self):73 return self._requestStatus74 def exit(self):75 self.notify.debug('exit()')76 del self._requestStatus77 base.transitions.noTransitions()78 self.fsm.request('off')79 self._dequeue()80 def waitForDatabase(self, description):81 if base.endlessQuietZone:82 return83 base.cr.waitForDatabaseTimeout(requestName='quietZoneState-%s' % description)84 def clearWaitForDatabase(self):85 base.cr.cleanupWaitingForDatabase()86 def addLeftQuietZoneCallback(self, callback, priority = None):87 if self._leftQuietZoneCallbacks:88 return self._leftQuietZoneCallbacks.add(callback, priority)89 else:90 token = PriorityCallbacks.GetToken()91 fdc = SubframeCall(callback, taskMgr.getCurrentTask().getPriority() - 1)92 self._leftQuietZoneLocalCallbacks[token] = fdc93 return token94 def removeLeftQuietZoneCallback(self, token):95 if token is not None:96 lc = self._leftQuietZoneLocalCallbacks.pop(token, None)97 if lc:98 lc.cleanup()99 if self._leftQuietZoneCallbacks:100 self._leftQuietZoneCallbacks.remove(token)101 return102 def addSetZoneCompleteCallback(self, callback, priority = None):103 if self._setZoneCompleteCallbacks:104 return self._setZoneCompleteCallbacks.add(callback, priority)105 else:106 token = PriorityCallbacks.GetToken()107 fdc = SubframeCall(callback, taskMgr.getCurrentTask().getPriority() - 1)108 self._setZoneCompleteLocalCallbacks[token] = fdc109 return token110 def removeSetZoneCompleteCallback(self, token):111 if token is not None:112 lc = self._setZoneCompleteLocalCallbacks.pop(token, None)113 if lc:114 lc.cleanup()115 if self._setZoneCompleteCallbacks:116 self._setZoneCompleteCallbacks.remove(token)117 return118 def handleWaitForQuietZoneResponse(self, msgType, di):119 self.notify.debug('handleWaitForQuietZoneResponse(' + 'msgType=' + str(msgType) + ', di=' + str(di) + ')')120 if msgType == CLIENT_ENTER_OBJECT_REQUIRED:121 base.cr.handleQuietZoneGenerateWithRequired(di)122 elif msgType == CLIENT_ENTER_OBJECT_REQUIRED_OTHER:123 base.cr.handleQuietZoneGenerateWithRequiredOther(di)124 elif msgType == CLIENT_OBJECT_SET_FIELD:125 base.cr.handleQuietZoneUpdateField(di)126 elif msgType in QUIET_ZONE_IGNORED_LIST:127 self.notify.debug('ignoring unwanted message from previous zone')128 else:129 base.cr.handlePlayGame(msgType, di)130 def handleWaitForZoneRedirect(self, msgType, di):131 self.notify.debug('handleWaitForZoneRedirect(' + 'msgType=' + str(msgType) + ', di=' + str(di) + ')')132 if msgType == CLIENT_ENTER_OBJECT_REQUIRED:133 base.cr.handleQuietZoneGenerateWithRequired(di)134 elif msgType == CLIENT_ENTER_OBJECT_REQUIRED_OTHER:135 base.cr.handleQuietZoneGenerateWithRequiredOther(di)136 elif msgType == CLIENT_OBJECT_SET_FIELD:137 base.cr.handleQuietZoneUpdateField(di)138 else:139 base.cr.handlePlayGame(msgType, di)140 def enterOff(self):141 self.notify.debug('enterOff()')142 def exitOff(self):143 self.notify.debug('exitOff()')144 self._leftQuietZoneCallbacks = PriorityCallbacks()145 self._setZoneCompleteCallbacks = PriorityCallbacks()146 self._leftQuietZoneLocalCallbacks = {}147 self._setZoneCompleteLocalCallbacks = {}148 def enterWaitForQuietZoneResponse(self):149 self.notify.debug('enterWaitForQuietZoneResponse(doneStatus=' + str(self._requestStatus) + ')')150 if not self.Disable:151 base.cr.handler = self.handleWaitForQuietZoneResponse152 base.cr.handlerArgs = self._requestStatus153 base.cr.setInQuietZone(True)154 self.setZoneDoneEvent = base.cr.getNextSetZoneDoneEvent()155 self.acceptOnce(self.setZoneDoneEvent, self._handleQuietZoneComplete)156 self.waitForDatabase('WaitForQuietZoneResponse')157 if base.slowQuietZone:158 def sQZR(task):159 base.cr.sendQuietZoneRequest()160 return Task.done161 taskMgr.doMethodLater(base.slowQuietZoneDelay, sQZR, 'slowQuietZone-sendQuietZoneRequest')162 else:163 base.cr.sendQuietZoneRequest()164 def _handleQuietZoneComplete(self):165 self.fsm.request('waitForZoneRedirect')166 def exitWaitForQuietZoneResponse(self):167 self.notify.debug('exitWaitForQuietZoneResponse()')168 self.clearWaitForDatabase()169 base.cr.handler = base.cr.handlePlayGame170 base.cr.handlerArgs = None171 base.cr.setInQuietZone(False)172 self.ignore(self.setZoneDoneEvent)173 del self.setZoneDoneEvent174 return175 def enterWaitForZoneRedirect(self):176 self.notify.debug('enterWaitForZoneRedirect(requestStatus=' + str(self._requestStatus) + ')')177 if not self.Disable:178 base.cr.handler = self.handleWaitForZoneRedirect179 base.cr.handlerArgs = self._requestStatus180 base.cr.setInQuietZone(True)181 self.waitForDatabase('WaitForZoneRedirect')182 zoneId = self._requestStatus['zoneId']183 avId = self._requestStatus.get('avId', -1)184 allowRedirect = self._requestStatus.get('allowRedirect', 1)185 if avId != -1:186 allowRedirect = 0187 if not base.cr.welcomeValleyManager:188 newZoneId = ZoneUtil.getCanonicalZoneId(zoneId)189 if newZoneId != zoneId:190 self.gotZoneRedirect(newZoneId)191 return192 if allowRedirect and ZoneUtil.isWelcomeValley(zoneId):193 self.notify.info('Requesting AI redirect from zone %s.' % zoneId)194 if base.slowQuietZone:195 def rZI(task, zoneId = zoneId, self = self):196 base.cr.welcomeValleyManager.requestZoneId(zoneId, self.gotZoneRedirect)197 return Task.done198 taskMgr.doMethodLater(base.slowQuietZoneDelay, rZI, 'slowQuietZone-welcomeValleyRedirect')199 else:200 base.cr.welcomeValleyManager.requestZoneId(zoneId, self.gotZoneRedirect)201 else:202 self.fsm.request('waitForSetZoneResponse')203 def gotZoneRedirect(self, zoneId):204 self.notify.info('Redirecting to zone %s.' % zoneId)205 base.cr.handlerArgs['zoneId'] = zoneId206 base.cr.handlerArgs['hoodId'] = ZoneUtil.getHoodId(zoneId)207 self.fsm.request('waitForSetZoneResponse')208 def exitWaitForZoneRedirect(self):209 self.notify.debug('exitWaitForZoneRedirect()')210 self.clearWaitForDatabase()211 base.cr.handler = base.cr.handlePlayGame212 base.cr.handlerArgs = None213 base.cr.setInQuietZone(False)214 return215 def enterWaitForSetZoneResponse(self):216 self.notify.debug('enterWaitForSetZoneResponse(requestStatus=' + str(self._requestStatus) + ')')217 if not self.Disable:218 messenger.send(self.getEnterWaitForSetZoneResponseMsg(), [self._requestStatus])219 base.cr.handlerArgs = self._requestStatus220 zoneId = self._requestStatus['zoneId']221 base.cr.dumpAllSubShardObjects()222 base.cr.resetDeletedSubShardDoIds()223 base.cr.sendSetZoneMsg(zoneId)224 self.waitForDatabase('WaitForSetZoneResponse')225 self.fsm.request('waitForSetZoneComplete')226 def exitWaitForSetZoneResponse(self):227 self.notify.debug('exitWaitForSetZoneResponse()')228 self.clearWaitForDatabase()229 base.cr.handler = base.cr.handlePlayGame230 base.cr.handlerArgs = None231 return232 def enterWaitForSetZoneComplete(self):233 self.notify.debug('enterWaitForSetZoneComplete(requestStatus=' + str(self._requestStatus) + ')')234 if not self.Disable:235 base.cr.handlerArgs = self._requestStatus236 if base.slowQuietZone:237 def delayFunc(self = self):238 def hSZC(task):239 self._handleSetZoneComplete()240 return Task.done241 taskMgr.doMethodLater(base.slowQuietZoneDelay, hSZC, 'slowQuietZone-sendSetZoneComplete')242 nextFunc = delayFunc243 else:244 nextFunc = self._handleSetZoneComplete245 self.waitForDatabase('WaitForSetZoneComplete')246 self.setZoneDoneEvent = base.cr.getLastSetZoneDoneEvent()247 self.acceptOnce(self.setZoneDoneEvent, nextFunc)248 if base.placeBeforeObjects:249 self._leftQuietZoneCallbacks()250 self._leftQuietZoneCallbacks = None251 fdcs = self._leftQuietZoneLocalCallbacks.values()252 self._leftQuietZoneLocalCallbacks = {}253 for fdc in fdcs:254 if not fdc.isFinished():255 fdc.finish()256 messenger.send(self.getQuietZoneLeftEvent())257 return258 def _handleSetZoneComplete(self):259 self.fsm.request('waitForLocalAvatarOnShard')260 def exitWaitForSetZoneComplete(self):261 self.notify.debug('exitWaitForSetZoneComplete()')262 self.clearWaitForDatabase()263 base.cr.handler = base.cr.handlePlayGame264 base.cr.handlerArgs = None265 self.ignore(self.setZoneDoneEvent)266 del self.setZoneDoneEvent267 return268 def enterWaitForLocalAvatarOnShard(self):269 self.notify.debug('enterWaitForLocalAvatarOnShard()')270 if not self.Disable:271 base.cr.handlerArgs = self._requestStatus272 self._onShardEvent = localAvatar.getArrivedOnDistrictEvent()273 self.waitForDatabase('WaitForLocalAvatarOnShard')274 if localAvatar.isGeneratedOnDistrict(localAvatar.defaultShard):275 self._announceDone()276 else:277 self.acceptOnce(self._onShardEvent, self._announceDone)278 def _announceDone(self):279 base.localAvatar.startChat()280 if base.endlessQuietZone:281 self._dequeue()282 return283 doneEvent = self.doneEvent284 requestStatus = self._requestStatus285 self._setZoneCompleteCallbacks()286 self._setZoneCompleteCallbacks = None287 fdcs = self._setZoneCompleteLocalCallbacks.values()288 self._setZoneCompleteLocalCallbacks = {}289 for fdc in fdcs:290 if not fdc.isFinished():291 fdc.finish()292 messenger.send(self.getSetZoneCompleteEvent(), [requestStatus])293 messenger.send(doneEvent)294 self._dequeue()295 return296 def exitWaitForLocalAvatarOnShard(self):297 self.notify.debug('exitWaitForLocalAvatarOnShard()')298 self.clearWaitForDatabase()299 self.ignore(self._onShardEvent)300 base.cr.handlerArgs = None301 del self._onShardEvent...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful