More debugging statements.

pull/17/head
Christian Jacobs 2013-09-14 22:12:10 +01:00
rodzic 45aee6bf74
commit e8c1fafbcc
5 zmienionych plików z 27 dodań i 20 usunięć

Wyświetl plik

@ -25,7 +25,7 @@ class Awards(Gtk.VBox):
""" A tool for tracking progress towards an award. Currently this only supports the DXCC award. """
def __init__(self, parent):
""" Sets up a table for progress tracking purposes. """
""" Set up a table for progress tracking purposes. """
#TODO: This only considers the DXCC award for now.
logging.debug("New Awards instance created!")
@ -63,13 +63,15 @@ class Awards(Gtk.VBox):
self.add(self.treeview)
self.show_all()
logging.debug("Awards table set up successfully.")
self.count()
return
def count(self):
""" Updates the table for progress tracking. """
logging.debug("Counting the band/mode combinations for the awards table.")
""" Update the table for progress tracking. """
logging.debug("Counting the band/mode combinations for the awards table...")
# Wipe everything and start again
self.awards.clear()
# For each mode, add a new list for holding the totals, and initialise the values to zero.
@ -95,5 +97,6 @@ class Awards(Gtk.VBox):
# Insert the rows containing the totals
for i in range(0, len(self.modes)):
self.awards.append([self.modes[i]] + count[i])
logging.debug("Awards table updated.")
return

Wyświetl plik

@ -32,11 +32,9 @@ class DXCluster(Gtk.VBox):
def __init__(self, parent):
""" Set up the DX cluster's Gtk.VBox, and set up a timer so that PyQSO can retrieve new data from the Telnet server every few seconds. """
logging.debug("Setting up the DX cluster...")
Gtk.VBox.__init__(self, spacing=2)
self.check_io_event = GObject.timeout_add(1000, self.on_telnet_io)
self.connection = None
self.parent = parent
@ -88,6 +86,8 @@ class DXCluster(Gtk.VBox):
self.show_all()
logging.debug("DX cluster ready!")
return
def telnet_connect(self, widget=None):
@ -129,15 +129,18 @@ class DXCluster(Gtk.VBox):
self.set_connect_button_sensitive(False)
self.check_io_event = GObject.timeout_add(1000, self._on_telnet_io)
return
def telnet_disconnect(self, widget=None):
""" Disconnect from a Telnet server. """
""" Disconnect from a Telnet server and remove the I/O timer. """
if(self.connection):
self.connection.close()
self.buffer.set_text("")
self.connection = None
self.set_connect_button_sensitive(True)
GObject.source_remove(self.check_io_event)
return
def telnet_send_command(self, widget=None):
@ -147,7 +150,7 @@ class DXCluster(Gtk.VBox):
self.command.set_text("")
return
def on_telnet_io(self):
def _on_telnet_io(self):
""" Retrieve any new data from the Telnet server and print it out in the Gtk.TextView widget. Always returns True to satisfy the GObject timer. """
if(self.connection):
text = self.connection.read_very_eager()
@ -167,11 +170,6 @@ class DXCluster(Gtk.VBox):
self.renderer.scroll_mark_onscreen(end_mark)
return True
def on_delete(self, widget, event):
""" Remove the I/O timer and end the connection with the Telnet server. """
self.telnet_disconnect()
GObject.source_remove(self.check_io_event)
def set_connect_button_sensitive(self, sensitive):
""" Enable/disable the relevant buttons for connecting/disconnecting from a DX cluster, so that users cannot click the connect button if PyQSO is already connected. """

Wyświetl plik

@ -37,7 +37,7 @@ class GreyLine(Gtk.VBox):
def __init__(self, parent):
""" Set up the drawing canvas and the timer which will re-plot the grey line every 30 minutes. """
logging.debug("Setting up the grey line...")
Gtk.VBox.__init__(self, spacing=2)
self.parent = parent
@ -49,6 +49,8 @@ class GreyLine(Gtk.VBox):
self.show_all()
logging.debug("Grey line ready!")
return
def draw(self):
@ -59,6 +61,7 @@ class GreyLine(Gtk.VBox):
# Don't re-draw if the grey line is not visible.
return True # We need to return True in case this is method was called by a timer event.
else:
logging.debug("Drawing the grey line...")
# Re-draw the grey line
self.fig.clf()
sub = self.fig.add_subplot(111)
@ -73,7 +76,7 @@ class GreyLine(Gtk.VBox):
m.drawmapboundary(fill_color='lightblue')
m.fillcontinents(color='darkgreen', lake_color='lightblue')
m.nightshade(datetime.utcnow()) # Add in the grey line using UTC time. Note that this requires NetCDF.
logging.debug("Grey line drawn.")
return True
else:
return False # Don't try to re-draw the canvas if the necessary modules to do so could not be imported.

Wyświetl plik

@ -564,6 +564,7 @@ class Logbook(Gtk.Notebook):
break
elif(self.log_name_exists(log_name) is None):
# Could not determine if the log name exists. It's safer to stop here than to try to add a new log.
error(parent=self.parent, message="Database error. Could not check if the log name exists.")
dialog.destroy()
return
else:
@ -867,7 +868,7 @@ SELECT MIN(rowid) FROM repeater_contacts GROUP BY call, qso_date, time_on, freq,
return len(self.logs)
def log_name_exists(self, table_name):
""" Return True if the log name already exists in the logbook, and False otherwise. """
""" Return True if the log name already exists in the logbook, and False if it does not already exist. Return None if there is a database error. """
try:
c = self.connection.cursor()
c.execute("SELECT EXISTS(SELECT 1 FROM sqlite_master WHERE name=?)", [table_name])
@ -877,8 +878,7 @@ SELECT MIN(rowid) FROM repeater_contacts GROUP BY call, qso_date, time_on, freq,
else:
return False
except sqlite.Error as e:
logging.exception(e)
error(parent=self.parent, message="Database error. Could not check if the log name exists.")
logging.exception(e) # Database error. PyQSO could not check if the log name exists.
return None
def _get_log_index(self, name=None):

Wyświetl plik

@ -28,7 +28,7 @@ class TelnetConnectionDialog(Gtk.Dialog):
This can be used to connect to DX clusters. """
def __init__(self, parent):
logging.debug("New TelnetConnectionDialog instance created!")
logging.debug("Setting up the Telnet connection dialog...")
Gtk.Dialog.__init__(self, title="New Telnet Connection", parent=parent, flags=Gtk.DialogFlags.DESTROY_WITH_PARENT, buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OK, Gtk.ResponseType.OK))
@ -71,11 +71,14 @@ class TelnetConnectionDialog(Gtk.Dialog):
hbox_temp.pack_start(self.sources["PASSWORD"], True, True, 6)
self.vbox.pack_start(hbox_temp, False, False, 6)
logging.debug("Telnet connection dialog ready!")
self.show_all()
return
def get_connection_info(self):
""" Returns the host and login information stored in the Gtk.Entry boxes. """
""" Return the host and login information stored in the Gtk.Entry boxes. """
logging.debug("Returning Telnet connection information...")
return self.sources