def go(self, argv): """ The main entry point into PyPDFOCR #. Parses options #. If filing is enabled, call :func:`_setup_filing` #. If watch is enabled, start the watcher #. :func:`run_conversion` #. if filing is enabled, call :func:`file_converted_file` """ # Read the command line options self.get_options(argv) # Setup tesseract and ghostscript self._setup_external_tools() # Setup the pdf filing if enabled if self.enable_filing: self._setup_filing() # Do the actual conversion followed by optional filing and email if self.watch: while True: # Make sure the watcher doesn't terminate try: py_watcher = PyPdfWatcher(self.watch_dir, self.config.get('watch')) for pdf_filename in py_watcher.start(): self._convert_and_file_email(pdf_filename) except KeyboardInterrupt: break except Exception as e: print traceback.print_exc(e) py_watcher.stop() else: self._convert_and_file_email(self.pdf_filename)