def emissions() -> None: # pragma: no cover """A simple demonstration of iterating over signal emissions.""" import qtrio import qtrio.examples.emissions qtrio.run(qtrio.examples.emissions.start_widget)
def gui(qt_api_string: str) -> None: # pragma: no cover """Launch the main GUI application.""" # TODO: This is generally actually covered by # ssst._tests.test_cli.test_gui_persists but the coverage recording or # reporting isn't working out. # https://github.com/altendky/ssst/issues/13 import ssst._utilities qt_api = qt_api_cli_names[qt_api_string] if qt_api is not None: ssst._utilities.configure_qt_wrapper(api=qt_api) import ssst.gui.main import qtrio qtrio.run(functools.partial(ssst.gui.main.Window.start, title="SSST"))
def run_gui(config: CoreConfig, start_arg: Optional[str] = None, diagnose: bool = False): logger.info("Starting UI") # Needed for High DPI usage of QIcons, otherwise only QImages are well scaled QApplication.setAttribute(Qt.AA_EnableHighDpiScaling) QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps) QApplication.setHighDpiScaleFactorRoundingPolicy( Qt.HighDpiScaleFactorRoundingPolicy.PassThrough) # The parsec app needs to be instanciated before qtrio runs in order # to be the default QApplication instance app = ParsecApp() assert QApplication.instance() is app return qtrio.run(_run_gui, app, config, start_arg, diagnose)
try: yield pickle.load(input) except EOFError: break def read_data(filename): print("Reading file:") [stored_course] = pickled_items(filename) counter = 0 for st in stored_course.statements: print("-------------------------") if isinstance(st, Exercise): counter += 1 print(f"Exercise n°{counter}: {st.pretty_name}") goal = st.initial_proof_state.goals[0] print(goal.goal_to_text()) # print(" More verbose:") # print(goal.goal_to_text(text_depth=2)) else: print(f"Definition: {st.pretty_name}") goal = st.initial_proof_state.goals[0] print(goal.goal_to_text(to_prove=False)) if __name__ == '__main__': logger.configure(debug=True) _ = gettext.gettext log.debug("starting pre-processing...") qtrio.run(main)
def download(url: str, destination: str, fps: int) -> None: # pragma: no cover import qtrio import qtrio.examples.download qtrio.run(qtrio.examples.download.start_downloader, url, destination, fps)
progress = Progress( downloaded=0, total=content_length, first=True, ) yield progress last_update = clock() progress = attr.evolve(progress, first=False) downloaded = 0 async with (await destination.open("wb")) as file: async for chunk in response.aiter_raw(): downloaded += len(chunk) await file.write(chunk) # type: ignore[attr-defined] if clock() - last_update > update_period: progress = attr.evolve(progress, downloaded=downloaded) yield progress last_update = clock() if progress.downloaded != downloaded: progress = attr.evolve(progress, downloaded=downloaded) yield progress if __name__ == "__main__": # pragma: no cover qtrio.run(start_downloader)
self.set_text(self.message[:i]) i += 1 if i > len(self.message): break # wait for another click to finish await emissions.channel.receive() async def start_widget( message: str, hold_event: typing.Optional[trio.Event] = None, *, cls: typing.Type[Widget] = Widget, task_status: trio_typing.TaskStatus[Widget] = trio.TASK_STATUS_IGNORED, ) -> None: self = cls(message=message) self.setup() task_status.started(self) if hold_event is not None: await hold_event.wait() await self.serve() if __name__ == "__main__": # pragma: no cover qtrio.run(start_widget, "Hello world.")
# Process each course for course in courses: async with trio.open_nursery() as nursery: servint = ServerInterfaceAllStatements(nursery) await servint.start() await servint.set_statements(course) servint.stop() log.debug("Got all proof states, saving") # Save pkl course file relative_course_path = course.relative_course_path directory_name = relative_course_path.parent course_hash = hash(course.file_content) # search for pkl file, and compare contents # so that only unprocessed statements will be processed unprocessed_statements = [] filename = relative_course_path.stem + '.pkl' course_pkl_path = directory_name.joinpath(Path(filename)) save_objects([course], course_pkl_path) print("===================================") print_goal(course) if __name__ == '__main__': logger.configure(domains=['ServerInterface', '__main__']) log.debug("starting pre-processing...") qtrio.run(main_alt)