Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions aperturedb/Connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,7 @@ def authenticate(self, shared_data, user, password, token):
if not self.authenticated:
if shared_data.session is None:
self.shared_data.lock = Lock()
try:
self._authenticate(user, password, token)
except Exception as e:
raise UnauthenticatedException(
"Authentication failed:", str(e))
self._authenticate(user, password, token)
Comment thread
drewaogle marked this conversation as resolved.
Resolved
else:
self.shared_data = shared_data
self.authenticated = True
Expand Down Expand Up @@ -327,10 +323,6 @@ def _connect(self):
self.conn = self.context.wrap_socket(self.conn)

except BaseException as e:
logger.error(
f"Error connecting to server: {str(e)} {self.config}",
exc_info=True,
stack_info=True)
self.conn.close()
self.connected = False
raise
Expand All @@ -347,7 +339,7 @@ def connect(self, details: str = None):
self._connect()
except socket.error as e:
logger.error(
f"Error connecting to server: {self.config} \r\n{details}.",
f"Error connecting to server: {self.config} \r\n{details}. {e=}",
exc_info=True,
stack_info=True)

Expand Down Expand Up @@ -436,8 +428,13 @@ def _query(self, query, blob_array = [], try_resume=True):
if try_resume:
self._renew_session()
if tries == self.config.retry_max_attempts:
# We have tried enough times, and failed. Log some state info.
raise Exception(
f"Could not query apertureDB using TCP.")
f"Could not query apertureDB using TCP. \r\n\
{self.connected=}\r\n \
{self.authenticated=} \r\n \
attempts={tries}/{self.config.retry_max_attempts} \r\n \
{self.config=}")
return (self.last_response, response_blob_array)

def query(self, q, blobs=[]):
Expand Down
2 changes: 1 addition & 1 deletion aperturedb/Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def __init__(self, connector: Connector, verbose=False):
self.verbose = verbose

def __repr__(self):
return self.status()
return f"{id(self)}"

def print(self, str):
if self.verbose:
Expand Down
2 changes: 1 addition & 1 deletion aperturedb/cli/adb.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from aperturedb.cli import configure, ingest, utilities, transact

app = typer.Typer()
app = typer.Typer(pretty_exceptions_show_locals=False)

app.add_typer(ingest.app, name="ingest", help="Ingest data into ApertureDB.")
app.add_typer(configure.app, name="config",
Expand Down
8 changes: 5 additions & 3 deletions aperturedb/cli/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def ls(log_to_console: bool = True):
check_configured(as_global)
except json.JSONDecodeError:
check_configured(as_global)
console.log("Failed to decode json")
console.log(f"Failed to decode json '{config_path.as_posix()}'")

if "global" in all_configs or "local" in all_configs:
if "global" in all_configs and len(all_configs["global"]) == 0 \
Expand Down Expand Up @@ -149,8 +149,10 @@ def create(
f"Enter {APP_NAME} username", default=db_username)
db_password = typer.prompt(
f"Enter {APP_NAME} password", hide_input=True, default=db_password)
db_use_rest = typer.confirm(f"Use REST", default=db_use_rest)
db_use_ssl = typer.confirm(f"Use SSL", default=db_use_ssl)
db_use_rest = typer.confirm(
f"Use REST [Note: Only if ApertureDB is setup to recieve http requests]", default=db_use_rest)
db_use_ssl = typer.confirm(
f"Use SSL [Note: ApertureDB's defaults do not allow non SSL traffic]", default=db_use_ssl)

gen_config = Configuration(
name=name,
Expand Down
6 changes: 3 additions & 3 deletions test/test_Session.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def mock_connect(host, port):
new_db.query([{"FindImage": {"results": {"limit": 5}}}])
except Exception as e:
# Check the exception is not an obscure one.
assert e.args[0] == "Authentication failed:"
assert "self.connected=False" in e.args[0]

# Check that we tried to connect 3 times.
assert connect_attempts == 3
Expand All @@ -136,7 +136,7 @@ def mock_send(x, buff):
new_db.query([{"FindImage": {"results": {"limit": 5}}}])
except Exception as e:
# Check the exception is not an obscure one.
assert e.args[0] == "Authentication failed:"
assert "self.connected=False" in e.args[0]

# Check that we tried to send 5 (connect hello:2) + query:3) times.
assert send_attempts == 5
Expand Down Expand Up @@ -164,7 +164,7 @@ def mock_recv(x, buff):
new_db.query([{"FindImage": {"results": {"limit": 5}}}])
except Exception as e:
# Check the exception is not an obscure one.
assert e.args[0] == "Authentication failed:"
assert "self.connected=False" in e.args[0]

# Check that we tried to connect 3 times.
assert connect_attempts == 3
Expand Down