def main(args=None): if args is None: args = sys.argv[1:] opts = parse_args(args) processor = None try: init_console_logging(verbose_level=opts.verbose) processor = TransactionProcessor(url=opts.connect) handler_user = UserTransactionHandler() handler_cars = CarsTransactionHandler() handler_invitations = InvitationsTransactionHandler() processor.add_handler(handler_user) processor.add_handler(handler_cars) processor.add_handler(handler_invitations) processor.start() except KeyboardInterrupt: pass except Exception as err: # pylint: disable=broad-except print("Error: {}".format(err)) finally: if processor is not None: processor.stop()
def main(args=None): if args is None: args = sys.argv[1:] opts = parse_args(args) processor = None try: init_console_logging(verbose_level=opts.verbose) processor = TransactionProcessor(url=opts.endpoint) log_config = get_log_config(filename="supplychain_log_config.toml") if log_config is not None: log_configuration(log_config=log_config) else: log_dir = get_log_dir() # use the transaction processor zmq identity for filename log_configuration(log_dir=log_dir, name="supplychain-" + str(processor.zmq_id)[2:-1]) processor.add_handler(SupplyChainHandler()) processor.start() except KeyboardInterrupt: pass except Exception as e: # pylint: disable=broad-except print("Error: {}".format(e), file=sys.stderr) finally: if processor is not None: processor.stop()
def main(prog_name=os.path.basename(sys.argv[0]), args=None, with_loggers=True): if args is None: args = sys.argv[1:] parser = create_parser(prog_name) args = parser.parse_args(args) arg_config = create_settings_config(args) setting_config = load_settings_config(arg_config) processor = TransactionProcessor(url=setting_config.connect) if with_loggers is True: if args.verbose is None: verbose_level = 0 else: verbose_level = args.verbose setup_loggers(verbose_level=verbose_level, processor=processor) my_logger = logging.getLogger(__name__) my_logger.debug("Processor loaded") handler = SettingTransactionHandler() processor.add_handler(handler) my_logger.debug( "Hashblock setting instantiated, starting setting processor thread...") try: processor.start() except KeyboardInterrupt: pass finally: processor.stop()
def main(args=None): if args is None: args = sys.argv[1:] opts = parse_args(args) processor = None try: processor = TransactionProcessor(url=opts.connect) log_config = get_log_config(filename="consent_log_config.toml") # If no toml, try loading yaml if log_config is None: log_config = get_log_config(filename="consent_log_config.yaml") if log_config is not None: log_configuration(log_config=log_config) # else: # log_dir = get_log_dir() init_console_logging(verbose_level=opts.verbose) handler = ConsentTransactionHandler(TP_PREFFIX_HEX6) processor.add_handler(handler) processor.start() except KeyboardInterrupt: pass except Exception as e: # pylint: disable=broad-except, invalid-name print("Error: {}".format(e), file=sys.stderr) finally: if processor is not None: processor.stop()
def main(args=None): if args is None: args = sys.argv[3:] # considering the starting command is `python3 main.py` and then additional arguments opts = parse_args(args) processor = None try: processor = TransactionProcessor(url=opts.connect) log_config = get_log_config(filename=tp_config_name+"_log_config.toml") # If no toml, try loading yaml if log_config is None: log_config = get_log_config(filename=tp_config_name+"_log_config.yaml") if log_config is not None: log_configuration(log_config=log_config) else: log_dir = get_log_dir() # use the transaction processor zmq identity for filename log_configuration( log_dir=log_dir, name=tp_config_name+"-" + str(processor.zmq_id)[2:-1]) init_console_logging(verbose_level=opts.verbose) # The prefix should eventually be looked up from the # validator's namespace registry. handler = Manufacturing() processor.add_handler(handler) processor.start() except KeyboardInterrupt: pass except Exception as e: # pylint: disable=broad-except print("Error: {}".format(e), file=sys.stderr) finally: if processor is not None: processor.stop()
def main(args=sys.argv[1:]): opts = parse_args(args) processor = TransactionProcessor(url=opts.endpoint) log_config = get_log_config(filename="intkey_log_config.toml") if log_config is not None: log_configuration(log_config=log_config) else: log_dir = get_log_dir() # use the transaction processor zmq identity for filename log_configuration(log_dir=log_dir, name="intkey_python-" + str(processor.zmq_id)[2:-1]) init_console_logging(verbose_level=opts.verbose) # The prefix should eventually be looked up from the # validator's namespace registry. intkey_prefix = hashlib.sha512('intkey'.encode()).hexdigest()[0:6] handler = IntkeyTransactionHandler(namespace_prefix=intkey_prefix) processor.add_handler(handler) try: processor.start() except KeyboardInterrupt: pass finally: processor.stop()
def main(prog_name=os.path.basename(sys.argv[0]), args=None, with_loggers=True): if args is None: args = sys.argv[1:] parser = create_parser(prog_name) args = parser.parse_args(args) if with_loggers is True: if args.verbose is None: verbose_level = 0 else: verbose_level = args.verbose setup_loggers(verbose_level=verbose_level) processor = TransactionProcessor(url=args.connect) handler = SettingsTransactionHandler() processor.add_handler(handler) try: processor.start() except KeyboardInterrupt: pass finally: processor.stop()
def main(args=sys.argv[1:]): opts = parse_args(args) processor = None try: processor = TransactionProcessor(url=opts.endpoint) log_config = get_log_config(filename="intkey_log_config.toml") if log_config is not None: log_configuration(log_config=log_config) else: log_dir = get_log_dir() # use the transaction processor zmq identity for filename log_configuration( log_dir=log_dir, name="intkey-" + str(processor.zmq_id)[2:-1]) init_console_logging(verbose_level=opts.verbose) # The prefix should eventually be looked up from the # validator's namespace registry. handler = IntkeyTransactionHandler() processor.add_handler(handler) processor.start() except KeyboardInterrupt: pass except Exception as e: # pylint: disable=broad-except print("Error: {}".format(e), file=sys.stderr) finally: if processor is not None: processor.stop()
def main(prog_name=os.path.basename(sys.argv[0]), args=None, with_loggers=True): if args is None: args = sys.argv[1:] parser = create_parser(prog_name) args = parser.parse_args(args) if with_loggers is True: if args.verbose is None: verbose_level = 0 else: verbose_level = args.verbose setup_loggers(verbose_level=verbose_level) processor = TransactionProcessor(url=args.endpoint) handler = TodoTransactionHandler() processor.add_handler(handler) # Start the processor # Provide an easy way to stop the processor with CTRL-C try: processor.start() except Exception as err: traceback.print_exc() print("Error. Stopping processor....") processor.stop()
def main(args=sys.argv[1:]): opts = parse_args(args) processor = None try: processor = TransactionProcessor(url=opts.endpoint) log_config = get_log_config(filename="supplier_log_config.toml") if log_config is not None: log_configuration(log_config=log_config) else: log_dir = get_log_dir() # use the transaction processor zmq identity for filename log_configuration(log_dir=log_dir, name="supplier-" + str(processor.zmq_id)[2:-1]) init_console_logging(verbose_level=opts.verbose) # The prefix should eventually be looked up from the # validator's namespace registry. supplier_prefix = hashlib.sha512( 'supplier'.encode("utf-8")).hexdigest()[0:6] handler = SupplierTransactionHandler(namespace_prefix=supplier_prefix) processor.add_handler(handler) processor.start() except KeyboardInterrupt: pass except Exception as e: print("Error: {}".format(e)) finally: if processor is not None: processor.stop()
def main(args=None): if args is None: args = sys.argv[1:] opts = parse_args(args) processor = None try: # In docker, the url would be the validator's container name with # port 4004 processor = TransactionProcessor(url=opts.connect) log_dir = get_log_dir() # use the transaction processor zmq identity for filename log_configuration(log_dir=log_dir, name="ca-bc-" + str(processor.zmq_id)[2:-1]) init_console_logging(verbose_level=2) handler = CAHandler('ca_1') processor.add_handler(handler) processor.start() except KeyboardInterrupt: pass except Exception as e: print("Error: {}".format(e), file=sys.stderr) finally: if processor is not None: processor.stop()
def main(args = None): if args is None: args = sys.argv[1:] opts = parse_args(args) processor = None try: arg_config = create_transfer_config(opts) transfer_config = load_transfer_config(arg_config) processor = TransactionProcessor(url=transfer_config.connect) log_config = get_log_config(filename="transfer_log_config.toml") if log_config is None: log_config = get_log_config(filename="transfer_log_config.yaml") if log_config is not None: log_configuration(log_config=log_config) else: log_dir = get_log_dir() log_configuration( log_dir=log_dir, name="transfer" + str(processor.zmq_id)[2:-1]) init_console_logging(verbose_level=opts.verbose) handler = TransferHandler() processor.add_handler(handler) processor.start() except KeyboardInterrupt: pass except Exception as e: print("Error: {}".format(e)) finally: if processor is not None: processor.stop()
def main(args=None): """ Main. Raises: RunTimeException, connection error """ if args is None: args = sys.argv[1:] opts = parse_args(args) processor = None try: processor = TransactionProcessor(url=opts.connect) log_dir = get_log_dir() #use the transaction processor zmq idenity for filename log_configuration(log_dir=log_dir, name="code_smell-" + str(processor.zmq_id)[2:-1]) init_console_logging(verbose_level=opts.verbose) handler = CodeSmellTransactionHandler() processor.add_handler(handler) processor.start() except KeyboardInterrupt: pass except RuntimeError as err: raise CodeSmellException("Error: {}".format(err)) finally: if processor is not None: processor.stop()
def main(args=sys.argv[1:]): opts = parse_args(args) processor = None try: processor = TransactionProcessor(url=opts.endpoint) log_config = get_log_config(filename="part_log_config.toml") if log_config is not None: log_configuration(log_config=log_config) else: log_dir = get_log_dir() log_configuration(log_dir=log_dir, name="part-" + str(processor.zmq_id)[2:-1]) init_console_logging(verbose_level=opts.verbose) part_prefix = hashlib.sha512('part'.encode("utf-8")).hexdigest()[0:6] handler = PartTransactionHandler(namespace_prefix=part_prefix) processor.add_handler(handler) processor.start() except KeyboardInterrupt: pass except Exception as e: print("Error: {}".format(e)) finally: if processor is not None: processor.stop()
def main(prog_name=os.path.basename(sys.argv[0]), args=None, with_loggers=True): if args is None: args = sys.argv[1:] parser = create_parser(prog_name) args = parser.parse_args(args) if with_loggers is True: if args.verbose is None: verbose_level = 0 else: verbose_level = args.verbose setup_loggers(verbose_level=verbose_level) processor = TransactionProcessor(url=args.endpoint) handler = SettingsTransactionHandler() processor.add_handler(handler) try: processor.start() except KeyboardInterrupt: pass finally: processor.stop()
def main(args=None): if args is None: args = sys.argv[1:] opts = parse_args(args) processor = None try: processor = TransactionProcessor(url=opts.endpoint) log_config = get_log_config(filename="intkey_log_config.toml") if log_config is not None: log_configuration(log_config=log_config) else: log_dir = get_log_dir() # use the transaction processor zmq identity for filename log_configuration( log_dir=log_dir, name="intkey-" + str(processor.zmq_id)[2:-1]) init_console_logging(verbose_level=opts.verbose) # The prefix should eventually be looked up from the # validator's namespace registry. handler = IntkeyTransactionHandler() processor.add_handler(handler) processor.start() except KeyboardInterrupt: pass except Exception as e: # pylint: disable=broad-except print("Error: {}".format(e), file=sys.stderr) finally: if processor is not None: processor.stop()
def main(prog_name=os.path.basename(sys.argv[0]), args=None, with_loggers=True): if args is None: args = sys.argv[1:] parser = create_parser(prog_name) args = parser.parse_args(args) arg_config = create_identity_config(args) identity_config = load_identity_config(arg_config) processor = TransactionProcessor(url=identity_config.connect) if with_loggers is True: if args.verbose is None: verbose_level = 0 else: verbose_level = args.verbose setup_loggers(verbose_level=verbose_level, processor=processor) handler = IdentityTransactionHandler() processor.add_handler(handler) try: processor.start() except KeyboardInterrupt: pass finally: processor.stop()
def __init__(self, conf: DistributedManagerConfig): super().__init__(conf) self.conf = conf # Set up transaction processor self.transaction_processor = TransactionProcessor( url=conf.VALIDATOR_URL) self.handler = CCellularHandler(conf) self.handler.set_apply_callback(self.report_update) self.transaction_processor.add_handler(self.handler) self.client = CCellularClient(conf) # Set loggers self.handler.logger = self.log self.client.logger = self.log self.trigger_callback_func = None
def add_handlers(processor=TransactionProcessor('tcp://localhost:4004')): """ Creates handlers for the processor to call. Used in main""" # For each handler you want to add, you'll # create the handler object and call # 'processor.add_handler(<object name>) # Handler initialization lace = LaceTransactionHandler() processor.add_handler(lace)
def main(args=sys.argv[1:]): processor = TransactionProcessor(url=args[0]) handler = ConfigurationTransactionHandler() processor.add_handler(handler) try: processor.start() except KeyboardInterrupt: pass finally: processor.stop()
def main(args=None): '''Entry-point function for the carLogger transaction walletprocessor.''' setup_loggers() if args is None: args = sys.argv[1:] opts = parse_args(args) try: # Register the transaction handler and start it. processor = TransactionProcessor(url=opts.connect) handler = CarLoggerTransactionHandler(sw_namespace) processor.add_handler(handler) processor.start() except KeyboardInterrupt: pass except SystemExit as err: LOGGER.info(err) raise err except BaseException as err: LOGGER.info(err) traceback.print_exc(file=sys.stderr) sys.exit(1) except Exception as err: LOGGER.info(err)
def main(prog_name=os.path.basename(sys.argv[0]), args=None, with_loggers=True): if args is None: args = sys.argv[1:] parser = create_parser(prog_name) args = parser.parse_args(args) if with_loggers is True: if args.verbose is None: verbose_level = 0 else: verbose_level = args.verbose setup_loggers(verbose_level=verbose_level) # Create a new processor thats connect to the validator processor = TransactionProcessor(url=args.endpoint) # Create handler(s) and associate it with the processor # See handlers.py to add more transaction handlers handler.add_handlers(processor) # Start the processor # Provide an easy way to stop the processor with CTRL-C try: print("henlo") processor.start() print("welp") except Exception as e: print(e) print("Error. Stopping processor....") processor.stop()
def main(): '''Entry-point function for all the TPs.''' try: logging.basicConfig() logging.getLogger().setLevel(logging.DEBUG) # Register the Transaction Handler and start it. processor = TransactionProcessor(DEFAULT_URL) processor.add_handler( ManufacturerTransactionHandler(prefix_hash("manufacturing"))) processor.add_handler( TransferTransactionHandler(prefix_hash("transfer"))) processor.add_handler(SalesTransactionHandler(prefix_hash("sales"))) processor.start() except KeyboardInterrupt: pass except SystemExit as err: raise err except BaseException as err: traceback.print_exc(file=sys.stderr) sys.exit(1)
def main(): processor = TransactionProcessor(url='tcp://validator:4004') handler = SimpleWalletTransactionHandler(sw_namespace) processor.add_handler(handler) processor.start()
def main(args=sys.argv[1:]): processor = TransactionProcessor(url=args[0]) # The prefix should eventually be looked up from the # validator's namespace registry. intkey_prefix = hashlib.sha512('intkey'.encode()).hexdigest()[0:6] handler = IntkeyTransactionHandler(namespace_prefix=intkey_prefix) processor.add_handler(handler) try: processor.start() except KeyboardInterrupt: pass finally: processor.stop()
def main(args=None): processor = TransactionProcessor(url="tcp://validator:4004") handler = SetGetTransactionHandler() # Adds a transaction family handler :param handler: the handler to # be added :type handler: TransactionHandler processor.add_handler(handler) #Connects the transaction processor to a validator and starts listening #for requests and routing them to an appropriate transaction handler. processor.start()
def main(): try: url = env("SAWTOOTH_VALIDATOR_ENDPOINT", "tcp://validator:4004") processor = TransactionProcessor(url=url) log_configuration(log_dir=get_log_dir(), name="petition_tp") create_console_handler(5) init_console_logging(5) handler = PetitionTransactionHandler() # url=rest_api) processor.add_handler(handler) processor.start() except KeyboardInterrupt: pass except Exception as e: print("Error: {}".format(e), file=sys.stderr) finally: if processor is not None: processor.stop()
def main(args=sys.argv[1:]): opts = parse_args(args) init_console_logging(verbose_level=opts.verbose) processor = TransactionProcessor(url=opts.endpoint) handler = ValidatorRegistryTransactionHandler() processor.add_handler(handler) try: processor.start() except KeyboardInterrupt: pass finally: processor.stop()
def main(): # In docker, the url would be the validator's container name with # port 4004 processor = TransactionProcessor(url='tcp://127.0.0.1:4004') handler = BlockONSTXHandler("007007") processor.add_handler(handler) processor.start()
class Processor: def __init__(self, handler, address): self._processor = TransactionProcessor(url=address) self._processor.add_handler(handler) def start(self): self._processor.start() def stop(self): self._processor.stop()
def main(validator_url): # In docker, the url would be the validator's container name with port 4004 processor = TransactionProcessor(url=validator_url) handler = XoTransactionHandler(XO_NAMESPACE) processor.add_handler(handler) processor.start()
def main(): # In docker, the url would be the validator's container name with # port 4004 processor = TransactionProcessor(url='tcp://validator-bgx-с1-1:4104') handler = DQTransactionHandler() processor.add_handler(handler) processor.start()
def main(args=None): if args is None: args = sys.argv[1:] opts = parse_args(args) processor = None try: processor = TransactionProcessor(url=opts.validator_endpoint) init_console_logging(verbose_level=opts.verbosity) processor.add_handler(RBACTransactionHandler()) processor.start() except KeyboardInterrupt: pass except Exception as exe: # pylint: disable=broad-except LOGGER.error("Error: %s", exe, file=sys.stderr) finally: if processor is not None: processor.stop()
def main(args=None): if args is None: args = sys.argv[1:] opts = parse_args(args) init_console_logging(verbose_level=opts.verbose) processor = TransactionProcessor(url=opts.endpoint) handler = ValidatorRegistryTransactionHandler() processor.add_handler(handler) try: processor.start() except KeyboardInterrupt: pass finally: processor.stop()
def main(args=sys.argv[1:]): opts = parse_args(args) init_console_logging(verbose_level=opts.verbose) processor = TransactionProcessor(url=opts.endpoint) # The prefix should eventually be looked up from the # validator's namespace registry. xo_prefix = hashlib.sha512('xo'.encode("utf-8")).hexdigest()[0:6] handler = XoTransactionHandler(namespace_prefix=xo_prefix) processor.add_handler(handler) try: processor.start() except KeyboardInterrupt: pass finally: processor.stop()
def main(args=None): if args is None: args = sys.argv[1:] opts = parse_args(args) processor = None try: processor = TransactionProcessor(url=opts.connect) log_config = get_log_config(filename="battleship_log_config.toml") # If no toml, try loading yaml if log_config is None: log_config = get_log_config(filename="battleship_log_config.yaml") if log_config is not None: log_configuration(log_config=log_config) else: log_dir = get_log_dir() # use the transaction processor zmq identity for filename log_configuration( log_dir=log_dir, name="battleship-" + str(processor.zmq_id)[2:-1]) init_console_logging(verbose_level=opts.verbose) # The prefix should eventually be looked up from the # validator's namespace registry. battle_ship_prefix = \ hashlib.sha512('battleship'.encode("utf-8")).hexdigest()[0:6] handler = \ BattleshipTransactionHandler(namespace_prefix=battle_ship_prefix) processor.add_handler(handler) processor.start() except KeyboardInterrupt: pass except Exception as e: # pylint: disable=broad-except print("Error: {}".format(e)) finally: if processor is not None: processor.stop()
def main(args=None): if args is None: args = sys.argv[1:] opts = parse_args(args) processor = None try: processor = TransactionProcessor(url=opts.connect) init_console_logging(verbose_level=opts.verbose) handler = TunachainTransactionHandler() processor.add_handler(handler) processor.start() except KeyboardInterrupt: pass except Exception as err: # pylint: disable=broad-except print("Error: {}".format(err)) finally: if processor is not None: processor.stop()
def main(args=None): if args is None: args = sys.argv[1:] opts = parse_args(args) processor = None try: arg_config = create_xo_config(opts) xo_config = load_xo_config(arg_config) processor = TransactionProcessor(url=xo_config.connect) log_config = get_log_config(filename="xo_log_config.toml") # If no toml, try loading yaml if log_config is None: log_config = get_log_config(filename="xo_log_config.yaml") if log_config is not None: log_configuration(log_config=log_config) else: log_dir = get_log_dir() # use the transaction processor zmq identity for filename log_configuration( log_dir=log_dir, name="xo-" + str(processor.zmq_id)[2:-1]) init_console_logging(verbose_level=opts.verbose) handler = XoTransactionHandler() processor.add_handler(handler) processor.start() except KeyboardInterrupt: pass except Exception as e: # pylint: disable=broad-except print("Error: {}".format(e)) finally: if processor is not None: processor.stop()