def __init__(self, methodName='runTest'):
        super().__init__(methodName)
        self.port = 8081
        self.name = None
        self.data_folder = None
        self.server_address = "localhost:{}".format(self.port)
        self.server = None
        self.server_thread = None
        self.server_process = None
        self.client = None
        self.converters = TExternalConverters(enable_smart_parser=False,
                                              enable_calibre=False,
                                              enable_cat_doc=False,
                                              enable_xls2csv=False,
                                              enable_office_2_txt=False)

        self.pdf_ocr_folder = os.path.join(os.path.dirname(__file__),
                                           "pdf.ocr")
        self.pdf_ocr_out_folder = os.path.join(os.path.dirname(__file__),
                                               "pdf.ocr.out")
        if not os.path.exists(self.pdf_ocr_folder) or not os.path.exists(
                self.pdf_ocr_out_folder):
            raise Exception(
                "run python update_finereader_task.py, and upload test.hft to finreader hot folder"
            )
        self.project_file = "converted_file_storage.json"
        self.client = None
        self.server_args = None
        self.client_count = 0
from source_doc_http.source_doc_client import TSourceDocClient
from DeclDocRecognizer.external_convertors import TExternalConverters
from smart_parser_http.smart_parser_client import TSmartParserCacheClient
from smart_parser_http.smart_parser_server import TSmartParserHTTPServer
from common.logging_wrapper import setup_logging

import sys
import os

if __name__ == "__main__":
    converters = TExternalConverters()
    INPUT_SHA256 = sys.argv[1]
    log_file_name = INPUT_SHA256 + ".log"
    logger = setup_logging(log_file_name=log_file_name)
    assert len(INPUT_SHA256) == 64
    source_doc_client = TSourceDocClient(TSourceDocClient.parse_args(
        ["--disable-first-ping"]),
                                         logger=logger)
    file_data, file_extension = source_doc_client.retrieve_file_data_by_sha256(
        INPUT_SHA256)
    if file_data is None:
        logger.error("cannot find source document {}".format(INPUT_SHA256))
        sys.exit(1)
    file_path = "{}{}".format(INPUT_SHA256, file_extension)
    with open(file_path, "wb") as outp:
        outp.write(file_data)

    sha256, json_data = converters.run_smart_parser_official(
        file_path,
        logger=logger,
        default_value=TSmartParserHTTPServer.SMART_PARSE_FAIL_CONSTANT)