def __init__(self, app): self.app = app self.viewer = None # chunking configs. More info at docs/prediction_chunks.rst # how often do we check if we need to refresh predictions? self.predictions_refresh_real_seconds = 5 # how many real seconds do we want to get on each prediction? self.predictions_chunk_real_seconds = 30 * 60 # how many real seconds before we run out of predictions should fire a new request for # predictions? self.predictions_too_low_threshold_real_seconds = 15 * 60 # initialize the map module self.configure_cesium_map() self.paths_visible = True self.sensors_visible = True # references to the dom self.paths_visible_input = jq("#paths-visible-input") self.sensors_visible_input = jq("#sensors-visible-input") self.night_shadow_input = jq("#night-shadow-input") self.map_date_picker = jq("#map-date-picker") self.go_to_date_button = jq("#go-to-date") # assign event handlers self.go_to_date_button.on("click", self.on_go_to_date_click) self.paths_visible_input.on("change", self.on_paths_visible_change) self.sensors_visible_input.on("change", self.on_sensors_visible_change) self.night_shadow_input.on("change", self.on_night_shadow_change) self.on_night_shadow_change() # every some time, ensure we have paths for each satellite aio.run(self.ensure_enough_predictions())
def test_browser_aio(): from browser import alert, document, html, aio async def main(): input = html.INPUT() document <= input while True: ev = await aio.event(input, "blur") try: v = int(ev.target.value) input.remove() alert(f"Value: {v}") assert v == 0 break except ValueError: input.value = "" ## only works with python >=3.7 if sys.version_info.major == 3 and sys.version_info.minor >= 7: aio.run(main()) from browser import document, html, aio async def main(): # Text file req = await aio.ajax("GET", "test.html") assert len(req.data) == 0 # Binary file req = await aio.get("memo.pdf", format="binary") assert len(req.data) == 0 # Read binary file as dataURL req = await aio.get("eraser.png", format="dataURL") # display the image in an IMG tag document <= html.IMG(src=req.data) ## only works with python >=3.7 if sys.version_info.major == 3 and sys.version_info.minor >= 7: aio.run(main())
def run_one(ev): aio.run(run(reset=True))
test_helper.init3() else: test_helper.init1() def option_on_change_network(evt): network_name = evt.target.value switch_network(network_name) # bindings to functions in module editor # doc['show_js'].bind('click', editor.show_js) # doc['show_console'].bind('click', editor.show_console) doc['files'].bind('change', option_load_test) doc['networks'].bind('change', option_on_change_network) doc['btn_code'].bind('click', load_code) doc['btn_abi'].bind('click', load_code) doc['btn_test'].bind('click', load_code) aio.run(init_editor()) def print_str(s): print(s, end='') window.print_str = print_str timer.set_interval(save_editor, 10000)
async for i in a: result.append(i) assert result == expected, (close, result, expected) print(throw, close, "async generator ok") async def main(secs, urls): print(f"wait {secs} seconds...") await aio.sleep(secs) for url in urls: r = await ajax_call(url) results.append(r) report() await test_async_for() await test_async_with() await test_lock() await test_async_comp() for throw, close, expected in [[False, False, [1, 2, 3, 4, 5]], [True, False, [1, 2, ZeroDivisionError]], [False, True, [1, 2]], [True, True, [1, 2, ZeroDivisionError]]]: await test_async_gen(throw, close, expected) await raise_error() print("Start...") aio.run(main(1, ["test_suite.py", "index.html", "unknown.txt"]), onerror=handle)
def created(self): print("getting list of modules") asyncio.run(self.get_module_names())
def start_animation(e): if not animation_is_running: grid = Grid(300, 10, ui) aio.run(animate(grid))
def mod_clicked(self, event): print(f"Module {self.selected_m} selected, getting its questions...") asyncio.run(self.get_questions())
def turn_left1(self, ev=None): aio.run(self.turn_left2())
def play_game(event): aio.run(play())
def restart_decision_making(_): aio.run(_restart_decision_making())
def aio_get(evt): log("Before aio.run") aio.run(process_get("/api.txt")) log("After aio.run")
def turn_over1(self, ev=None): aio.run(self.turn_over2())
def turn_right1(self, ev=None): aio.run(self.turn_right2())
def _run(task): aio.run(task)
def created(self): # self.nx_firebase = NxFirebaseBackEnd.NxFirebaseBackEnd() print("getting list of modules") asyncio.run(self.get_module_names())
from browser import alert, document, html, aio async def main(): input = html.INPUT() document <= input while True: ev = await aio.event(input, "blur") try: v = int(ev.target.value) input.remove() alert(f"Value: {v}") print(1) break except ValueError: input.value = "" aio.run(main()) for i in range(5): print(i)
def walk1(self, ev=None): aio.run(self.walk2())