-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added new table of recent QSOs and more cleanup of the INI file plus a few others. #69
Changes from 4 commits
bfec6be
c504569
7e0d306
a36a049
b397711
fb554db
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
import matplotlib.pyplot as plt | ||
import pygame | ||
from matplotlib.dates import HourLocator, DateFormatter | ||
import pprint | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what's this for? I don't see any usages. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is a debugging remnant. It can be removed. Sorry. |
||
|
||
from config import Config | ||
from constants import * | ||
|
@@ -210,7 +211,34 @@ def qso_classes_graph(size, qso_classes): | |
values.append(d[0]) | ||
return make_pie(size, values, labels, "QSOs by Class") | ||
|
||
def qso_table(size, qsos): | ||
""" | ||
create the a table of the qso log | ||
""" | ||
if len(qsos) == 0: | ||
return None, (0, 0) | ||
|
||
count = 0 | ||
cells = [['Time', 'Call', 'Band', 'Mode', 'Operator', 'Section', 'Station']] | ||
|
||
for d in qsos: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since the number of qsos is already limited by the fetch, does this need to also limit the size? Another way to do this would be to slice the QSOs e.g. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point. Since the fetch of the records is its own discrete function, this protects the table generation in case a result set of too large a size is returned. That way the generation protects itself without relying upon how big the supplied set is. I wasn't aware of the syntax for d in qsos[:10]. That is handy. |
||
cells.append( ['%s' % datetime.datetime.utcfromtimestamp(d[0]).strftime('%Y %b %d %H:%M:%S') # Time | ||
,'%s' % d[1] # Call | ||
,'%s' % d[2] # Band | ||
,'%s' % d[3] # Mode | ||
,'%s' % d[4] # Operator | ||
,'%s' % d[6] # Section | ||
,'%s' % d[7] # Station | ||
]) | ||
count += 1 | ||
if count >= 10: | ||
break | ||
|
||
if count == 0: | ||
return None, (0, 0) | ||
else: | ||
return draw_table(size, cells, "Last 10 QSOs") | ||
|
||
def qso_operators_table(size, qso_operators): | ||
""" | ||
create the Top 5 QSOs by Operators table | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,6 +50,7 @@ def create_images(size, image_dir, last_qso_timestamp): | |
qsos_per_hour = [] | ||
qsos_by_section = {} | ||
qso_classes = [] | ||
qsos = [] | ||
|
||
db = None | ||
data_updated = False | ||
|
@@ -70,7 +71,9 @@ def create_images(size, image_dir, last_qso_timestamp): | |
last_qso_time, message = dataaccess.get_last_qso(cursor) | ||
|
||
logging.debug('old_timestamp = %s, timestamp = %s' % (last_qso_timestamp, last_qso_time)) | ||
if last_qso_time != last_qso_timestamp: | ||
if config.SKIP_TIMESTAMP_CHECK: | ||
logging.warn('Skipping check for a recent QSO - Please jkust use this for debug - Review SKIP_TIMESTAMP_CHECK in ini file') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo jkust |
||
if last_qso_time != last_qso_timestamp or config.SKIP_TIMESTAMP_CHECK: | ||
# last_qso_time is passed as the result and updated in call to this function. | ||
logging.debug('data updated!') | ||
data_updated = True | ||
|
@@ -95,8 +98,11 @@ def create_images(size, image_dir, last_qso_timestamp): | |
|
||
# load QSOs by Section | ||
qsos_by_section = dataaccess.get_qsos_by_section(cursor) | ||
|
||
# load last 10 qsos | ||
qsos = dataaccess.get_last_N_qsos(cursor, 10) # Note this returns last 10 qsos in reverse order so oldest is first | ||
|
||
logging.debug('load data done') | ||
logging.info('load data done') | ||
except sqlite3.OperationalError as error: | ||
logging.exception(error) | ||
return | ||
|
@@ -115,78 +121,95 @@ def create_images(size, image_dir, last_qso_timestamp): | |
graphics.save_image(image_data, image_size, filename) | ||
except Exception as e: | ||
logging.exception(e) | ||
|
||
try: | ||
image_data, image_size = graphics.qso_rates_table(size, operator_qso_rates) | ||
if image_data is not None: | ||
filename = makePNGTitle(image_dir, 'qso_rates_table') | ||
graphics.save_image(image_data, image_size, filename) | ||
except Exception as e: | ||
logging.exception(e) | ||
|
||
try: | ||
image_data, image_size = graphics.qso_operators_graph(size, qso_operators) | ||
if image_data is not None: | ||
filename = makePNGTitle(image_dir, 'qso_operators_graph') | ||
graphics.save_image(image_data, image_size, filename) | ||
except Exception as e: | ||
logging.exception(e) | ||
|
||
try: | ||
image_data, image_size = graphics.qso_operators_table(size, qso_operators) | ||
if image_data is not None: | ||
filename = makePNGTitle(image_dir, 'qso_operators_table') | ||
graphics.save_image(image_data, image_size, filename) | ||
except Exception as e: | ||
logging.exception(e) | ||
|
||
try: | ||
image_data, image_size = graphics.qso_operators_table_all(size, qso_operators) | ||
if image_data is not None: | ||
filename = makePNGTitle(image_dir, 'qso_operators_table_all') | ||
graphics.save_image(image_data, image_size, filename) | ||
except Exception as e: | ||
logging.exception(e) | ||
|
||
try: | ||
image_data, image_size = graphics.qso_stations_graph(size, qso_stations) | ||
if image_data is not None: | ||
filename = makePNGTitle(image_dir, 'qso_stations_graph') | ||
graphics.save_image(image_data, image_size, filename) | ||
except Exception as e: | ||
logging.exception(e) | ||
|
||
try: | ||
image_data, image_size = graphics.qso_bands_graph(size, qso_band_modes) | ||
if image_data is not None: | ||
filename = makePNGTitle(image_dir, 'qso_bands_graph') | ||
graphics.save_image(image_data, image_size, filename) | ||
except Exception as e: | ||
logging.exception(e) | ||
|
||
try: | ||
image_data, image_size = graphics.qso_modes_graph(size, qso_band_modes) | ||
if image_data is not None: | ||
filename = makePNGTitle(image_dir, 'qso_modes_graph') | ||
graphics.save_image(image_data, image_size, filename) | ||
except Exception as e: | ||
logging.exception(e) | ||
|
||
try: | ||
image_data, image_size = graphics.qso_classes_graph(size, qso_classes) | ||
if image_data is not None: | ||
filename = makePNGTitle(image_dir, 'qso_classes_graph') | ||
graphics.save_image(image_data, image_size, filename) | ||
except Exception as e: | ||
logging.exception(e) | ||
|
||
try: | ||
image_data, image_size = graphics.qso_rates_graph(size, qsos_per_hour) | ||
if image_data is not None: | ||
filename = makePNGTitle(image_dir, 'qso_rates_graph') | ||
graphics.save_image(image_data, image_size, filename) | ||
except Exception as e: | ||
logging.exception(e) | ||
|
||
try: | ||
image_data, image_size = graphics.qso_table(size, qsos) | ||
if image_data is not None: | ||
filename = makePNGTitle(image_dir, 'last_qso_table') | ||
graphics.save_image(image_data, image_size, filename) | ||
except Exception as e: | ||
logging.exception(e) | ||
|
||
# map gets updated every time so grey line moves | ||
try: | ||
# There is a memory leak in the next code -- is there? | ||
image_data, image_size = graphics.draw_map(size, qsos_by_section) | ||
if image_data is not None: | ||
filename = makePNGTitle(image_dir, 'sections_worked_map') | ||
graphics.save_image(image_data, image_size, filename) | ||
gc.collect() | ||
# There is a memory leak in the next code -- is there? | ||
image_data, image_size = graphics.draw_map(size, qsos_by_section) | ||
if image_data is not None: | ||
filename = makePNGTitle(image_dir, 'sections_worked_map') | ||
graphics.save_image(image_data, image_size, filename) | ||
gc.collect() | ||
|
||
except Exception as e: | ||
logging.exception(e) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does your logging software (I think you are not using N1MM) emit a mode of 'SSB'?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have seen other software send SSB. I think TR4W (which I maintain) did but I fixed that issue. This is a belt-and-suspenders approach now more so just in case.