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: 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: processor = TransactionProcessor(url=opts.endpoint) log_config = get_log_config(filename="part_log_config.toml") if log_config is None: log_config = get_log_config(filename="part_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="part-" + str(processor.zmq_id)[2:-1]) init_console_logging(verbose_level=opts.verbose) part_prefix = hashlib.sha512('pt'.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: # pylint: disable=broad-except print("Error: {}".format(e)) finally: if processor is not None: processor.stop()
def main(): loop = ZMQEventLoop() asyncio.set_event_loop(loop) try: opts = parse_args(sys.argv[1:]) init_console_logging(verbose_level=opts.verbose) validator_url = opts.connect if "tcp://" not in validator_url: validator_url = "tcp://" + validator_url messenger = Messenger(validator_url) try: host, port = opts.bind.split(":") port = int(port) except ValueError: print("Unable to parse binding {}: Must be in the format" " host:port".format(opts.bind)) sys.exit(1) start_rest_api(host, port, messenger) except Exception as err: # pylint: disable=broad-except LOGGER.exception(err) sys.exit(1) finally: messenger.close_validator_connection()
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[1:] opts = parse_args(args) processor = None try: processor = TransactionProcessor(url=opts.connect) log_config = get_log_config(filename="snarkcoin_log_config.toml") # If no toml, try loading yaml if log_config is None: log_config = get_log_config(filename="snarkcoin_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="snarkcoin-" + str(processor.zmq_id)[2:-1]) init_console_logging(verbose_level=opts.verbose) handler = SnarkcoinHandler() 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(): loop = ZMQEventLoop() asyncio.set_event_loop(loop) connection = None try: opts = parse_args(sys.argv[1:]) init_console_logging(verbose_level=opts.verbose) url = opts.connect if "tcp://" not in url: url = "tcp://" + url connection = Connection(url) try: host, port = opts.bind.split(":") port = int(port) except ValueError: print("Unable to parse binding {}: Must be in the format" " host:port".format(opts.bind)) sys.exit(1) start_rest_api(host, port, connection) except Exception as err: # pylint: disable=broad-except LOGGER.exception(err) sys.exit(1) finally: if connection is not None: connection.close()
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 = 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): 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 set_log_config(self): log_config = get_log_config(filename="rest_api_log_config.toml") # If no toml, try loading yaml if log_config is None: log_config = get_log_config(filename="rest_api_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="rest_api") init_console_logging(verbose_level=0)
def setup_logging(name, verbosity=2): log_config = get_log_config(filename='{}_log_config.toml'.format(name)) if log_config is None: log_config = get_log_config(filename='{}_log_config.yaml'.format(name)) 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=name) init_console_logging(verbose_level=verbosity)
def main(args=None): try: path_config = load_path_config() except LocalConfigurationError as local_config_err: LOGGER.error(str(local_config_err)) sys.exit(1) if args is None: args = sys.argv[1:] opts = parse_args(args) try: arg_config = create_pbft_config(opts) pbft_config = load_pbft_config(arg_config) log_config = get_log_config('bgx-pbft-engine-log-config.toml') if log_config is None: log_config = get_log_config('bgx-pbft-engine-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='pbft-engine') init_console_logging(verbose_level=opts.verbose) driver = ZmqDriver( PbftEngine( path_config=path_config, component_endpoint=opts.component, pbft_config=pbft_config)) LOGGER.debug('Start driver=%s endpoint=%s component=%s',driver,opts.connect,opts.component) attemps = 0 while attemps < MAX_CONNECT_ATTEMPTS: try: driver.start(endpoint=opts.connect) break except FutureTimeoutError: attemps += 1 LOGGER.debug('Start driver=%s endpoint=%s AGAIN=%s',driver,opts.connect,attemps) except KeyboardInterrupt: pass except Exception: # pylint: disable=broad-except LOGGER.exception("Error starting PBFT Engine") finally: pass
def setup_loggers(verbose_level, processor): log_config = get_log_config(filename="setting_log_config.toml") # If no toml, try loading yaml if log_config is None: log_config = get_log_config(filename="setting_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="setting-" + str(processor.zmq_id)[2:-1]) init_console_logging(verbose_level=verbose_level)
def setup_logging(name, verbosity=2): Path('/var/log/sawtooth').mkdir(parents=True, exist_ok=True) Path('/var/log/sawtooth/{}-debug.log'.format(name)).touch(exist_ok=True) log_config = get_log_config(filename='{}_log_config.toml'.format(name)) if log_config is None: log_config = get_log_config(filename='{}_log_config.yaml'.format(name)) 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=name) init_console_logging(verbose_level=verbosity)
def main(): # Set logging init_console_logging(verbose_level=2) # Create transaction processor class with specified address of the validator processor = TransactionProcessor(url='tcp://127.0.0.1:4004') # We have to instantiate our self implemented handler class which encodes the main part of the application's logic handler = BenchmarkHandler('benchcontract') # Now we have to add our handler to the processor processor.add_handler(handler) # Start the processor print('starting benchcontract processor...') 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 setup_loggers(verbose_level, processor): log_config = get_log_config(filename="identity_log_config.toml") # If no toml, try loading yaml if log_config is None: log_config = get_log_config(filename="identity_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="identity-" + str(processor.zmq_id)[2:-1]) init_console_logging(verbose_level=verbose_level)
def main(destino): '''Entry-point function for the sensor transaction processor.''' try: init_console_logging() # Register the transaction handler and start it. processor = TransactionProcessor(url=destino) handler = IoTTransactionHandler(iot_namespace) processor.add_handler(handler) 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(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) try: log_dir = get_log_dir() log_configuration(log_dir=log_dir, name='poet-engine') init_console_logging(verbose_level=opts.verbose) driver = ZmqDriver(PoetEngine()) driver.start(endpoint=opts.connect) except KeyboardInterrupt: pass except Exception as e: # pylint: disable=broad-except print("Error: {}".format(e), file=sys.stderr) finally: pass
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 = SupplyHandler() processor.add_handler(handler) processor.start() except KeyboardInterrupt: pass except Exception as err: 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: processor = TransactionProcessor( url=opts.connect or "tcp://validator:4004") log_config = get_log_config(filename="log_config.yaml") log_configuration(log_config=log_config) init_console_logging(verbose_level=opts.verbose) handler = GaiachainTransactionHandler() processor.add_handler(handler) processor.start() except KeyboardInterrupt: pass finally: if processor is not None: processor.stop()
def main(args=None): """Starts sawtooth transaction processor with options set per args.""" 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 err: # pylint: disable=broad-except LOGGER.exception("Fatal processor %s exception", type(err)) LOGGER.exception(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: 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) #print(opts) processor = None try: processor = TransactionProcessor(url=opts.connect) log_config = get_log_config(filename="bcmcs_log_config.toml") # If no toml, try loading yaml if log_config is None: print('None', processor.zmq_id, get_log_dir()) log_config = get_log_config(filename="bcmcs_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="bcmcs-" + 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 = BCMCSTransactionHandler() 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(): processor = None try: processor = TransactionProcessor(url='tcp://127.0.0.1:4004') log_dir = get_log_dir() log_configuration(log_dir=log_dir, name="barcode-" + str(processor.zmq_id)[2:-1]) init_console_logging(verbose_level=2) barcode_prefix = hashlib.sha512( 'barcode'.encode("utf-8")).hexdigest()[0:6] handler = BarcodeTransactionHandler(namespace_prefix=barcode_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) try: log_dir = get_log_dir() log_configuration( log_dir=log_dir, name='poet-engine') init_console_logging(verbose_level=opts.verbose) driver = ZmqDriver(PoetEngine()) driver.start(endpoint=opts.connect) except KeyboardInterrupt: pass except Exception as e: # pylint: disable=broad-except print("Error: {}".format(e), file=sys.stderr) finally: pass
def main(args=None): if args is None: args = sys.argv[1:] opts = parse_args(args) processor = None try: print("here 1") arg_config = create_identity_config(opts) identity_config = load_identity_config(arg_config) processor = TransactionProcessor(url=identity_config.connect) log_config = get_log_config(filename="identity_log_config.toml") print("here 2") # If no toml, try loading yaml if log_config is None: log_config = get_log_config(filename="identity_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="identity-" + str(processor.zmq_id)[2:-1]) print('here 3') init_console_logging(verbose_level=opts.verbose) print('here 4') handler = IdentityTransactionHandler() print('here 5') processor.add_handler(handler) print('here 6') processor.start() print('here 7') 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): try: path_config = load_path_config() except LocalConfigurationError as local_config_err: LOGGER.error(str(local_config_err)) sys.exit(1) if args is None: args = sys.argv[1:] opts = parse_args(args) try: log_config = get_log_config('poet-engine-log-config.toml') if log_config is None: log_config = get_log_config('poet-engine-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='poet-engine') init_console_logging(verbose_level=opts.verbose) driver = ZmqDriver( PoetEngine( path_config=path_config, component_endpoint=opts.component)) driver.start(endpoint=opts.connect) except KeyboardInterrupt: pass except Exception: # pylint: disable=broad-except LOGGER.exception("Error starting PoET Engine") finally: pass
def main(url): try: init_console_logging(verbose_level=2) logger = logging.getLogger(__name__) # Start a transaction processor, listening to a given host. # TODO: Parameterize this. processor = TransactionProcessor(url=url) # Add custom handler to our TP. blocked_handler = handler.BlockedHandler() processor.add_handler(blocked_handler) # Start TP. processor.start() except KeyboardInterrupt: pass except Exception as err: print("error: {}".format(err)) finally: if processor is not None: processor.stop()
def main(): try: url = env("ZTP_VALIDATOR_ENDPOINT", "tcp://validator:4004") rest_api = env("ZTP_REST_ENDPOINT", "http://rest-api:8090") processor = TransactionProcessor(url=url) log_dir = get_log_dir() # use the transaction processor zmq identity for filename log_configuration(log_dir=log_dir, name="zenroom-" + str(processor.zmq_id)[2:-1]) init_console_logging() handler = ZenroomTransactionHandler(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=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: processor = TransactionProcessor(url=opts.connect) log_config = get_log_config(filename="intkey_log_config.toml") # If no toml, try loading yaml if log_config is None: log_config = get_log_config(filename="intkey_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="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 = SimpleTransactionHandler() 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=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()
def main(): loop = ZMQEventLoop() asyncio.set_event_loop(loop) connection = None try: opts = parse_args(sys.argv[1:]) opts_config = RestApiConfig( bind=opts.bind, connect=opts.connect, timeout=opts.timeout, opentsdb_url=opts.opentsdb_url, opentsdb_db=opts.opentsdb_db) rest_api_config = load_rest_api_config(opts_config) url = None if "tcp://" not in rest_api_config.connect: url = "tcp://" + rest_api_config.connect else: url = rest_api_config.connect connection = Connection(url) log_config = get_log_config(filename="rest_api_log_config.toml") # If no toml, try loading yaml if log_config is None: log_config = get_log_config(filename="rest_api_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="rest_api") init_console_logging(verbose_level=opts.verbose) try: host, port = rest_api_config.bind[0].split(":") port = int(port) except ValueError as e: print("Unable to parse binding {}: Must be in the format" " host:port".format(rest_api_config.bind[0])) sys.exit(1) wrapped_registry = None if rest_api_config.opentsdb_url: LOGGER.info("Adding metrics reporter: url=%s, db=%s", rest_api_config.opentsdb_url, rest_api_config.opentsdb_db) url = urlparse(rest_api_config.opentsdb_url) proto, db_server, db_port, = url.scheme, url.hostname, url.port registry = MetricsRegistry() wrapped_registry = MetricsRegistryWrapper(registry) reporter = InfluxReporter( registry=registry, reporting_interval=10, database=rest_api_config.opentsdb_db, prefix="sawtooth_rest_api", port=db_port, protocol=proto, server=db_server, username=rest_api_config.opentsdb_username, password=rest_api_config.opentsdb_password) reporter.start() start_rest_api( host, port, connection, int(rest_api_config.timeout), wrapped_registry) # pylint: disable=broad-except except Exception as e: LOGGER.exception(e) sys.exit(1) finally: if connection is not None: connection.close()