Skip to content

Commit

Permalink
Merge pull request #45 from UMDBPP/develop
Browse files Browse the repository at this point in the history
minor fixes
  • Loading branch information
zacharyburnett authored Mar 10, 2021
2 parents 945b566 + 7994648 commit 4eb407f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
32 changes: 19 additions & 13 deletions client/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ def __init__(
log_file_frame, variable=self.__toggles['log_file'], command=self.__toggle_log_file
)
log_file_checkbox.grid(row=0, column=0, padx=10)
log_file_checkbox.select()
if log_filename is not None:
log_file_checkbox.select()

self.__elements['log_file_box'] = self.__add_file_box(
log_file_frame,
Expand Down Expand Up @@ -182,6 +183,8 @@ def __init__(
command=self.__toggle_output_file,
)
output_file_checkbox.grid(row=0, column=0, padx=10)
if output_filename is not None:
output_file_checkbox.select()

self.__elements['output_file_box'] = self.__add_file_box(
output_file_frame,
Expand Down Expand Up @@ -219,6 +222,8 @@ def __init__(
command=self.__toggle_prediction_file,
)
prediction_checkbox.grid(row=0, column=0, padx=10)
if prediction_filename is not None:
prediction_checkbox.select()

self.__elements['prediction_file_box'] = self.__add_file_box(
prediction_frame,
Expand Down Expand Up @@ -284,16 +289,17 @@ def __init__(
self.log_filename = log_filename
if self.log_filename is None:
self.log_filename = Path('~') / 'Desktop'
self.__toggle_log_file()

self.output_filename = output_filename
if self.output_filename is None:
self.output_filename = Path('~') / 'Desktop'
set_child_states(self.__elements['output_file_box'], state=tkinter.DISABLED)
self.__toggle_output_file()

self.prediction_filename = prediction_filename
if self.prediction_filename is None:
self.prediction_filename = Path('~') / 'Desktop'
set_child_states(self.__elements['prediction_file_box'], state=tkinter.DISABLED)
self.__toggle_prediction_file()
self.__predictions = {}

self.__windows['main'].protocol('WM_DELETE_WINDOW', self.close)
Expand Down Expand Up @@ -761,10 +767,10 @@ def toggle(self):
raise ConnectionError('missing SSH password')
ssh_tunnel_kwargs['ssh_password'] = password

database_kwargs = self.__configuration['database_database']
database_kwargs = {key.replace('database_', ''): value for key, value in self.__configuration['database'].items()}
if (
'username' not in database_kwargs
or database_kwargs['database_username'] is None
or database_kwargs['username'] is None
):
database_username = simpledialog.askstring(
'Database Username',
Expand All @@ -775,11 +781,11 @@ def toggle(self):
)
if database_username is None or len(database_username) == 0:
raise ConnectionError('missing database username')
database_kwargs['database_username'] = database_username
database_kwargs['username'] = database_username

if (
'database_password' not in database_kwargs
or database_kwargs['database_password'] is None
'password' not in database_kwargs
or database_kwargs['password'] is None
):
database_password = simpledialog.askstring(
'Database Password',
Expand All @@ -790,10 +796,10 @@ def toggle(self):
)
if database_password is None or len(database_password) == 0:
raise ConnectionError('missing database password')
database_kwargs['database_password'] = database_password
database_kwargs['password'] = database_password
if (
'database_table' not in database_kwargs
or database_kwargs['database_table'] is None
'table' not in database_kwargs
or database_kwargs['table'] is None
):
database_table = simpledialog.askstring(
'Database Table',
Expand All @@ -802,14 +808,14 @@ def toggle(self):
)
if database_table is None or len(database_table) == 0:
raise ConnectionError('missing database table name')
database_kwargs['database_table'] = database_table
database_kwargs['table'] = database_table

self.database = APRSDatabaseTable(
**database_kwargs, **ssh_tunnel_kwargs, callsigns=self.callsigns
)
LOGGER.info(f'connected to {self.database.location}')
self.__connections.append(self.database)
self.__configuration['database_database'].update(database_kwargs)
self.__configuration['database'].update(database_kwargs)
self.__configuration['ssh_tunnel'].update(ssh_tunnel_kwargs)
except ConnectionError as error:
connection_errors.append(f'database - {error}')
Expand Down
2 changes: 1 addition & 1 deletion packetraven/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ def __init__(
kwargs['fields'] = {
f'packet_{field}': field_type for field, field_type in kwargs['fields'].items()
}
PacketDatabaseTable.__init__(self, hostname, database, table, **kwargs)
PacketDatabaseTable.__init__(self, hostname=hostname, database=database, table=table, **kwargs)
location = f'postgres://{self.hostname}:{self.port}/{self.database}/{self.name}'
APRSPacketSource.__init__(self, location, callsigns)
APRSPacketSink.__init__(self, location)
Expand Down

0 comments on commit 4eb407f

Please sign in to comment.