diff --git a/src/consumer.py b/src/consumer.py index 36ab3f4..7ba9bb5 100644 --- a/src/consumer.py +++ b/src/consumer.py @@ -69,6 +69,26 @@ def callback(ch, method, properties, body, access, logger): # thread.join() # print('Waiting for the message...') +def local_run(filename): + logger = configure_file_logger('consumer', logging_format='%(asctime)s - %(levelname)s - %(message)s') + + logger.info(f'Start processing book-{filename}.') + logging_format = '%(asctime)s - %(levelname)s - %(message)s' + + + folder_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + file_path = Path(os.path.join(folder_path, f'docx/{filename}.docx')) + output_path = Path(os.path.join(folder_path, f'json/{filename}.json')) + + try: + book = Book(file_path=file_path, output_path=output_path, main_logger=logger) + book.test_conversion() + + except Exception as exc: + raise exc + + logger.info(f'Book-{filename} has been proceeded.') + if __name__ == '__main__': @@ -103,3 +123,5 @@ if __name__ == '__main__': logger.info('Waiting for messages...') channel.start_consuming() + + # local_run('0')