run.py
 1  import sys
 2  import logging
 3  from airbyte_cdk.entrypoint import launch, AirbyteEntrypoint
 4  from .source import SourceBlockchainExplorer
 5  
 6  def run():
 7  
 8      logger = logging.getLogger("airbyte")
 9      args = sys.argv[1:]
10      
11      source = SourceBlockchainExplorer()
12      launch(source, sys.argv[1:])
13  
14      if "read" not in args:
15          return
16      
17      config_path = AirbyteEntrypoint(source).extract_config(args)
18      config = source.read_config(config_path)
19  
20      debug_mode = config["blocks_to_do"] > 0
21  
22      if debug_mode:
23          logger.info(f"Processed {config['blocks_to_do']} block pages")
24          return
25      
26      source.set_block(source.blocks.starting_block)
27      logger.info(f"{__name__}(): Updated text file {source.starting_block_path}")