add functionallity for local run

This commit is contained in:
Jeniamakarchik
2020-04-06 14:09:40 +03:00
parent c79486c934
commit dab9485e20

View File

@@ -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')