def main(): args = Arguments() args.print_header() cache = Cache(args) cache.read_and_parse_trace_file() cache.print_results()
def main(): """Main function Returns: int -- Program's return code """ try: Args = Arguments() Interpreter(Args.get_source_file()).run() except InterpreterError as e: print("[ ERROR ]", e, file=stderr) return e.code else: return 0
def main(): if Path("config.json").exists(): GLOBAL.configDirectory = Path("config.json") else: if not Path(GLOBAL.defaultConfigDirectory).is_dir(): os.makedirs(GLOBAL.defaultConfigDirectory) GLOBAL.configDirectory = GLOBAL.defaultConfigDirectory / "config.json" try: GLOBAL.config = Config(GLOBAL.configDirectory).generate() except InvalidJSONFile as exception: VanillaPrint(str(exception.__class__.__name__),">>",str(exception)) VanillaPrint("Resolve it or remove it to proceed") input("\nPress enter to quit") sys.exit() sys.argv = sys.argv + GLOBAL.config["options"].split() arguments = Arguments.parse() GLOBAL.arguments = arguments if arguments.set_filename: Config(GLOBAL.configDirectory).setCustomFileName() sys.exit() if arguments.set_folderpath: Config(GLOBAL.configDirectory).setCustomFolderPath() sys.exit() if arguments.set_default_directory: Config(GLOBAL.configDirectory).setDefaultDirectory() sys.exit() if arguments.set_default_options: Config(GLOBAL.configDirectory).setDefaultOptions() sys.exit() if arguments.use_local_config: JsonFile("config.json").add(GLOBAL.config) sys.exit() if arguments.directory: GLOBAL.directory = Path(arguments.directory.strip()) elif "default_directory" in GLOBAL.config and GLOBAL.config["default_directory"] != "": GLOBAL.directory = Path(GLOBAL.config["default_directory"].format(time=GLOBAL.RUN_TIME)) else: GLOBAL.directory = Path(input("\ndownload directory: ").strip()) if arguments.downloaded_posts: GLOBAL.downloadedPosts = Store(arguments.downloaded_posts) else: GLOBAL.downloadedPosts = Store() printLogo() print("\n"," ".join(sys.argv),"\n",noPrint=True) if arguments.log is not None: logDir = Path(arguments.log) download(postFromLog(logDir)) sys.exit() programMode = ProgramMode(arguments).generate() try: posts = getPosts(programMode) except Exception as exc: logging.error(sys.exc_info()[0].__name__, exc_info=full_exc_info(sys.exc_info())) print(GLOBAL.log_stream.getvalue(),noPrint=True) print(exc) sys.exit() if posts is None: print("I could not find any posts in that URL") sys.exit() if GLOBAL.arguments.no_download: pass else: download(posts)
frame = self.interface.getCurrentFrame(self.video_capture) objects = self.recognizer.detectObjects(self.model, frame) self.interface.drawObjects(objects, frame) if self.endKeyWasPressed(): return self.stop() self.interface.displayFrame(frame) def endKeyWasPressed(self): if cv2.waitKey(1) & 0xFF == ord('q'): return True return False def stop(self): self.video_capture.release() cv2.destroyAllWindows() return True if __name__ == "__main__": # get external arguments object_type, show_border, show_image = Arguments().setup() # start main main = Main() main.run(object_type, show_border, show_image)