コード例 #1
0
    def __init__(self,
                 unresolved_address,
                 sock,
                 max_connection_lifetime,
                 *,
                 auth=None,
                 user_agent=None,
                 routing_context=None):
        self.unresolved_address = unresolved_address
        self.socket = sock
        self.server_info = ServerInfo(Address(sock.getpeername()),
                                      self.PROTOCOL_VERSION)
        self.outbox = Outbox()
        self.inbox = Inbox(self.socket, on_error=self._set_defunct)
        self.packer = Packer(self.outbox)
        self.unpacker = Unpacker(self.inbox)
        self.responses = deque()
        self._max_connection_lifetime = max_connection_lifetime
        self._creation_timestamp = perf_counter()
        self.supports_multiple_results = False
        self.supports_multiple_databases = False
        self._is_reset = True
        self.routing_context = routing_context

        # Determine the user agent
        if user_agent:
            self.user_agent = user_agent
        else:
            self.user_agent = get_user_agent()

        # Determine auth details
        if not auth:
            self.auth_dict = {}
        elif isinstance(auth, tuple) and 2 <= len(auth) <= 3:
            from neo4j import Auth
            self.auth_dict = vars(Auth("basic", *auth))
        else:
            try:
                self.auth_dict = vars(auth)
            except (KeyError, TypeError):
                raise AuthError("Cannot determine auth details from %r" % auth)

        # Check for missing password
        try:
            credentials = self.auth_dict["credentials"]
        except KeyError:
            pass
        else:
            if credentials is None:
                raise AuthError("Password cannot be None")
コード例 #2
0
    def __init__(self,
                 unresolved_address,
                 sock,
                 *,
                 auth=None,
                 protocol_version=None,
                 **config):
        self.config = PoolConfig.consume(config)
        self.protocol_version = protocol_version
        self.unresolved_address = unresolved_address
        self.socket = sock
        self.server = ServerInfo(Address(sock.getpeername()), protocol_version)
        self.outbox = Outbox()
        self.inbox = Inbox(BufferedSocket(self.socket, 32768),
                           on_error=self._set_defunct)
        self.packer = Packer(self.outbox)
        self.unpacker = Unpacker(self.inbox)
        self.responses = deque()
        self._max_connection_lifetime = self.config.max_age
        self._creation_timestamp = perf_counter()

        # Determine the user agent
        user_agent = self.config.user_agent
        if user_agent:
            self.user_agent = user_agent
        else:
            self.user_agent = get_user_agent()

        # Determine auth details
        if not auth:
            self.auth_dict = {}
        elif isinstance(auth, tuple) and 2 <= len(auth) <= 3:
            from neo4j import Auth
            self.auth_dict = vars(Auth("basic", *auth))
        else:
            try:
                self.auth_dict = vars(auth)
            except (KeyError, TypeError):
                raise AuthError("Cannot determine auth details from %r" % auth)

        # Check for missing password
        try:
            credentials = self.auth_dict["credentials"]
        except KeyError:
            pass
        else:
            if credentials is None:
                raise AuthError("Password cannot be None")
コード例 #3
0
    operation = 'highvalue = true'
elif arguments.mode == 'o':
    operation = 'owned = true'
elif arguments.mode == 's':
    operation = 'hassigning = false'
elif not arguments.edge is None:
    operation = 'edge'
else:
    operation = arguments.operation

logger.debug('[*] Operation: ' + operation)

try:
    driver = GraphDatabase.driver(arguments.databaseUri,
                                  auth=Auth(
                                      scheme='basic',
                                      principal=arguments.databaseUser,
                                      credentials=arguments.databasePassword))
    with driver.session() as session:
        for filePath in arguments.filePaths:
            with open(filePath) as file:
                logger.info('[*] Opened file: ' + filePath)

                for line in file:
                    if operation == 'edge':
                        item = line.strip().split(',')
                        logger.debug('[*] Current item: ' + item[0] + ' ' +
                                     item[1])

                        if item[0] and item[1]:
                            source = item[0].upper()
                            destination = item[1].upper()