Beispiel #1
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        # Sentry Logging
        if self.log_to_sentry is True:
            initialize_sentry(dsn=NUCYPHER_SENTRY_ENDPOINT)
            globalLogPublisher.addObserver(logToSentry)

        # File Logging
        if self.log_to_file is True:
            globalLogPublisher.addObserver(getTextFileObserver())
            globalLogPublisher.addObserver(getJsonFileObserver())

        # You guessed it
        self.debug = False

        # Logging
        self.quiet = False
        self.log = Logger(self.__class__.__name__)

        # Auth
        self.__keyring_password = NO_PASSWORD

        # Blockchain
        self.accounts = NO_BLOCKCHAIN_CONNECTION
        self.blockchain = NO_BLOCKCHAIN_CONNECTION
Beispiel #2
0
    def __init__(self):

        #
        # Logging
        #

        if self.log_to_sentry:
            import sentry_sdk
            import logging

            sentry_logging = LoggingIntegration(
                level=logging.INFO,  # Capture info and above as breadcrumbs
                event_level=logging.DEBUG  # Send debug logs as events
            )
            sentry_sdk.init(dsn=self.__NUCYPHER_SENTRY_ENDPOINT,
                            integrations=[sentry_logging],
                            release=nucypher.__version__)

            globalLogPublisher.addObserver(logToSentry)

        if self.log_to_file is True:
            globalLogPublisher.addObserver(getTextFileObserver())

        self.log = Logger(self.__class__.__name__)

        # Node Configuration
        self.node_configuration = NO_NODE_CONFIGURATION
        self.dev = NO_NODE_CONFIGURATION
        self.federated_only = NO_NODE_CONFIGURATION
        self.config_root = NO_NODE_CONFIGURATION
        self.config_file = NO_NODE_CONFIGURATION

        # Blockchain
        self.deployer = NO_BLOCKCHAIN_CONNECTION
        self.compile = NO_BLOCKCHAIN_CONNECTION
        self.poa = NO_BLOCKCHAIN_CONNECTION
        self.blockchain = NO_BLOCKCHAIN_CONNECTION
        self.provider_uri = NO_BLOCKCHAIN_CONNECTION
        self.registry_filepath = NO_BLOCKCHAIN_CONNECTION
        self.accounts = NO_BLOCKCHAIN_CONNECTION

        # Agency
        self.token_agent = NO_BLOCKCHAIN_CONNECTION
        self.miner_agent = NO_BLOCKCHAIN_CONNECTION
        self.policy_agent = NO_BLOCKCHAIN_CONNECTION
Beispiel #3
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        # Sentry Logging
        if self.log_to_sentry is True:
            initialize_sentry(dsn=NUCYPHER_SENTRY_ENDPOINT)
            globalLogPublisher.addObserver(logToSentry)

        # File Logging
        if self.log_to_file is True:
            globalLogPublisher.addObserver(getTextFileObserver())
            globalLogPublisher.addObserver(getJsonFileObserver())

        # You guessed it
        self.debug = False

        # Logging
        self.quiet = False
        self.log = Logger(self.__class__.__name__)
Beispiel #4
0
class NucypherClickConfig:

    # Output Sinks
    emitters = list()
    capture_stdout = False
    __sentry_endpoint = NUCYPHER_SENTRY_ENDPOINT

    # Environment Variables
    config_file = os.environ.get('NUCYPHER_CONFIG_FILE', None)
    sentry_endpoint = os.environ.get("NUCYPHER_SENTRY_DSN", __sentry_endpoint)
    log_to_sentry = os.environ.get("NUCYPHER_SENTRY_LOGS", True)
    log_to_file = os.environ.get("NUCYPHER_FILE_LOGS", True)

    # Sentry Logging
    if log_to_sentry is True:
        initialize_sentry(dsn=__sentry_endpoint)
        globalLogPublisher.addObserver(logToSentry)

    # File Logging
    if log_to_file is True:
        globalLogPublisher.addObserver(getTextFileObserver())
        globalLogPublisher.addObserver(getJsonFileObserver())

    def __init__(self):
        self.log = Logger(self.__class__.__name__)
        self.__keyring_password = NO_PASSWORD

    def get_password(self, confirm: bool =False) -> str:
        keyring_password = os.environ.get("NUCYPHER_KEYRING_PASSWORD", NO_PASSWORD)

        if keyring_password is NO_PASSWORD:  # Collect password, prefer env var
            prompt = "Enter keyring password"
            keyring_password = click.prompt(prompt, confirmation_prompt=confirm, hide_input=True)

        self.__keyring_password = keyring_password
        return self.__keyring_password

    @classmethod
    def emit(cls, *args, **kwargs):
        for emitter in cls.emitters:
            emitter(*args, **kwargs)
Beispiel #5
0
class NucypherClickConfig:

    __sentry_endpoint = "https://[email protected]/1310685"  # TODO: Use nucypher domain

    # Environment Variables
    config_file = os.environ.get('NUCYPHER_CONFIG_FILE', None)
    sentry_endpoint = os.environ.get("NUCYPHER_SENTRY_DSN", __sentry_endpoint)
    log_to_sentry = os.environ.get("NUCYPHER_SENTRY_LOGS", True)
    log_to_file = os.environ.get("NUCYPHER_FILE_LOGS", True)

    # Sentry Logging
    if log_to_sentry is True:
        initialize_sentry(dsn=__sentry_endpoint)
        globalLogPublisher.addObserver(logToSentry)

    # File Logging
    if log_to_file is True:
        globalLogPublisher.addObserver(getTextFileObserver())
        globalLogPublisher.addObserver(getJsonFileObserver())

    def __init__(self):
        self.log = Logger(self.__class__.__name__)
        self.__keyring_password = NO_PASSWORD

    def get_password(self, confirm: bool = False) -> str:
        keyring_password = os.environ.get("NUCYPHER_KEYRING_PASSWORD",
                                          NO_PASSWORD)

        if keyring_password is NO_PASSWORD:  # Collect password, prefer env var
            prompt = "Enter keyring password"
            keyring_password = click.prompt(prompt,
                                            confirmation_prompt=confirm,
                                            hide_input=True)

        self.__keyring_password = keyring_password
        return self.__keyring_password
Beispiel #6
0
class NucypherClickConfig:

    # Output Sinks
    emitters = list()
    capture_stdout = False
    __sentry_endpoint = NUCYPHER_SENTRY_ENDPOINT

    # Environment Variables
    config_file = os.environ.get('NUCYPHER_CONFIG_FILE', None)
    sentry_endpoint = os.environ.get("NUCYPHER_SENTRY_DSN", __sentry_endpoint)
    log_to_sentry = os.environ.get("NUCYPHER_SENTRY_LOGS", True)
    log_to_file = os.environ.get("NUCYPHER_FILE_LOGS", True)

    # Sentry Logging
    if log_to_sentry is True:
        initialize_sentry(dsn=__sentry_endpoint)
        globalLogPublisher.addObserver(logToSentry)

    # File Logging
    if log_to_file is True:
        globalLogPublisher.addObserver(getTextFileObserver())
        globalLogPublisher.addObserver(getJsonFileObserver())

    def __init__(self):

        # Logging
        self.quiet = False
        self.log = Logger(self.__class__.__name__)

        # Auth
        self.__keyring_password = NO_PASSWORD

        # Blockchain
        self.accounts = NO_BLOCKCHAIN_CONNECTION
        self.blockchain = NO_BLOCKCHAIN_CONNECTION

    def connect_to_blockchain(self,
                              character_configuration,
                              recompile_contracts: bool = False):
        try:
            character_configuration.connect_to_blockchain(
                recompile_contracts=recompile_contracts)
            character_configuration.connect_to_contracts()
        except EthereumContractRegistry.NoRegistry:
            message = "Cannot configure blockchain character: No contract registry found; " \
                      "Did you mean to pass --federated-only?"
            raise EthereumContractRegistry.NoRegistry(message)

        else:
            self.blockchain = character_configuration.blockchain
            self.accounts = self.blockchain.interface.w3.eth.accounts

    def _get_password(self, confirm: bool = False) -> str:
        keyring_password = os.environ.get("NUCYPHER_KEYRING_PASSWORD",
                                          NO_PASSWORD)

        if keyring_password is NO_PASSWORD:  # Collect password, prefer env var
            prompt = "Enter keyring password"
            keyring_password = click.prompt(prompt,
                                            confirmation_prompt=confirm,
                                            hide_input=True)

        self.__keyring_password = keyring_password
        return self.__keyring_password

    def unlock_keyring(self, character_configuration: NodeConfiguration):
        try:  # Unlock Keyring
            if not self.quiet:
                self.emit('Decrypting keyring...', fg='blue')
            character_configuration.keyring.unlock(
                password=self._get_password())  # Takes ~3 seconds, ~1GB Ram
        except CryptoError:
            raise character_configuration.keyring.AuthenticationFailed

    @classmethod
    def emit(cls, *args, **kwargs):
        for emitter in cls.emitters:
            emitter(*args, **kwargs)
Beispiel #7
0
 def __init__(self):
     if self.log_to_file:
         globalLogPublisher.addObserver(getTextFileObserver())
     self.log = Logger(self.__class__.__name__)