settings = await ns.get_settings() print(pp.str_inotificationsettings(settings)) async def show_single_notification(conn): # Assumes there is at least one WARNING. ns = NotificationsService(conn) notif_type = NotificationType.WARNING notifications = await ns.get_all(notif_type) if not notifications: print(f"Unable to find a {notif_type.name} notification to display.") else: first_notification_id = notifications[0].id # Fetch it again notification = await ns.get_notification(first_notification_id) print(f"Single Notification:") print(pp.str_notificationmodel_multiline(notification, "")) async def exercise_notifications_services_ro(conn): await show_settings(conn) await show_single_notification(conn) await list_notifications(conn) if __name__ == "__main__": from tests.runexercise import run_exercise run_exercise(exercise_notifications_services_ro)
from pyslobs import PerformanceService import formatters as pp async def show_performance(conn): ps = PerformanceService(conn) state = await ps.get_model() print("Current performance statistics") print(pp.str_iperformancestate(state)) async def exercise_performanceservice_ro(conn): await show_performance(conn) if __name__ == "__main__": from tests.runexercise import run_exercise run_exercise(exercise_performanceservice_ro)
print( "After setting - proxy value", scene_node.locked, scene_node.visible, scene_node.stream_visible, ) items = await folder.get_items() assert len(items) == 1 refetched_scene_node = items[0] print( "After setting - refetched value", refetched_scene_node.locked, refetched_scene_node.visible, refetched_scene_node.stream_visible, ) await asyncio.sleep(2) print("Scene deleted, old scene made active (via sceneservice)") # Source is implicitly deleted (!) async def exercise_scenenodes_rw(conn): await modify_scene_nodes(conn) if __name__ == "__main__": from tests.runexercise import run_exercise run_exercise(exercise_scenenodes_rw)
await audioservice.get_source(audio_source.source_id), "")) assert (await (await audioservice.get_source(audio_source.source_id )).get_model()).fader.deflection == 0 await audio_source.set_deflection(1) assert (await (await audioservice.get_source(audio_source.source_id )).get_model()).fader.deflection == 1 async def exercise_audioservice_ro(conn): await list_current_scene_audio_sources(conn) await list_first_scenes_audio_sources(conn) await list_all_audio_sources(conn) await fetch_first_source(conn) async def exercise_audioservice_rw(conn): await manipulate_audio_source(conn) if __name__ == "__main__": from tests.runexercise import run_exercise run_exercise(exercise_audioservice_ro)
# Enlarge it await sts.stretch_to_screen() await sts.reset_transform() await sts.rotate(45) await sts.set_transform(dict(rotation=12)) await sts.set_visibility(False) await sts.set_visibility(True) await sts.set_stream_visible(False) await sts.set_stream_visible(True) await sts.set_recording_visible(False) await sts.set_settings(dict(locked=True)) await sts.set_settings(dict(locked=False, recordingVisible=True)) async def exercise_selection_ro(conn): await display_status(conn) async def exercise_selection_rw(conn): await direct_selection(conn) await manipulate_selected(conn) if __name__ == "__main__": import logging logging.basicConfig(level=logging.DEBUG) from tests.runexercise import run_exercise run_exercise(exercise_selection_rw)
assert active_scene.id == active_scene_id_3 assert active_scene_2.id == active_scene_id_3 print("All Scenes") all_scenes = await ss.get_scenes() for scene in all_scenes: print(await pp.str_scene_multiline(scene, "", show_nodes=False)) async def show_add_delete_scene(conn): # This is actually tested by the preserver itself. async with TestScene(conn) as ts: print("Scene added.") await ts.make_active() print("Scene made active (via scene).") await asyncio.sleep(2) print("Scene deleted, old scene made active (via sceneservice") async def exercise_scenesservice_ro(conn): await show_active_scene(conn) async def exercise_scenesservice_rw(conn): await show_add_delete_scene(conn) if __name__ == "__main__": from tests.runexercise import run_exercise run_exercise(exercise_scenesservice_ro)
print("Toggle recording") await sts.toggle_recording() await asyncio.sleep(2) await display_status(conn) print("Toggle streaming") await sts.toggle_streaming() await asyncio.sleep(2) await display_status(conn) print("Toggle recording") await sts.toggle_recording() await asyncio.sleep(2) await display_status(conn) print("Toggle streaming") await sts.toggle_streaming() await asyncio.sleep(2) await display_status(conn) async def exercise_streaming_ro(conn): await display_status(conn) async def exercise_streaming_destructive(conn): await record_and_stream(conn) if __name__ == "__main__": from tests.runexercise import run_exercise run_exercise(exercise_streaming_ro)
async def show_add_showcase_dialog(conn, delay): ss = SourcesService(conn) print("Please note the 'Select source type' dialogue.") await ss.show_showcase() await asyncio.sleep(delay) async def show_source_properties_dialog(conn, delay): ss = SourcesService(conn) sources = await ss.get_sources() first_source = sources[0] first_source_id = first_source.source_id print("Please cancel the 'properties' dialogue for:") # TODO: When str_source_multiline is available, print it here. await ss.show_source_properties(first_source_id) async def exercise_all_ui(conn, delay=0): await show_notification_dialog(conn, delay) await show_add_source_dialog(conn, delay) await show_add_showcase_dialog(conn, delay) await show_source_properties_dialog(conn, delay=0) await exercise_notifications_services_ui(conn) if __name__ == "__main__": from tests.runexercise import run_exercise run_exercise(exercise_all_ui)
async def show_add_showcase_dialog(conn, delay): ss = SourcesService(conn) print("Please note the 'Select source type' dialogue.") await ss.show_showcase() await asyncio.sleep(delay) async def show_source_properties_dialog(conn, delay): ss = SourcesService(conn) sources = await ss.get_sources() first_source = sources[0] first_source_id = first_source.source_id print("Please cancel the 'properties' dialogue for:") # TODO: When str_source_multiline is available, print it here. await ss.show_source_properties(first_source_id) async def exercise_all_ui(conn, delay=0): await show_notification_dialog(conn, delay) await show_add_source_dialog(conn, delay) await show_add_showcase_dialog(conn, delay) await show_source_properties_dialog(conn, delay=0) if __name__ == "__main__": from tests.runexercise import run_exercise run_exercise(exercise_all_ui, delay=5)
while True: try: await ts.disable_studio_mode() break except ProtocolError: print("Failed. Will retry") await asyncio.sleep(3) print("Mode is now:", await ts.get_model()) await asyncio.sleep(3) print("---") await ts.execute_studio_mode_transition() print("Transitioned!") await asyncio.sleep(2) async def exercise_transitionservice_ro(conn): await show_studio_mode(conn) async def exercise_transitionservice_rw(conn): await change_studio_mode(conn) if __name__ == "__main__": from tests.runexercise import run_exercise run_exercise(exercise_transitionservice_rw)
"SourcesService.sourceRemoved": 1, } file_source = await ss.add_file( Path(__file__).parent / "testpattern.jpg") print("Created source from file:") print(await pp.str_source_multiline(file_source, "")) await ss.remove_source(file_source.source_id) assert events == { "SourcesService.sourceAdded": 2, "SourcesService.sourceUpdated": 1, "SourcesService.sourceRemoved": 2, } async def exercise_sourcesservice_ro(conn): await show_all_sources(conn) await show_all_source_types(conn) async def exercise_sourcesservice_rw(conn): await add_source(conn) if __name__ == "__main__": from tests.runexercise import run_exercise run_exercise(exercise_sourcesservice_ro)
# print(await pp.str_scene_multiline(active_scene, "", as_tree=True)) async def create_load_delete_collection(conn): scs = SceneCollectionsService(conn) await asyncio.sleep(1) # Try to avoid overloading server original_collection = await scs.active_collection() await asyncio.sleep(1) # Try to avoid overloading server sc = await scs.create( ISceneCollectionCreateOptions("SceneCollectionExercise")) await asyncio.sleep(1) # Try to avoid overloading server await scs.rename("SceneCollectionExercise2", sc.id) await asyncio.sleep(1) # Try to avoid overloading server await scs.delete(sc.id) await asyncio.sleep(1) # Try to avoid overloading server await scs.load(original_collection.id) async def exercise_scenecollections_ro(conn): await show_active_collection(conn) async def exercise_scenecollections_rw(conn): await create_load_delete_collection(conn) if __name__ == "__main__": from tests.runexercise import run_exercise run_exercise(exercise_scenecollections_rw)