def replay(self): lines = open(self.replay_file).read().strip().split('\n') succ_cnt = 0 replay_cnt = 0 for i in xrange(self.retry_count): logger.info("=== try No. %d ===" % i) log.clear() self.replay_lines(lines) replay_cnt += 1 if self.target: target_buginfo = self.get_target_info() logger.info("target bug to replay: " + buglib.get_bug_info(target_buginfo)) if self.check_target(target_buginfo): logger.info("successfully replayed the bug at retry %d" % i) succ_cnt += 1 if not self.cont_after_succ: break else: logger.info("failed to replay the bug") else: logger.info("no replay target specified. maybe succeeded") break logger.info("=== succ count / replay count / retry count: %d/%d/%d" % (succ_cnt, replay_cnt, self.retry_count))
def execute(self, context): if state.compileproc != None: return {"CANCELLED"} if not armutils.check_saved(self): return {"CANCELLED"} if not armutils.check_camera(self): return {"CANCELLED"} if not armutils.check_sdkpath(self): return {"CANCELLED"} if context.area == None: return {"CANCELLED"} nodes_renderpath.check_default() assets.invalidate_enabled = False if state.playproc == None and state.krom_running == False: if context.area.type != 'VIEW_3D': return {"CANCELLED"} log.clear() # Cancel viewport render for space in context.area.spaces: if space.type == 'VIEW_3D': if space.viewport_shade == 'RENDERED': space.viewport_shade = 'SOLID' break make.play_project(True) else: make.play_project(True) assets.invalidate_enabled = True return{'FINISHED'}
def execute(self, context): area = bpy.context.area if area == None: area = state.play_area area.type = 'VIEW_3D' state.is_paused = False log.clear() return {'FINISHED'}
def execute(self, context): area = bpy.context.area if area == None: area = state.play_area area.type = 'VIEW_3D' state.is_paused = False log.clear() return{'FINISHED'}
def on_compiled(mode): # build, play, play_viewport, publish log.clear() sdk_path = armutils.get_sdk_path() wrd = bpy.data.worlds['Arm'] # Print info if mode == 'publish': target_name = make_utils.get_kha_target(wrd.arm_project_target) print('Project published') files_path = armutils.get_fp() + '/build/' + target_name if target_name == 'html5': print('HTML5 files are located in ' + files_path) elif target_name == 'ios' or target_name == 'osx': # TODO: to macos print('XCode project files are located in ' + files_path + '-build') elif target_name == 'windows': print('VisualStudio 2015 project files are located in ' + files_path + '-build') elif target_name == 'android-native': print('Android Studio project files are located in ' + files_path + '-build/' + wrd.arm_project_name) else: print('Makefiles are located in ' + files_path + '-build') return # Launch project in new window elif mode =='play': if wrd.arm_play_runtime == 'Electron': electron_app_path = './build/electron.js' if armutils.get_os() == 'win': electron_path = sdk_path + 'win32/Kode Studio.exe' elif armutils.get_os() == 'mac': electron_path = sdk_path + 'Kode Studio.app/Contents/MacOS/Electron' else: electron_path = sdk_path + 'linux64/kodestudio' state.playproc = subprocess.Popen([electron_path, '--chromedebug', '--remote-debugging-port=9222', '--enable-logging', electron_app_path], stderr=subprocess.PIPE) watch_play() elif wrd.arm_play_runtime == 'Browser': # Start server os.chdir(armutils.get_fp()) t = threading.Thread(name='localserver', target=lib.server.run) t.daemon = True t.start() html5_app_path = 'http://localhost:8040/build/html5' webbrowser.open(html5_app_path) elif wrd.arm_play_runtime == 'Krom': if armutils.get_os() == 'win': krom_location = sdk_path + '/win32/Krom/win32' krom_path = krom_location + '/Krom.exe' elif armutils.get_os() == 'mac': krom_location = sdk_path + '/Kode Studio.app/Contents/Krom/macos/Krom.app/Contents/MacOS' krom_path = krom_location + '/Krom' else: krom_location = sdk_path + '/linux64/Krom/linux' krom_path = krom_location + '/Krom' os.chdir(krom_location) state.playproc = subprocess.Popen([krom_path, armutils.get_fp() + '/build/window/krom', armutils.get_fp() + '/build/window/krom-resources'], stderr=subprocess.PIPE) watch_play()
def on_compiled(mode): # build, play, play_viewport, publish log.clear() sdk_path = armutils.get_sdk_path() # Print info if mode == 'publish': target_name = make_utils.get_kha_target(bpy.data.worlds['Arm'].arm_project_target) print('Project published') files_path = armutils.get_fp() + '/build/' + target_name if target_name == 'html5': print('HTML5 files are located in ' + files_path) elif target_name == 'ios' or target_name == 'osx': # TODO: to macos print('XCode project files are located in ' + files_path + '-build') elif target_name == 'windows': print('VisualStudio 2015 project files are located in ' + files_path + '-build') elif target_name == 'android-native': print('Android Studio project files are located in ' + files_path + '-build') else: print('Makefiles are located in ' + files_path + '-build') return # Launch project in new window elif mode =='play': wrd = bpy.data.worlds['Arm'] if wrd.arm_play_runtime == 'Electron': electron_app_path = './build/electron.js' if armutils.get_os() == 'win': electron_path = sdk_path + 'win32/Kode Studio.exe' elif armutils.get_os() == 'mac': electron_path = sdk_path + 'Kode Studio.app/Contents/MacOS/Electron' else: electron_path = sdk_path + 'linux64/kodestudio' state.playproc = subprocess.Popen([electron_path, '--chromedebug', '--remote-debugging-port=9222', '--enable-logging', electron_app_path], stderr=subprocess.PIPE) watch_play() elif wrd.arm_play_runtime == 'Browser': # Start server os.chdir(armutils.get_fp()) t = threading.Thread(name='localserver', target=lib.server.run) t.daemon = True t.start() html5_app_path = 'http://localhost:8040/build/html5' webbrowser.open(html5_app_path) elif wrd.arm_play_runtime == 'Krom': if armutils.get_os() == 'win': krom_location = sdk_path + '/win32/Krom/win32' krom_path = krom_location + '/Krom.exe' elif armutils.get_os() == 'mac': krom_location = sdk_path + '/Kode Studio.app/Contents/Krom/macos/Krom.app/Contents/MacOS' krom_path = krom_location + '/Krom' else: krom_location = sdk_path + '/linux64/Krom/linux' krom_path = krom_location + '/Krom' os.chdir(krom_location) state.playproc = subprocess.Popen([krom_path, armutils.get_fp() + '/build/window/krom', armutils.get_fp() + '/build/window/krom-resources'], stderr=subprocess.PIPE) watch_play()
def watch_play(): if state.playproc == None: return line = b'' while state.playproc != None and state.playproc.poll() == None: char = state.playproc.stderr.read(1) # Read immediately one by one if char == b'\n': msg = str(line).split('"', 1) # Extract message if len(msg) > 1: trace = msg[1].rsplit('"', 1)[0] log.electron_trace(trace) line = b'' else: line += char state.playproc = None state.playproc_finished = True log.clear()
def __init__(self, ip, port, username, character): log.clear() log.log("Server class initialised.") self.sock = socket.socket() while True: try: self.sock.connect((ip, port)) break except: delay = 2 log.log("Server refused connection. Wait %s second(s) before retry." % (str(delay))) time.sleep(delay) if self.sock.recv(1024).decode() == "+--SEND-INIT--+": self.sock.send(str.encode("%s|%s" % (username, character))) self.sock.recv(1024) self.sock.send(str.encode("--+end+--"))
def cross_train(def_params, param_1, param_1_lst, param_2, param_2_lst, last_bmark=0): clear('results') results = np.zeros((len(param_1_lst), len(param_2_lst), 3)) count = 1 for x, p1 in enumerate(param_1_lst): for y, p2 in enumerate(param_2_lst): c_name = def_params['name'] + '_' + str(count).zfill(3) params = network.load_Parameter(c_name) if params is None: params = def_params.copy() params['name'] = c_name params[param_1] = p1 params[param_2] = p2 else: params = get_params(**params) # Continue at the last benchmark if count > last_bmark: log('Benchmark %s: %s = %s | %s = %s' % (c_name, param_1, str(p1), param_2, str(p2)), name='results') train(params) mat_accuracy_G, mat_accuracy_D, mat_accuracy_C = network.load_Acc( params) acc_G = np.mean(mat_accuracy_G, axis=0) acc_D = np.mean(mat_accuracy_D, axis=0) acc_C = np.mean(mat_accuracy_C, axis=0) results[x, y, 1] = acc_G[-1] results[x, y, 2] = acc_D[-1] results[x, y, 0] = acc_C[-1] count += 1 excel.save(def_params, param_1, param_1_lst, param_2, param_2_lst, results)
def try_to_replay(self, events, target): lines = [] for event in events: event.append_to(lines) for i in xrange(self.retry_count): logger.info("=== try No. %d ===" % i) log.clear() try: self.replay_lines(lines) except apptest.exception.StoppedException as e: raise e except Exception as e: if not self.launcher.dev_running(): logger.info("restart device since it's not running") apptest.init.load_config(self.launcher.restart_dev()) if self.check_target(target): return True return False
def execute(self, context): if not armutils.check_saved(self): return {"CANCELLED"} if not armutils.check_camera(self): return {"CANCELLED"} nodes_renderpath.check_default() assets.invalidate_enabled = False if state.playproc == None: log.clear() # Cancel viewport render for space in context.area.spaces: if space.type == 'VIEW_3D': if space.viewport_shade == 'RENDERED': space.viewport_shade = 'SOLID' break make.play_project(self, True) else: make.patch_project() make.compile_project() assets.invalidate_enabled = True return{'FINISHED'}
def build_project(is_play=False, is_publish=False, in_viewport=False, target=None): wrd = bpy.data.worlds['Arm'] # Set target if target == None: state.target = wrd.arm_project_target.lower() # Clear flag state.in_viewport = False # Save blend bpy.ops.wm.save_mainfile() log.clear() # Set camera in active scene active_scene = bpy.context.screen.scene if wrd.arm_play_active_scene else bpy.data.scenes[wrd.arm_project_scene] if active_scene.camera == None: for o in active_scene.objects: if o.type == 'CAMERA': active_scene.camera = o break # Get paths sdk_path = armutils.get_sdk_path() raw_shaders_path = sdk_path + '/armory/Shaders/' # Set dir fp = armutils.get_fp() os.chdir(fp) # Create directories if not os.path.exists('Sources'): os.makedirs('Sources') # Compile path tracer shaders if len(bpy.data.cameras) > 0 and bpy.data.cameras[0].renderpath_path == 'pathtrace_path': path_tracer.compile(raw_shaders_path + 'pt_trace_pass/pt_trace_pass.frag.glsl') # Save external scripts edited inside Blender write_texts = False for text in bpy.data.texts: if text.filepath != '' and text.is_dirty: write_texts = True break if write_texts: area = bpy.context.area old_type = area.type area.type = 'TEXT_EDITOR' for text in bpy.data.texts: if text.filepath != '' and text.is_dirty: area.spaces[0].text = text bpy.ops.text.save() area.type = old_type # Save internal Haxe scripts for text in bpy.data.texts: if text.filepath == '' and text.name[-3:] == '.hx': with open('Sources/' + bpy.data.worlds['Arm'].arm_project_package + '/' + text.name, 'w') as f: f.write(text.as_string()) # Export data export_data(fp, sdk_path, is_play=is_play, is_publish=is_publish, in_viewport=in_viewport) if state.playproc == None: log.print_progress(50)
def build_project(is_play=False, is_publish=False, in_viewport=False, target=None): wrd = bpy.data.worlds['Arm'] # Set target if target == None: state.target = wrd.arm_project_target.lower() # Clear flag state.in_viewport = False # Save blend if armutils.get_save_on_build(): bpy.ops.wm.save_mainfile() log.clear() # Set camera in active scene active_scene = bpy.context.screen.scene if wrd.arm_play_active_scene else bpy.data.scenes[wrd.arm_project_scene] if active_scene.camera == None: for o in active_scene.objects: if o.type == 'CAMERA': active_scene.camera = o break # Get paths sdk_path = armutils.get_sdk_path() raw_shaders_path = sdk_path + '/armory/Shaders/' # Set dir fp = armutils.get_fp() os.chdir(fp) # Create directories sources_path = 'Sources/' + wrd.arm_project_package if not os.path.exists(sources_path): os.makedirs(sources_path) # Compile path tracer shaders if len(bpy.data.cameras) > 0 and bpy.data.cameras[0].renderpath_path == 'pathtrace_path': path_tracer.compile(raw_shaders_path + 'pt_trace_pass/pt_trace_pass.frag.glsl') # Save external scripts edited inside Blender write_texts = False for text in bpy.data.texts: if text.filepath != '' and text.is_dirty: write_texts = True break if write_texts: area = bpy.context.area old_type = area.type area.type = 'TEXT_EDITOR' for text in bpy.data.texts: if text.filepath != '' and text.is_dirty and os.path.isfile(text.filepath): area.spaces[0].text = text bpy.ops.text.save() area.type = old_type # Save internal Haxe scripts for text in bpy.data.texts: if text.filepath == '' and text.name[-3:] == '.hx': with open('Sources/' + bpy.data.worlds['Arm'].arm_project_package + '/' + text.name, 'w') as f: f.write(text.as_string()) # Export data export_data(fp, sdk_path, is_play=is_play, is_publish=is_publish, in_viewport=in_viewport) if state.playproc == None: log.print_progress(50)
import log log.clear()
def test_clear(self): with mock.patch('os.system') as mock_clear: log.clear() mock_clear.assert_called()
def btnClear_clicked(self, widget): """ Clear the log window """
def __init__(self): self.my_ip = socket.gethostbyname(socket.gethostname()).split(".") self.my_ip = str(self.my_ip[0] + self.my_ip[1] + self.my_ip[2]) self.sock = socket.socket() self.search_port = 24456 log.clear()