def start_application(args=None): if requirements_installed(): from util.process_life_cycle import ProcessLifeCycle life_cycle = ProcessLifeCycle(args) life_cycle.start() return 0 return 1
def test_draw_process_life_cycle(): try: from util.process_life_cycle import ProcessLifeCycle process_life_cycle = ProcessLifeCycle(None) process_life_cycle.get_fsm_builder().draw("launch_state_diagram.png") assert os.path.isfile("launch_state_diagram.png") is True finally: os.remove("launch_state_diagram.png")
def draw_state_diagram(): process_life_cycle = ProcessLifeCycle(None) config_life_cycle = ConfigLifeCycle(None, None, None, None) process_life_cycle.get_fsm_builder().draw( "docs/fsm/graphviz/launch_state_diagram.png", title="Process Life Cycle") config_life_cycle.get_fsm_builder().draw( "docs/fsm/graphviz/config_cycle_state_diagram.png", title="Configuration Life Cycle", )
def start_application(args=None): check_fee_ini() # Requirements need to be checked outside of the state machine # because the library transitions could not be present if requirements_installed(): from util.process_life_cycle import ProcessLifeCycle life_cycle = ProcessLifeCycle(args) life_cycle.start() return 0 return 1
def test_draw_process_life_cycle(): directory_path = os.path.dirname(os.path.abspath(__file__)) file_name = "launch_state_diagram" file_extension = ".png" file_path_1 = os.path.join(directory_path, file_name + file_extension) file_path_2 = os.path.join(directory_path, file_name) try: from util.process_life_cycle import ProcessLifeCycle process_life_cycle = ProcessLifeCycle(None) process_life_cycle.get_fsm_builder().draw(file_path_1) assert os.path.isfile(file_path_1) is True finally: if os.path.isfile(file_path_1): os.remove(file_path_1) if os.path.isfile(file_path_2): os.remove(file_path_2)
def test_disk_full_payment_producer(args, caplog): # Issue: https://github.com/tezos-reward-distributor-organization/tezos-reward-distributor/issues/504 client_manager = ClientManager(args.node_endpoint, args.signer_endpoint) network_config_map = init_network_config(args.network, client_manager) factory = ProviderFactory(provider="prpc") parser = BakingYamlConfParser( baking_config, None, None, None, None, block_api=factory, api_base_url=None ) parser.parse() parser.process() cfg_dict = parser.get_conf_obj() baking_cfg = BakingConf(cfg_dict) baking_dirs = BakingDirs(args, baking_cfg.get_baking_address()) srvc_fee_calc = ServiceFeeCalculator( baking_cfg.get_full_supporters_set(), baking_cfg.get_specials_map(), baking_cfg.get_service_fee(), ) payments_queue = queue.Queue(50) plc = ProcessLifeCycle(None) pp = PaymentProducer( name="producer", network_config=network_config_map[args.network], payments_dir=baking_dirs.payments_root, calculations_dir=baking_dirs.calculations_root, run_mode=RunMode(args.run_mode), service_fee_calc=srvc_fee_calc, release_override=args.release_override, payment_offset=args.payment_offset, baking_cfg=baking_cfg, life_cycle=plc, payments_queue=payments_queue, dry_run=args.dry_run, client_manager=client_manager, node_url=args.node_endpoint, reward_data_provider=args.reward_data_provider, node_url_public=args.node_addr_public, api_base_url=args.api_base_url, retry_injected=args.retry_injected, initial_payment_cycle=args.initial_cycle, ) assert disk_is_full() try: pp.daemon = True pp.start() finally: pp.stop() assert ( "Disk is becoming full. Only 0.50 Gb left from 10.00 Gb. Please clean up disk to continue saving logs and reports." in caplog.text )
from util.dir_utils import ( get_payment_root, get_successful_payments_dir, get_failed_payments_dir, ) from util.disk_is_full import disk_is_full from util.process_life_cycle import ProcessLifeCycle LINER = "--------------------------------------------" NB_CONSUMERS = 1 BUF_SIZE = 50 payments_queue = queue.Queue(BUF_SIZE) logger = main_logger life_cycle = ProcessLifeCycle() MUTEZ = 1 def main(args): logger.info( "Arguments Configuration = {}".format(json.dumps(args.__dict__, indent=1)) ) # Load payments file payments_file = os.path.expanduser(os.path.normpath(args.payments_file)) if not os.path.isfile(payments_file): raise Exception("payments_file ({}) does not exist.".format(payments_file)) with open(payments_file, "r") as file: payment_lines = file.readlines()