forked from LiveCarta/BookConverter
add functionallity for local run
This commit is contained in:
@@ -69,6 +69,26 @@ def callback(ch, method, properties, body, access, logger):
|
|||||||
# thread.join()
|
# thread.join()
|
||||||
# print('Waiting for the message...')
|
# 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__':
|
if __name__ == '__main__':
|
||||||
|
|
||||||
@@ -103,3 +123,5 @@ if __name__ == '__main__':
|
|||||||
logger.info('Waiting for messages...')
|
logger.info('Waiting for messages...')
|
||||||
|
|
||||||
channel.start_consuming()
|
channel.start_consuming()
|
||||||
|
|
||||||
|
# local_run('0')
|
||||||
|
|||||||
Reference in New Issue
Block a user