[hamradio-commits] [pyqso] 01/03: Imported Upstream version 0.2
Iain Learmonth
irl-guest at moszumanska.debian.org
Mon Mar 23 22:45:18 UTC 2015
This is an automated email from the git hooks/post-receive script.
irl-guest pushed a commit to branch master
in repository pyqso.
commit d6512dc53d8f19afc1f910a36ae1bbd656c98510
Author: Iain R. Learmonth <irl at fsfe.org>
Date: Mon Mar 23 21:39:07 2015 +0000
Imported Upstream version 0.2
---
.gitignore | 4 +
.travis.yml | 24 +++
CHANGELOG.md | 50 ++++++
Makefile | 32 ++--
README.md | 23 ++-
bin/pyqso | 14 +-
doc/images/awards.png | Bin 11921 -> 0 bytes
doc/images/dx_cluster.png | Bin 49197 -> 0 bytes
doc/images/edit_record.png | Bin 42003 -> 0 bytes
doc/images/log_with_awards.png | Bin 59371 -> 0 bytes
doc/manual.tex | 258 ----------------------------
docs/Makefile | 180 ++++++++++++++++++++
docs/make.bat | 242 +++++++++++++++++++++++++++
docs/source/conf.py | 269 ++++++++++++++++++++++++++++++
docs/source/getting_started.rst | 96 +++++++++++
docs/source/images/awards.png | Bin 0 -> 11055 bytes
docs/source/images/dx_cluster.png | Bin 0 -> 62219 bytes
docs/source/images/edit_record.png | Bin 0 -> 44291 bytes
{doc => docs/source}/images/grey_line.png | Bin
docs/source/images/logbook.png | Bin 0 -> 140698 bytes
docs/source/index.rst | 20 +++
docs/source/introduction.rst | 67 ++++++++
docs/source/log_management.rst | 76 +++++++++
docs/source/preferences.rst | 43 +++++
docs/source/pyqso.rst | 134 +++++++++++++++
docs/source/record_management.rst | 71 ++++++++
docs/source/toolbox.rst | 58 +++++++
pyqso/adif.py | 107 ++++++++++--
pyqso/auxiliary_dialogs.py | 9 +-
pyqso/awards.py | 3 +-
pyqso/callsign_lookup.py | 47 +++++-
pyqso/dx_cluster.py | 10 +-
pyqso/grey_line.py | 6 +-
pyqso/log.py | 51 +++---
pyqso/log_name_dialog.py | 3 +-
pyqso/logbook.py | 61 ++++++-
pyqso/menu.py | 3 +-
pyqso/preferences_dialog.py | 80 +++++----
pyqso/record_dialog.py | 31 ++--
pyqso/telnet_connection_dialog.py | 3 +-
pyqso/toolbar.py | 3 +-
pyqso/toolbox.py | 3 +-
setup.py | 8 +-
43 files changed, 1685 insertions(+), 404 deletions(-)
diff --git a/.gitignore b/.gitignore
index 0d20b64..e625f77 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,5 @@
*.pyc
+pyqso.debug
+build/
+docs/build
+ADIF.test*.adi
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..b43b4be
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,24 @@
+language: python
+
+python:
+ - "2.7"
+
+virtualenv:
+ system_site_packages: true
+
+before_install:
+ - sudo apt-get update -qq
+ - sudo apt-get install -y python2.7 gir1.2-gtk-3.0 python-gi-cairo python-mpltoolkits.basemap python-numpy python-matplotlib python-libhamlib2 python-sphinx
+ - "export DISPLAY=:99.0"
+ - "sh -e /etc/init.d/xvfb start"
+
+install:
+ - sudo make install
+
+before_script:
+ - export PYTHONPATH=`pwd`:$PYTHONPATH
+
+script:
+ - make unittest
+ - make docs
+ - sudo make clean
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..8f23c39
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,50 @@
+# Change Log
+
+## [0.2] - 2015-03-07
+### Added
+- Travis CI configuration file for automated building and testing.
+- Button to add the current date and time.
+- Option to specify default values for the power and mode fields.
+- Allow UTC time to be used when creating records.
+- Allow prefixes/suffixes to be removed when looking up a callsign (e.g. "MYCALL" would be extracted from "EA3/MYCALL/M").
+
+### Changed
+- Migrated the documentation to a Sphinx-based setup.
+- Separate the Create and Open functionality for logbooks.
+- In the record dialog, the labels "TX RST" and "RX RST" have been changed to "RST Sent" and "RST Received". The underlying ADIF field names remain the same (RST_SENT and RST_RCVD).
+
+### Fixed
+- Logging debug messages to file.
+- 'Z' characters in callsigns were being ignored when importing ADIF files. This has now been fixed.
+- Specifed the Agg backend for matplotlib to workaround a bug in Ubuntu 14.10.
+- Sorting the date and time fields in the correct chronological order.
+- Removal of duplicate records.
+- Error handling when looking up a callsign that does not have an entry on qrz.com.
+- Handling of ConfigParser.NoOptionError exceptions when trying to load preferences.
+- Handling of UnicodeDecodeError exceptions when parsing the output from DX cluster servers.
+
+## [0.1] - 2014-03-22
+
+### Changed
+- The 'Notes' column is no longer automatically resized.
+- The BEL character is now handled properly in the DX cluster tool.
+- QSOs can now be sorted in the correct chronological order.
+
+### Fixed
+- Fixed the ADIF export functionality. Previously, only markers were being written and the actual record data was being skipped.
+
+## [0.1b] - 2013-10-04
+
+### Added
+- Basic logging functionality.
+- Import and export in ADIF format.
+- Log printing.
+- Basic support for Hamlib.
+- Telnet-based DX cluster support.
+- Progress tracker for the DXCC award.
+- Greyline plotter.
+- QSO filtering and sorting.
+- Duplicate record removal.
+
+[0.2]: https://github.com/ctjacobs/pyqso/compare/v0.1...v0.2
+[0.1]: https://github.com/ctjacobs/pyqso/compare/v0.1b...v0.1
diff --git a/Makefile b/Makefile
index 369177e..bfe6dac 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,6 @@
-#!/usr/bin/env python
-# File: Makefile
+#!/bin/sh
-# Copyright (C) 2013 Christian Jacobs.
+# Copyright (C) 2013 Christian T. Jacobs.
# This file is part of PyQSO.
@@ -18,25 +17,26 @@
# You should have received a copy of the GNU General Public License
# along with PyQSO. If not, see <http://www.gnu.org/licenses/>.
-input: clean install documentation
+.PHONY: input clean install docs unittest
+
+input: clean install docs
install:
- @echo **********Installing PyQSO
+ @echo "*** Installing PyQSO"
python setup.py install
-manual:
- @echo **********Compiling the user manual
- cd doc; pdflatex manual.tex; cd ..
+docs:
+ @echo "*** Building the documentation"
+ cd docs; make html; cd ..
unittest:
- @echo **********Running the unit tests
- cd pyqso; for file in *.py; do (python $$file); done; cd ..
+ @echo "*** Running the unit tests"
+ python -m unittest discover --start-directory=pyqso --pattern=*.py --verbose
clean:
- @echo **********Cleaning build directory
+ @echo "*** Cleaning docs directory"
+ cd docs; make clean; cd ..
+ @echo "*** Cleaning pyqso directory"
+ rm -f ADIF.test_*.adi; cd pyqso; rm -f *.pyc ADIF.test_*.adi; cd ..
+ @echo "*** Removing build directory"
rm -rf build
- @echo **********Cleaning pyqso directory
- cd pyqso; rm -rf *.pyc ADIF.test_read.adi ADIF.test_write*.adi; cd ..
- @echo **********Cleaning doc directory
- cd doc; rm -rf *.log *.aux *.dvi *.pdf *.ps *.toc *.out; cd ..
-
diff --git a/README.md b/README.md
index fa45723..2b10795 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,4 @@
- File: README.md
- Copyright (C) 2013 Christian Jacobs.
+ Copyright (C) 2013 Christian T. Jacobs.
This file is part of PyQSO.
@@ -21,6 +20,9 @@ PyQSO
PyQSO is a contact logging tool for amateur radio operators.
+[](https://travis-ci.org/ctjacobs/pyqso)
+[](https://readthedocs.org/projects/pyqso/?badge=latest)
+
Installation and running
------------------------
@@ -41,11 +43,13 @@ from PyQSO's base directory.
Documentation
-------------
-The PyQSO user manual is stored as a LaTeX source file in the doc/ directory. It can be compiled with the following command:
+The PyQSO documentation is stored in the `docs` directory. It can be built with the following command:
+
+ `make docs`
- `make manual`
+which will produce an HTML version of the documentation in `docs/build/html` that can be opened in a web browser.
-which will produce the manual.pdf file.
+Alternatively, a ready-built version of the PyQSO documentation can be found on [Read the Docs](http://pyqso.readthedocs.org/en/latest/).
Dependencies
------------
@@ -66,3 +70,12 @@ The following extra package is necessary to enable Hamlib support:
* python-libhamlib2
+The following extra package is necessary to build the documentation:
+
+* python-sphinx
+
+Contact
+-------
+
+If you have any comments or questions about PyQSO, please send them via email to <c.jacobs10 at imperial.ac.uk>.
+
diff --git a/bin/pyqso b/bin/pyqso
index c412fb9..eaff9f2 100755
--- a/bin/pyqso
+++ b/bin/pyqso
@@ -1,7 +1,6 @@
#!/usr/bin/env python
-# File: pyqso.py
-# Copyright (C) 2012 Christian Jacobs.
+# Copyright (C) 2012 Christian T. Jacobs.
# This file is part of PyQSO.
@@ -26,8 +25,7 @@ import os.path
import sys
import signal
-# This will help Python find the PyQSO modules
-# that need to be imported below.
+# This will help Python find the PyQSO modules that need to be imported below.
pyqso_path = os.path.join(os.path.realpath(os.path.dirname(__file__)), os.pardir)
sys.path.insert(0, pyqso_path)
@@ -49,7 +47,7 @@ class PyQSO(Gtk.Window):
""" Set up the main (root) window, start the event loop, and open a logbook (if the logbook's path is specified by the user in the command line). """
# Call the constructor of the super class (Gtk.Window)
- Gtk.Window.__init__(self, title="PyQSO 0.2a-dev")
+ Gtk.Window.__init__(self, title="PyQSO 0.2")
# Get any application-specific preferences from the configuration file
config = ConfigParser.ConfigParser()
@@ -115,8 +113,8 @@ class PyQSO(Gtk.Window):
about.set_modal(True)
about.set_transient_for(parent=self)
about.set_program_name("PyQSO")
- about.set_version("0.2a-dev")
- about.set_authors(["Christian Jacobs"])
+ about.set_version("0.2")
+ about.set_authors(["Christian T. Jacobs (M6RDG)"])
about.set_license("""This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
@@ -151,7 +149,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.""")
if(__name__ == "__main__"):
# Get any command line arguments
- parser = argparse.ArgumentParser()
+ parser = argparse.ArgumentParser(prog="pyqso")
parser.add_argument("-d", "--debug", action="store_true", default=False, help="Enable debugging. All debugging messages will be written to pyqso.debug.")
parser.add_argument("-l", "--logbook", action="store", type=str, metavar="/path/to/my_logbook_file.db", default=None, help="Path to a Logbook file. If this file does not already exist, then it will be created.")
args = parser.parse_args()
diff --git a/doc/images/awards.png b/doc/images/awards.png
deleted file mode 100644
index 44b2723..0000000
Binary files a/doc/images/awards.png and /dev/null differ
diff --git a/doc/images/dx_cluster.png b/doc/images/dx_cluster.png
deleted file mode 100644
index fc250a4..0000000
Binary files a/doc/images/dx_cluster.png and /dev/null differ
diff --git a/doc/images/edit_record.png b/doc/images/edit_record.png
deleted file mode 100644
index 4e43456..0000000
Binary files a/doc/images/edit_record.png and /dev/null differ
diff --git a/doc/images/log_with_awards.png b/doc/images/log_with_awards.png
deleted file mode 100644
index 4e7e070..0000000
Binary files a/doc/images/log_with_awards.png and /dev/null differ
diff --git a/doc/manual.tex b/doc/manual.tex
deleted file mode 100644
index e31f1c3..0000000
--- a/doc/manual.tex
+++ /dev/null
@@ -1,258 +0,0 @@
-% PyQSO User Manual
-
-% Copyright (C) 2013 Christian Jacobs.
-
-% This file is part of PyQSO.
-
-% PyQSO is free software: you can redistribute it and/or modify
-% it under the terms of the GNU General Public License as published by
-% the Free Software Foundation, either version 3 of the License, or
-% (at your option) any later version.
-%
-% PyQSO is distributed in the hope that it will be useful,
-% but WITHOUT ANY WARRANTY; without even the implied warranty of
-% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-% GNU General Public License for more details.
-%
-% You should have received a copy of the GNU General Public License
-% along with PyQSO. If not, see <http://www.gnu.org/licenses/>.
-
-\documentclass[11pt, a4paper]{report}
-\usepackage[margin=1.2in]{geometry}
-\usepackage{graphicx}
-\usepackage{hyperref}
-\hypersetup{
- colorlinks=false,
- pdfborder={0 0 0},
- }
-
-\setlength{\parskip}{0.25cm}
-
-\begin{document}
-
-\begin{titlepage}
-\begin{center}
-\vspace*{5cm}
-\huge{PyQSO User Manual}\\\vspace*{5cm}
-\LARGE{Version 0.2a-dev}
-\end{center}
-\end{titlepage}
-
-\tableofcontents
-
-\chapter{Introduction}\label{chap:introduction}
-\section{Overview}
-PyQSO is a logging tool for amateur radio operators. It provides a simple graphical interface through which users can manage information about the contacts/QSOs they make with other operators on the air. All information is stored in a light-weight SQL database. Other key features include:
-\begin{itemize}
- \item Customisable interface (e.g. only show callsign and frequency information).
- \item Import and export logs in ADIF format.
- \item Perform callsign lookups and auto-fill data fields using the qrz.com database.
- \item Sort the logs by individual fields.
- \item Print a hard-copy of logs, or print to PDF.
- \item Connect to Telnet-based DX clusters.
- \item Progress tracker for the DXCC award.
- \item Grey line plotter.
- \item Filter out QSOs based on the callsign field (e.g. only display contacts with callsigns beginning with ``M6'').
- \item Remove duplicate QSOs.
- \item Basic support for the Hamlib library.
-\end{itemize}
-The source code for PyQSO is available for download at:
-
-\texttt{https://github.com/ctjacobs/pyqso}
-
-\section{Data storage model}
-Many amateur radio operators choose to store all the contacts they ever make in a single \textit{logbook}, whereas others keep a separate logbook for each year, for example. Each logbook may be divided up to form multiple distinct \textit{logs}, perhaps one for casual repeater contacts and another for DX'ing. Finally, each log can contain multiple \textit{records}. PyQSO is based around this three-tier model for data storage, going from logbooks at the top to individual records at the bottom.
-
-Rather than storing each log in a separate file, a single database can hold several logs together; in PyQSO, a database is therefore analogous to a logbook. Within a database the user can create multiple tables which are analogous to the logs. Within each table the user can create/modify/delete records which are analogous to the records in each log.
-
-\section{Licensing}
-PyQSO is free software, released under the GNU General Public License. Please see the file called COPYING for more information.
-
-\section{Structure of this manual}
-The structure of this manual is as follows. Chapter \ref{chap:getting_started} is all about getting started with PyQSO -- from the installation process through to creating a new logbook (or opening an existing one). Chapter \ref{chap:log_management} explains how to create a log in the logbook, as well as the basic operations that users can perform with existing logs, such as printing, importing from/exporting to ADIF format, and sorting. Chapter \ref{chap:record_management} deals with th [...]
-
-\chapter{Getting started}\label{chap:getting_started}
-
-\section{System requirements}
-It is recommended that users run PyQSO on the Linux operating system, since all development and testing of PyQSO takes place there.
-
-As the name suggests, PyQSO is written primarily in the Python programming language. The graphical user interface has been built using the GTK+ library through the PyGObject bindings. PyQSO also uses an SQLite embedded database to manage all the contacts an amateur radio operator makes. Users must therefore make sure that the Python interpreter and any additional software dependencies are satisfied before PyQSO can be run successfully. The list of software packages that PyQSO depends on [...]
-
-\section{Installation and running}
-Assuming that the current working directory is PyQSO's base directory (the directory that the Makefile is in), PyQSO can be installed via the terminal with the following command:
-
- \texttt{make install}
-
-\noindent Note: `sudo' may be needed for this. Once installed, the following command will run PyQSO:
-
- \texttt{pyqso}
-
-\noindent Alternatively, PyQSO can be run (without installing) with:
-
- \texttt{python bin/pyqso}
-
-\noindent from PyQSO's base directory.
-
-\subsection{Command-line options}
-There are several options available when executing PyQSO from the command-line.
-
-\subsubsection{Open a specified logbook file}
-In addition to being able to open a new or existing logbook through the graphical interface, users can also specify a logbook file to open at the command line with the \texttt{-l} or \texttt{--logbook} option. For example, to open a logbook file called \texttt{mylogbook.db}, use the following command:
-
- \texttt{pyqso --logbook /path/to/mylogbook.db}
-
-\noindent If the file does not already exist, PyQSO will create it.
-
-\subsubsection{Debugging mode}
-Running PyQSO with the \texttt{-d} or \texttt{--debug} flag enables the debugging mode:
-
- \texttt{pyqso --debug}
-
-\noindent All debugging-related messages are written to a file called pyqso.debug, located in the current working directory.
-
-\section{Opening a new or existing logbook}
-Logbooks are SQL databases, and as such they are accessed with a database connection. To create a connection and open the logbook, click \texttt{Open a New or Existing Logbook...} in the \texttt{Logbook} menu, and either:
-\begin{itemize}
- \item Find and select an existing logbook database file (which usually has a \texttt{.db} file extension), and click \texttt{Open} to create the database connection; or
- \item Create a new database by entering a (non-existing) file name and clicking \texttt{Open}. The logbook database file (and a connection to it) will then be created automatically.
-\end{itemize}
-Once the database connection has been established, the database file name will appear in the status bar. All logs in the logbook will be opened automatically, and the interface will look something like the one shown in Figure \ref{fig:log_view_with_awards}.
-
-\begin{figure}
- \centering
- \includegraphics[width=1\columnwidth]{images/log_with_awards.png}
- \caption{The PyQSO main window, showing the records in a log called \texttt{repeater\_contacts}, and the awards tool in the toolbox below it.}
- \label{fig:log_view_with_awards}
-\end{figure}
-
-\section{Closing a logbook}
-A logbook can be closed (along with its corresponding database connection) by clicking the \texttt{Close Logbook} button in the toolbar, or by clicking \texttt{Close Logbook} in the \texttt{Logbook} menu.
-
-\chapter{Log management}\label{chap:log_management}
-\noindent\textbf{Note 1:} All the operations described below assume that a logbook is already open.
-
-\noindent\textbf{Note 2:} Any modifications made to the logs are permanent. Users should make sure they keep up-to-date backups.
-
-\section{Creating a new log}
-To create a new log, click \texttt{New Log} in the \texttt{Logbook} menu and enter the desired name of the log (e.g. repeater\_contacts, dx, mobile\_log). Alternatively, use the shortcut key combination \texttt{Ctrl + N}.
-
-The log name must be unique (i.e. it cannot already exist in the logbook). Furthermore, it can only be composed of alphanumeric characters and the underscore character, and the first character in the name must not be a number.
-
-Note: When logs are stored in the database file, field/column names from the ADIF standard are used. However, please note that only the following subset of all the ADIF fields is considered: CALL, QSO\_DATE, TIME\_ON, FREQ, BAND, MODE, TX\_PWR, RST\_SENT, RST\_RCVD, QSL\_SENT, QSL\_RCVD, NOTES, NAME, ADDRESS, STATE, COUNTRY, DXCC, CQZ, ITUZ, IOTA. Visit http://adif.org/ for more information about these fields.
-
-\section{Renaming a log}
-To rename the currently selected log, click \texttt{Rename Selected Log} in the \texttt{Logbook} menu. Remember that the log's new name cannot be the same as another log in the logbook.
-
-\section{Deleting a log}
-To delete the currently selected log, click \texttt{Delete Selected Log} in the \texttt{Logbook} menu. As with all database operations in PyQSO, this is permanent and cannot be undone.
-
-\section{Importing and exporting a log}
-While PyQSO stores logbooks in SQL format, it is possible to export individual logs in the well-known ADIF format. Select the log to export, and click \texttt{Export Log} in the \texttt{Logbook} menu.
-
-Similarly, records can be imported from an ADIF file. Upon importing, users can choose to store the records in a new log, or append them to an existing log in the logbook. To import, click \texttt{Import Log} in the \texttt{Logbook} menu.
-
-Note that all data must conform to the ADIF standard, otherwise it will be ignored.
-
-\section{Printing a log}
-Due to restrictions on the page width, only a selection of field names will be printed: callsign, date, time, frequency, and mode.
-
-\section{Filtering by callsign}
-Entering an expression such as \texttt{xyz} into the \texttt{Filter by callsign} box will instantly filter out all records whose callsign field does not contain \texttt{xyz}.
-
-\section{Sorting by field}
-To sort a log by a particular field name, left-click the column header that contains that field name. By default, it is the \texttt{Index} field that is sorted in ascending order.
-
-\chapter{Record management}\label{chap:record_management}
-
-\noindent\textbf{Note:} Any modifications made to the records are permanent. Users should make sure they keep up-to-date backups.
-
-\section{Creating a new record (QSO)}
-A new QSO can be added by either:
-\begin{itemize}
- \item Clicking the \texttt{Add Record} button in the toolbar.
- \item Pressing \texttt{Ctrl + R}.
- \item Clicking \texttt{Add Record...} in the \texttt{Records} menu.
-\end{itemize}
-A dialog window will appear where details of the QSO can be entered (see Figure \ref{fig:edit_record}). Note that the current date and time are filled in automatically. When ready, click \texttt{OK} to save the changes.
-
-\begin{figure}
- \centering
- \includegraphics[width=1\columnwidth]{images/edit_record.png}
- \caption{Record dialog used to add new records and edit existing ones.}
- \label{fig:edit_record}
-\end{figure}
-
-\subsection{Callsign lookup}
-PyQSO can also resolve station-related information (e.g. the operator's name, address, and ITU Zone) by clicking the \texttt{Lookup on qrz.com} button adjacent to the Callsign data entry box. Note that the user must first supply their qrz.com account information in the preferences dialog window.
-
-\section{Editing a record}
-An existing record can be edited by:
-\begin{itemize}
- \item Double-clicking on it.
- \item Selecting it and clicking the \texttt{Edit Record} button in the toolbar.
- \item Selecting it and clicking \texttt{Edit Selected Record...} in the \texttt{Records} menu.
-\end{itemize}
-This will bring up the same dialog window as before.
-
-\section{Deleting a record}
-An existing record can be deleted by:
-\begin{itemize}
- \item Selecting it and clicking the \texttt{Delete Record} button in the toolbar.
- \item Selecting it and pressing the \texttt{Delete} key.
- \item Selecting it and clicking \texttt{Delete Selected Record...} in the \texttt{Records} menu.
-\end{itemize}
-
-\section{Removing duplicate records}
-PyQSO can find and delete duplicate records in a log. A record is a duplicate of another if its data in the Callsign, Date, Time, Frequency, and Mode fields are the same. Click \texttt{Remove Duplicate Records} in the \texttt{Records} menu.
-
-\chapter{Toolbox}\label{chap:toolbox}
-The toolbox is hidden by default. To show it, click \texttt{Toolbox} in the \texttt{View} menu.
-
-\section{DX cluster}
-A DX cluster is essentially a server through which amateur radio operators can report and receive updates about QSOs that are in progress across the bands. PyQSO is able to connect to a DX cluster that operates using the Telnet protocol to provide a text-based alert service. As a result of the many different Telnet-based software products that DX clusters run, PyQSO currently outputs the raw data received from the DX cluster rather than trying to parse it in some way.
-
-Click on the \texttt{Connect to Telnet Server} button and enter the DX server details in the dialog that appears. If no port is specified, PyQSO will use the default value of 23. A username and password may also need to be supplied. Once connected, the server output will appear in the DX cluster frame (see Figure \ref{fig:dx_cluster}). A command can also be sent to the server by typing it into the entry box and clicking the adjacent \texttt{Send Command} button.
-
-\begin{figure}
- \centering
- \includegraphics[width=1\columnwidth]{images/dx_cluster.png}
- \caption{The DX cluster frame.}
- \label{fig:dx_cluster}
-\end{figure}
-
-\section{Grey line}
-The grey line tool (see Figure \ref{fig:grey_line}) can be used to check which parts of the world are in darkness. The position of the grey line is automatically updated every 30 minutes.
-
-\begin{figure}
- \centering
- \includegraphics[width=1\columnwidth]{images/grey_line.png}
- \caption{The grey line tool.}
- \label{fig:grey_line}
-\end{figure}
-
-\section{Awards}
-The awards progress tracker (see Figure \ref{fig:awards}) updates its data each time a record is added, deleted, or modified. Currently only the DXCC award is supported (visit http://www.arrl.org/dxcc for more information).
-
-\begin{figure}
- \centering
- \includegraphics[width=1\columnwidth]{images/awards.png}
- \caption{The award progress tracker.}
- \label{fig:awards}
-\end{figure}
-
-\chapter{Preferences}\label{chap:preferences}
-PyQSO user preferences are stored in a configuration file located at \texttt{\textasciitilde/.pyqso.ini}, where \texttt{\textasciitilde} denotes the user's home directory.
-
-\section{General}
-Under the \texttt{General} tab, the user can choose to show the toolbox (see Chapter \ref{chap:toolbox}) when PyQSO is started.
-
-The user can also enter their login details to access the qrz.com database. Note that these details are currently stored in plain text (unencrypted) format.
-
-\section{View}
-Not all the available fields have to be displayed in the logbook. The user can choose to hide a subset of them by unchecking them in the \texttt{View} tab. PyQSO must be restarted in order for any changes to take effect.
-
-\section{Hamlib support}\label{sect:hamlib}
-PyQSO features rudimentary support for the Hamlib library. The name and path of the radio device connected to the user's computer can be specified in the \texttt{Hamlib} tab of the preferences dialog. Upon adding a new record to the log, PyQSO will use Hamlib to retrieve the current frequency that the radio device is set to and automatically fill in the Frequency field.
-
-\bibliographystyle{plainnat}
-\end{document}
diff --git a/docs/Makefile b/docs/Makefile
new file mode 100644
index 0000000..ea0fe8b
--- /dev/null
+++ b/docs/Makefile
@@ -0,0 +1,180 @@
+# Makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS =
+SPHINXBUILD = sphinx-build
+PAPER =
+BUILDDIR = build
+
+# User-friendly check for sphinx-build
+ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
+$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
+endif
+
+# Internal variables.
+PAPEROPT_a4 = -D latex_paper_size=a4
+PAPEROPT_letter = -D latex_paper_size=letter
+ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
+# the i18n builder cannot share the environment and doctrees with the others
+I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
+
+.PHONY: help clean aptdoc html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
+
+help:
+ @echo "Please use \`make <target>' where <target> is one of"
+ @echo " html to make standalone HTML files"
+ @echo " dirhtml to make HTML files named index.html in directories"
+ @echo " singlehtml to make a single large HTML file"
+ @echo " pickle to make pickle files"
+ @echo " json to make JSON files"
+ @echo " htmlhelp to make HTML files and a HTML help project"
+ @echo " qthelp to make HTML files and a qthelp project"
+ @echo " devhelp to make HTML files and a Devhelp project"
+ @echo " epub to make an epub"
+ @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
+ @echo " latexpdf to make LaTeX files and run them through pdflatex"
+ @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
+ @echo " text to make text files"
+ @echo " man to make manual pages"
+ @echo " texinfo to make Texinfo files"
+ @echo " info to make Texinfo files and run them through makeinfo"
+ @echo " gettext to make PO message catalogs"
+ @echo " changes to make an overview of all changed/added/deprecated items"
+ @echo " xml to make Docutils-native XML files"
+ @echo " pseudoxml to make pseudoxml-XML files for display purposes"
+ @echo " linkcheck to check all external links for integrity"
+ @echo " doctest to run all doctests embedded in the documentation (if enabled)"
+
+clean:
+ rm -rf $(BUILDDIR)/*
+
+apidoc:
+ sphinx-apidoc ../pyqso -o source/ -f -T
+
+html: apidoc
+ $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
+ @echo
+ @echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
+
+dirhtml:
+ $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
+ @echo
+ @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
+
+singlehtml:
+ $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
+ @echo
+ @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
+
+pickle:
+ $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
+ @echo
+ @echo "Build finished; now you can process the pickle files."
+
+json:
+ $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
+ @echo
+ @echo "Build finished; now you can process the JSON files."
+
+htmlhelp:
+ $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
+ @echo
+ @echo "Build finished; now you can run HTML Help Workshop with the" \
+ ".hhp project file in $(BUILDDIR)/htmlhelp."
+
+qthelp:
+ $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
+ @echo
+ @echo "Build finished; now you can run "qcollectiongenerator" with the" \
+ ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
+ @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/PyQSO.qhcp"
+ @echo "To view the help file:"
+ @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/PyQSO.qhc"
+
+devhelp:
+ $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
+ @echo
+ @echo "Build finished."
+ @echo "To view the help file:"
+ @echo "# mkdir -p $$HOME/.local/share/devhelp/PyQSO"
+ @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/PyQSO"
+ @echo "# devhelp"
+
+epub:
+ $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
+ @echo
+ @echo "Build finished. The epub file is in $(BUILDDIR)/epub."
+
+latex:
+ $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+ @echo
+ @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
+ @echo "Run \`make' in that directory to run these through (pdf)latex" \
+ "(use \`make latexpdf' here to do that automatically)."
+
+latexpdf:
+ $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+ @echo "Running LaTeX files through pdflatex..."
+ $(MAKE) -C $(BUILDDIR)/latex all-pdf
+ @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+
+latexpdfja:
+ $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+ @echo "Running LaTeX files through platex and dvipdfmx..."
+ $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
+ @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+
+text:
+ $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
+ @echo
+ @echo "Build finished. The text files are in $(BUILDDIR)/text."
+
+man:
+ $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
+ @echo
+ @echo "Build finished. The manual pages are in $(BUILDDIR)/man."
+
+texinfo:
+ $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+ @echo
+ @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
+ @echo "Run \`make' in that directory to run these through makeinfo" \
+ "(use \`make info' here to do that automatically)."
+
+info:
+ $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+ @echo "Running Texinfo files through makeinfo..."
+ make -C $(BUILDDIR)/texinfo info
+ @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
+
+gettext:
+ $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
+ @echo
+ @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
+
+changes:
+ $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
+ @echo
+ @echo "The overview file is in $(BUILDDIR)/changes."
+
+linkcheck:
+ $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
+ @echo
+ @echo "Link check complete; look for any errors in the above output " \
+ "or in $(BUILDDIR)/linkcheck/output.txt."
+
+doctest:
+ $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
+ @echo "Testing of doctests in the sources finished, look at the " \
+ "results in $(BUILDDIR)/doctest/output.txt."
+
+xml:
+ $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
+ @echo
+ @echo "Build finished. The XML files are in $(BUILDDIR)/xml."
+
+pseudoxml:
+ $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
+ @echo
+ @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
diff --git a/docs/make.bat b/docs/make.bat
new file mode 100644
index 0000000..d5661b2
--- /dev/null
+++ b/docs/make.bat
@@ -0,0 +1,242 @@
+ at ECHO OFF
+
+REM Command file for Sphinx documentation
+
+if "%SPHINXBUILD%" == "" (
+ set SPHINXBUILD=sphinx-build
+)
+set BUILDDIR=build
+set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% source
+set I18NSPHINXOPTS=%SPHINXOPTS% source
+if NOT "%PAPER%" == "" (
+ set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
+ set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS%
+)
+
+if "%1" == "" goto help
+
+if "%1" == "help" (
+ :help
+ echo.Please use `make ^<target^>` where ^<target^> is one of
+ echo. html to make standalone HTML files
+ echo. dirhtml to make HTML files named index.html in directories
+ echo. singlehtml to make a single large HTML file
+ echo. pickle to make pickle files
+ echo. json to make JSON files
+ echo. htmlhelp to make HTML files and a HTML help project
+ echo. qthelp to make HTML files and a qthelp project
+ echo. devhelp to make HTML files and a Devhelp project
+ echo. epub to make an epub
+ echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter
+ echo. text to make text files
+ echo. man to make manual pages
+ echo. texinfo to make Texinfo files
+ echo. gettext to make PO message catalogs
+ echo. changes to make an overview over all changed/added/deprecated items
+ echo. xml to make Docutils-native XML files
+ echo. pseudoxml to make pseudoxml-XML files for display purposes
+ echo. linkcheck to check all external links for integrity
+ echo. doctest to run all doctests embedded in the documentation if enabled
+ goto end
+)
+
+if "%1" == "clean" (
+ for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
+ del /q /s %BUILDDIR%\*
+ goto end
+)
+
+
+%SPHINXBUILD% 2> nul
+if errorlevel 9009 (
+ echo.
+ echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
+ echo.installed, then set the SPHINXBUILD environment variable to point
+ echo.to the full path of the 'sphinx-build' executable. Alternatively you
+ echo.may add the Sphinx directory to PATH.
+ echo.
+ echo.If you don't have Sphinx installed, grab it from
+ echo.http://sphinx-doc.org/
+ exit /b 1
+)
+
+if "%1" == "html" (
+ %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The HTML pages are in %BUILDDIR%/html.
+ goto end
+)
+
+if "%1" == "dirhtml" (
+ %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
+ goto end
+)
+
+if "%1" == "singlehtml" (
+ %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.
+ goto end
+)
+
+if "%1" == "pickle" (
+ %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished; now you can process the pickle files.
+ goto end
+)
+
+if "%1" == "json" (
+ %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished; now you can process the JSON files.
+ goto end
+)
+
+if "%1" == "htmlhelp" (
+ %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished; now you can run HTML Help Workshop with the ^
+.hhp project file in %BUILDDIR%/htmlhelp.
+ goto end
+)
+
+if "%1" == "qthelp" (
+ %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished; now you can run "qcollectiongenerator" with the ^
+.qhcp project file in %BUILDDIR%/qthelp, like this:
+ echo.^> qcollectiongenerator %BUILDDIR%\qthelp\PyQSO.qhcp
+ echo.To view the help file:
+ echo.^> assistant -collectionFile %BUILDDIR%\qthelp\PyQSO.ghc
+ goto end
+)
+
+if "%1" == "devhelp" (
+ %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished.
+ goto end
+)
+
+if "%1" == "epub" (
+ %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The epub file is in %BUILDDIR%/epub.
+ goto end
+)
+
+if "%1" == "latex" (
+ %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
+ goto end
+)
+
+if "%1" == "latexpdf" (
+ %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
+ cd %BUILDDIR%/latex
+ make all-pdf
+ cd %BUILDDIR%/..
+ echo.
+ echo.Build finished; the PDF files are in %BUILDDIR%/latex.
+ goto end
+)
+
+if "%1" == "latexpdfja" (
+ %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
+ cd %BUILDDIR%/latex
+ make all-pdf-ja
+ cd %BUILDDIR%/..
+ echo.
+ echo.Build finished; the PDF files are in %BUILDDIR%/latex.
+ goto end
+)
+
+if "%1" == "text" (
+ %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The text files are in %BUILDDIR%/text.
+ goto end
+)
+
+if "%1" == "man" (
+ %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The manual pages are in %BUILDDIR%/man.
+ goto end
+)
+
+if "%1" == "texinfo" (
+ %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo.
+ goto end
+)
+
+if "%1" == "gettext" (
+ %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The message catalogs are in %BUILDDIR%/locale.
+ goto end
+)
+
+if "%1" == "changes" (
+ %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.The overview file is in %BUILDDIR%/changes.
+ goto end
+)
+
+if "%1" == "linkcheck" (
+ %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Link check complete; look for any errors in the above output ^
+or in %BUILDDIR%/linkcheck/output.txt.
+ goto end
+)
+
+if "%1" == "doctest" (
+ %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Testing of doctests in the sources finished, look at the ^
+results in %BUILDDIR%/doctest/output.txt.
+ goto end
+)
+
+if "%1" == "xml" (
+ %SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The XML files are in %BUILDDIR%/xml.
+ goto end
+)
+
+if "%1" == "pseudoxml" (
+ %SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml.
+ goto end
+)
+
+:end
diff --git a/docs/source/conf.py b/docs/source/conf.py
new file mode 100644
index 0000000..b2a7956
--- /dev/null
+++ b/docs/source/conf.py
@@ -0,0 +1,269 @@
+# -*- coding: utf-8 -*-
+#
+# PyQSO documentation build configuration file, created by
+# sphinx-quickstart on Sun Feb 8 12:09:34 2015.
+#
+# This file is execfile()d with the current directory set to its
+# containing dir.
+#
+# Note that not all possible configuration values are present in this
+# autogenerated file.
+#
+# All configuration values have a default; values that are commented out
+# serve to show the default.
+
+import sys
+import os
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+print os.path.abspath(".")
+sys.path.insert(0, os.path.abspath('../../'))
+
+# -- General configuration ------------------------------------------------
+
+# If your documentation needs a minimal Sphinx version, state it here.
+#needs_sphinx = '1.0'
+
+# Add any Sphinx extension module names here, as strings. They can be
+# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
+# ones.
+extensions = [
+ 'sphinx.ext.autodoc',
+ 'sphinx.ext.intersphinx',
+ 'sphinx.ext.mathjax',
+ 'sphinx.ext.ifconfig',
+ 'sphinx.ext.viewcode',
+]
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ['_templates']
+
+# The suffix of source filenames.
+source_suffix = '.rst'
+
+# The encoding of source files.
+#source_encoding = 'utf-8-sig'
+
+# The master toctree document.
+master_doc = 'index'
+
+# General information about the project.
+project = u'PyQSO'
+copyright = u'2015, Christian T. Jacobs'
+
+# The version info for the project you're documenting, acts as replacement for
+# |version| and |release|, also used in various other places throughout the
+# built documents.
+#
+# The short X.Y version.
+version = '0.2'
+# The full version, including alpha/beta/rc tags.
+release = '0.2'
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#language = None
+
+# There are two options for replacing |today|: either, you set today to some
+# non-false value, then it is used:
+#today = ''
+# Else, today_fmt is used as the format for a strftime call.
+#today_fmt = '%B %d, %Y'
+
+# List of patterns, relative to source directory, that match files and
+# directories to ignore when looking for source files.
+exclude_patterns = []
+
+# The reST default role (used for this markup: `text`) to use for all
+# documents.
+#default_role = None
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+#add_function_parentheses = True
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+#add_module_names = True
+
+# If true, sectionauthor and moduleauthor directives will be shown in the
+# output. They are ignored by default.
+#show_authors = False
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = 'sphinx'
+
+# A list of ignored prefixes for module index sorting.
+#modindex_common_prefix = []
+
+# If true, keep warnings as "system message" paragraphs in the built documents.
+#keep_warnings = False
+
+
+# -- Options for HTML output ----------------------------------------------
+
+# The theme to use for HTML and HTML Help pages. See the documentation for
+# a list of builtin themes.
+html_theme = 'default'
+
+# Theme options are theme-specific and customize the look and feel of a theme
+# further. For a list of options available for each theme, see the
+# documentation.
+#html_theme_options = {}
+
+# Add any paths that contain custom themes here, relative to this directory.
+#html_theme_path = []
+
+# The name for this set of Sphinx documents. If None, it defaults to
+# "<project> v<release> documentation".
+#html_title = None
+
+# A shorter title for the navigation bar. Default is the same as html_title.
+#html_short_title = None
+
+# The name of an image file (relative to this directory) to place at the top
+# of the sidebar.
+#html_logo = None
+
+# The name of an image file (within the static path) to use as favicon of the
+# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
+# pixels large.
+#html_favicon = None
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+html_static_path = []
+
+# Add any extra paths that contain custom files (such as robots.txt or
+# .htaccess) here, relative to this directory. These files are copied
+# directly to the root of the documentation.
+#html_extra_path = []
+
+# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
+# using the given strftime format.
+#html_last_updated_fmt = '%b %d, %Y'
+
+# If true, SmartyPants will be used to convert quotes and dashes to
+# typographically correct entities.
+#html_use_smartypants = True
+
+# Custom sidebar templates, maps document names to template names.
+#html_sidebars = {}
+
+# Additional templates that should be rendered to pages, maps page names to
+# template names.
+#html_additional_pages = {}
+
+# If false, no module index is generated.
+html_domain_indices = True
+
+# If false, no index is generated.
+#html_use_index = True
+
+# If true, the index is split into individual pages for each letter.
+#html_split_index = False
+
+# If true, links to the reST sources are added to the pages.
+#html_show_sourcelink = True
+
+# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
+#html_show_sphinx = True
+
+# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
+#html_show_copyright = True
+
+# If true, an OpenSearch description file will be output, and all pages will
+# contain a <link> tag referring to it. The value of this option must be the
+# base URL from which the finished HTML is served.
+#html_use_opensearch = ''
+
+# This is the file name suffix for HTML files (e.g. ".xhtml").
+#html_file_suffix = None
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = 'PyQSOdoc'
+
+
+# -- Options for LaTeX output ---------------------------------------------
+
+latex_elements = {
+# The paper size ('letterpaper' or 'a4paper').
+#'papersize': 'letterpaper',
+
+# The font size ('10pt', '11pt' or '12pt').
+#'pointsize': '10pt',
+
+# Additional stuff for the LaTeX preamble.
+#'preamble': '',
+}
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title,
+# author, documentclass [howto, manual, or own class]).
+latex_documents = [
+ ('index', 'PyQSO.tex', u'PyQSO Documentation',
+ u'Christian T. Jacobs', 'manual'),
+]
+
+# The name of an image file (relative to this directory) to place at the top of
+# the title page.
+#latex_logo = None
+
+# For "manual" documents, if this is true, then toplevel headings are parts,
+# not chapters.
+#latex_use_parts = False
+
+# If true, show page references after internal links.
+#latex_show_pagerefs = False
+
+# If true, show URL addresses after external links.
+#latex_show_urls = False
+
+# Documents to append as an appendix to all manuals.
+#latex_appendices = []
+
+# If false, no module index is generated.
+#latex_domain_indices = True
+
+
+# -- Options for manual page output ---------------------------------------
+
+# One entry per manual page. List of tuples
+# (source start file, name, description, authors, manual section).
+man_pages = [
+ ('index', 'pyqso', u'PyQSO Documentation',
+ [u'Christian T. Jacobs'], 1)
+]
+
+# If true, show URL addresses after external links.
+#man_show_urls = False
+
+
+# -- Options for Texinfo output -------------------------------------------
+
+# Grouping the document tree into Texinfo files. List of tuples
+# (source start file, target name, title, author,
+# dir menu entry, description, category)
+texinfo_documents = [
+ ('index', 'PyQSO', u'PyQSO Documentation',
+ u'Christian T. Jacobs', 'PyQSO', 'A contact logging tool for amateur radio operators.',
+ 'Miscellaneous'),
+]
+
+# Documents to append as an appendix to all manuals.
+#texinfo_appendices = []
+
+# If false, no module index is generated.
+#texinfo_domain_indices = True
+
+# How to display URL addresses: 'footnote', 'no', or 'inline'.
+#texinfo_show_urls = 'footnote'
+
+# If true, do not generate a @detailmenu in the "Top" node's menu.
+#texinfo_no_detailmenu = False
+
+
+# Example configuration for intersphinx: refer to the Python standard library.
+intersphinx_mapping = {'http://docs.python.org/': None}
diff --git a/docs/source/getting_started.rst b/docs/source/getting_started.rst
new file mode 100644
index 0000000..ef9e0ad
--- /dev/null
+++ b/docs/source/getting_started.rst
@@ -0,0 +1,96 @@
+Getting started
+===============
+
+System requirements
+-------------------
+
+It is recommended that users run PyQSO on the Linux operating system,
+since all development and testing of PyQSO takes place there.
+
+As the name suggests, PyQSO is written primarily in the Python
+programming language. The graphical user interface has been built using
+the GTK+ library through the PyGObject bindings. PyQSO also uses an
+SQLite embedded database to manage all the contacts an amateur radio
+operator makes. Users must therefore make sure that the Python
+interpreter and any additional software dependencies are satisfied
+before PyQSO can be run successfully. The list of software packages that
+PyQSO depends on is provided in the ``README.md`` file.
+
+Installation and running
+------------------------
+
+Assuming that the current working directory is PyQSO's base directory
+(the directory that the Makefile is in), PyQSO can be installed via the
+terminal with the following command:
+
+.. code-block:: bash
+
+ make install
+
+Note: ``sudo`` may be needed for this. Once installed, the following
+command will run PyQSO:
+
+.. code-block:: bash
+
+ pyqso
+
+Alternatively, PyQSO can be run (without installing) with:
+
+.. code-block:: bash
+
+ python bin/pyqso
+
+from PyQSO's base directory.
+
+Command-line options
+~~~~~~~~~~~~~~~~~~~~
+
+There are several options available when executing PyQSO from the
+command-line.
+
+Open a specified logbook file
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+In addition to being able to open a new or existing logbook through the
+graphical interface, users can also specify a logbook file to open at
+the command line with the ``-l`` or ``--logbook`` option. For example, to
+open a logbook file called ``mylogbook.db``, use the following command:
+
+.. code-block:: bash
+
+ pyqso --logbook /path/to/mylogbook.db
+
+If the file does not already exist, PyQSO will create it.
+
+Debugging mode
+^^^^^^^^^^^^^^
+
+Running PyQSO with the ``-d`` or ``--debug`` flag enables the debugging
+mode:
+
+.. code-block:: bash
+
+ pyqso --debug
+
+All debugging-related messages are written to a file called ``pyqso.debug``,
+located in the current working directory.
+
+
+Creating and opening a logbook
+------------------------------
+
+A PyQSO-based logbook is essentially an SQL database. To create a new database/logbook file, click ``Create a New Logbook...`` in the ``Logbook`` menu, choose the directory where you want the file to be saved, and enter the file's name (e.g. ``my_new_logbook.db``). The new logbook will then be opened automatically. If you would like to open an *existing* logbook file, click ``Open an Existing Logbook...`` in the ``Logbook`` menu. Note that logbook files usually have a ``.db`` file extension.
+
+Once the logbook has been opened, its name will appear in the status bar. All logs in the logbook will be opened automatically, and the interface will look something like the one shown in figure:logbook_.
+
+ .. _figure:logbook:
+ .. figure:: images/logbook.png
+ :align: center
+
+ The PyQSO main window, showing the records in a log called ``HF``, and the DX cluster tool in the toolbox below it.
+
+Closing a logbook
+-----------------
+
+A logbook can be closed by clicking the ``Close Logbook`` button in the toolbar, or by clicking ``Close Logbook`` in the ``Logbook`` menu.
+
diff --git a/docs/source/images/awards.png b/docs/source/images/awards.png
new file mode 100644
index 0000000..991e4ae
Binary files /dev/null and b/docs/source/images/awards.png differ
diff --git a/docs/source/images/dx_cluster.png b/docs/source/images/dx_cluster.png
new file mode 100644
index 0000000..1623402
Binary files /dev/null and b/docs/source/images/dx_cluster.png differ
diff --git a/docs/source/images/edit_record.png b/docs/source/images/edit_record.png
new file mode 100644
index 0000000..d74eba0
Binary files /dev/null and b/docs/source/images/edit_record.png differ
diff --git a/doc/images/grey_line.png b/docs/source/images/grey_line.png
similarity index 100%
rename from doc/images/grey_line.png
rename to docs/source/images/grey_line.png
diff --git a/docs/source/images/logbook.png b/docs/source/images/logbook.png
new file mode 100644
index 0000000..77c6d6b
Binary files /dev/null and b/docs/source/images/logbook.png differ
diff --git a/docs/source/index.rst b/docs/source/index.rst
new file mode 100644
index 0000000..a8539f2
--- /dev/null
+++ b/docs/source/index.rst
@@ -0,0 +1,20 @@
+.. PyQSO documentation master file, created by
+ sphinx-quickstart on Sun Feb 8 12:09:34 2015.
+ You can adapt this file completely to your liking, but it should at least
+ contain the root `toctree` directive.
+
+Welcome to PyQSO's documentation!
+=================================
+
+Contents:
+
+.. toctree::
+ :maxdepth: 2
+
+ introduction
+ getting_started
+ log_management
+ record_management
+ toolbox
+ preferences
+
diff --git a/docs/source/introduction.rst b/docs/source/introduction.rst
new file mode 100644
index 0000000..8e9498b
--- /dev/null
+++ b/docs/source/introduction.rst
@@ -0,0 +1,67 @@
+Introduction
+============
+
+Overview
+--------
+
+PyQSO is a logging tool for amateur radio operators. It provides a
+simple graphical interface through which users can manage information
+about the contacts/QSOs they make with other operators on the air. All
+information is stored in a light-weight SQL database. Other key features
+include:
+
+- Customisable interface (e.g. only show callsign and frequency
+ information).
+
+- Import and export logs in ADIF format.
+
+- Perform callsign lookups and auto-fill data fields using the qrz.com
+ database.
+
+- Sort the logs by individual fields.
+
+- Print a hard-copy of logs, or print to PDF.
+
+- Connect to Telnet-based DX clusters.
+
+- Progress tracker for the DXCC award.
+
+- Grey line plotter.
+
+- Filter out QSOs based on the callsign field (e.g. only display
+ contacts with callsigns beginning with "M6").
+
+- Remove duplicate QSOs.
+
+- Basic support for the Hamlib library.
+
+The source code for PyQSO is available for download from the `GitHub repository <https://github.com/ctjacobs/pyqso>`_.
+
+Data storage model
+------------------
+
+Many amateur radio operators choose to store all the contacts they ever
+make in a single *logbook*, whereas others keep a separate logbook for
+each year, for example. Each logbook may be divided up to form multiple
+distinct *logs*, perhaps one for casual repeater contacts and another
+for DX'ing. Finally, each log can contain multiple *records*. PyQSO is
+based around this three-tier model for data storage, going from logbooks
+at the top to individual records at the bottom.
+
+Rather than storing each log in a separate file, a single database can
+hold several logs together; in PyQSO, a database is therefore analogous
+to a logbook. Within a database the user can create multiple tables
+which are analogous to the logs. Within each table the user can
+create/modify/delete records which are analogous to the records in each
+log.
+
+Licensing
+---------
+
+PyQSO is free software, released under the GNU General Public License. Please see the file called ``COPYING`` for more information.
+
+Structure of this documentation
+-------------------------------
+
+The structure of this documentation is as follows. The section on `Getting Started <getting_started.html>`_ provides information on the PyQSO installation process through to creating a new logbook (or opening an existing one). The `Log Management <log_management.html>`_ section explains how to create a log in the logbook, as well as the basic operations that users can perform with existing logs, such as printing, importing from/exporting to ADIF format, and sorting. The `Record Managemen [...]
+
diff --git a/docs/source/log_management.rst b/docs/source/log_management.rst
new file mode 100644
index 0000000..357a739
--- /dev/null
+++ b/docs/source/log_management.rst
@@ -0,0 +1,76 @@
+Log management
+==============
+
+**Note 1:** All the operations described below assume that a logbook is
+already open.
+
+**Note 2:** Any modifications made to the logs are permanent. Users
+should make sure they keep up-to-date backups.
+
+Creating a new log
+------------------
+
+To create a new log, click ``New Log`` in the ``Logbook`` menu and enter
+the desired name of the log (e.g. repeater\_contacts, dx, mobile\_log).
+Alternatively, use the shortcut key combination ``Ctrl + N``.
+
+The log name must be unique (i.e. it cannot already exist in the
+logbook). Furthermore, it can only be composed of alphanumeric
+characters and the underscore character, and the first character in the
+name must not be a number.
+
+Note: When logs are stored in the database file, field/column names from
+the ADIF standard are used. However, please note that only the following
+subset of all the ADIF fields is considered: CALL, QSO\_DATE, TIME\_ON,
+FREQ, BAND, MODE, TX\_PWR, RST\_SENT, RST\_RCVD, QSL\_SENT, QSL\_RCVD,
+NOTES, NAME, ADDRESS, STATE, COUNTRY, DXCC, CQZ, ITUZ, IOTA. Visit the `ADIF website <http://adif.org/>`_ for more information about these fields.
+
+Renaming a log
+--------------
+
+To rename the currently selected log, click ``Rename Selected Log`` in
+the ``Logbook`` menu. Remember that the log's new name cannot be the
+same as another log in the logbook.
+
+Deleting a log
+--------------
+
+To delete the currently selected log, click ``Delete Selected Log`` in
+the ``Logbook`` menu. As with all database operations in PyQSO, this is
+permanent and cannot be undone.
+
+Importing and exporting a log
+-----------------------------
+
+While PyQSO stores logbooks in SQL format, it is possible to export
+individual logs in the well-known `ADIF <http://www.adif.org/>`_ format. Select the log to export,
+and click ``Export Log`` in the ``Logbook`` menu.
+
+Similarly, records can be imported from an ADIF file. Upon importing,
+users can choose to store the records in a new log, or append them to an
+existing log in the logbook. To import, click ``Import Log`` in the
+``Logbook`` menu.
+
+Note that all data must conform to the ADIF standard, otherwise it will
+be ignored.
+
+Printing a log
+--------------
+
+Due to restrictions on the page width, only a selection of field names
+will be printed: callsign, date, time, frequency, and mode.
+
+Filtering by callsign
+---------------------
+
+Entering an expression such as ``xyz`` into the ``Filter by callsign``
+box will instantly filter out all records whose callsign field does not
+contain ``xyz``.
+
+Sorting by field
+----------------
+
+To sort a log by a particular field name, left-click the column header
+that contains that field name. By default, it is the ``Index`` field
+that is sorted in ascending order.
+
diff --git a/docs/source/preferences.rst b/docs/source/preferences.rst
new file mode 100644
index 0000000..4347711
--- /dev/null
+++ b/docs/source/preferences.rst
@@ -0,0 +1,43 @@
+Preferences
+===========
+
+PyQSO user preferences are stored in a configuration file located at
+``~/.pyqso.ini``, where ``~`` denotes the user's home directory.
+
+General
+-------
+
+Under the ``General`` tab, the user can choose to show the toolbox (see
+the `Toolbox <toolbox.html>`_ section) when PyQSO is started.
+
+View
+----
+
+Not all the available fields have to be displayed in the logbook. The
+user can choose to hide a subset of them by unchecking them in the
+``View`` tab. PyQSO must be restarted in order for any changes to take
+effect.
+
+Records
+-------
+
+The records tab allows users to choose if the UTC timezone is used when autocompleting the date and time fields, and whether the band should be automatically determined from the frequency field. Default values for the Power and Mode fields can also be specified here.
+
+Callsign lookup
+~~~~~~~~~~~~~~~
+
+The user can enter their login details to access the `qrz.com <http://qrz.com/>`_
+database and perform callsign lookups. Note that these details are currently stored in plain text
+(unencrypted) format.
+
+If the ``Ignore callsign prefixes and/or suffixes`` box is checked, then PyQSO will perform the callsign lookup whilst ignoring all prefixes (i.e. anything before a preceding "/" in the callsign) and the suffixes "P", "M", "A", "PM", "MM", "AM", and "QRP". For example, if the callsign to be looked up is EA3/MYCALL/P, only MYCALL will be looked up. If you get 'Callsign not found' errors, try enabling this option.
+
+Hamlib support
+--------------
+
+PyQSO features rudimentary support for the Hamlib library. The name and
+path of the radio device connected to the user's computer can be
+specified in the ``Hamlib`` tab of the preferences dialog. Upon adding a
+new record to the log, PyQSO will use Hamlib to retrieve the current
+frequency that the radio device is set to and automatically fill in the
+Frequency field.
diff --git a/docs/source/pyqso.rst b/docs/source/pyqso.rst
new file mode 100644
index 0000000..8336c24
--- /dev/null
+++ b/docs/source/pyqso.rst
@@ -0,0 +1,134 @@
+pyqso package
+=============
+
+Submodules
+----------
+
+pyqso.adif module
+-----------------
+
+.. automodule:: pyqso.adif
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+pyqso.auxiliary_dialogs module
+------------------------------
+
+.. automodule:: pyqso.auxiliary_dialogs
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+pyqso.awards module
+-------------------
+
+.. automodule:: pyqso.awards
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+pyqso.callsign_lookup module
+----------------------------
+
+.. automodule:: pyqso.callsign_lookup
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+pyqso.dx_cluster module
+-----------------------
+
+.. automodule:: pyqso.dx_cluster
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+pyqso.grey_line module
+----------------------
+
+.. automodule:: pyqso.grey_line
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+pyqso.log module
+----------------
+
+.. automodule:: pyqso.log
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+pyqso.log_name_dialog module
+----------------------------
+
+.. automodule:: pyqso.log_name_dialog
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+pyqso.logbook module
+--------------------
+
+.. automodule:: pyqso.logbook
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+pyqso.menu module
+-----------------
+
+.. automodule:: pyqso.menu
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+pyqso.preferences_dialog module
+-------------------------------
+
+.. automodule:: pyqso.preferences_dialog
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+pyqso.record_dialog module
+--------------------------
+
+.. automodule:: pyqso.record_dialog
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+pyqso.telnet_connection_dialog module
+-------------------------------------
+
+.. automodule:: pyqso.telnet_connection_dialog
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+pyqso.toolbar module
+--------------------
+
+.. automodule:: pyqso.toolbar
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+pyqso.toolbox module
+--------------------
+
+.. automodule:: pyqso.toolbox
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+
+Module contents
+---------------
+
+.. automodule:: pyqso
+ :members:
+ :undoc-members:
+ :show-inheritance:
diff --git a/docs/source/record_management.rst b/docs/source/record_management.rst
new file mode 100644
index 0000000..f7281bf
--- /dev/null
+++ b/docs/source/record_management.rst
@@ -0,0 +1,71 @@
+Record management
+=================
+
+**Note:** Any modifications made to the records are permanent. Users
+should make sure they keep up-to-date backups.
+
+Creating a new record (QSO)
+---------------------------
+
+A new QSO can be added by either:
+
+- Clicking the ``Add Record`` button in the toolbar.
+
+- Pressing ``Ctrl + R``.
+
+- Clicking ``Add Record...`` in the ``Records`` menu.
+
+A dialog window will appear where details of the QSO can be entered (see
+figure:edit_record_). Note that the current date and time
+are filled in automatically. When ready, click ``OK`` to save the
+changes.
+
+ .. _figure:edit_record:
+ .. figure:: images/edit_record.png
+ :align: center
+
+ Record dialog used to add new records and edit existing ones.
+
+Callsign lookup
+~~~~~~~~~~~~~~~
+
+PyQSO can also resolve station-related information (e.g. the operator's
+name, address, and ITU Zone) by clicking the ``Lookup on qrz.com``
+button adjacent to the Callsign data entry box. Note that the user must
+first supply their `qrz.com <http://qrz.com/>`_ account information in the preferences dialog
+window.
+
+Editing a record
+----------------
+
+An existing record can be edited by:
+
+- Double-clicking on it.
+
+- Selecting it and clicking the ``Edit Record`` button in the toolbar.
+
+- Selecting it and clicking ``Edit Selected Record...`` in the
+ ``Records`` menu.
+
+This will bring up the same dialog window as before.
+
+Deleting a record
+-----------------
+
+An existing record can be deleted by:
+
+- Selecting it and clicking the ``Delete Record`` button in the
+ toolbar.
+
+- Selecting it and pressing the ``Delete`` key.
+
+- Selecting it and clicking ``Delete Selected Record...`` in the
+ ``Records`` menu.
+
+Removing duplicate records
+--------------------------
+
+PyQSO can find and delete duplicate records in a log. A record is a
+duplicate of another if its data in the Callsign, Date, Time, Frequency,
+and Mode fields are the same. Click ``Remove Duplicate Records`` in the
+``Records`` menu.
diff --git a/docs/source/toolbox.rst b/docs/source/toolbox.rst
new file mode 100644
index 0000000..1e8289f
--- /dev/null
+++ b/docs/source/toolbox.rst
@@ -0,0 +1,58 @@
+Toolbox
+=======
+
+The toolbox is hidden by default. To show it, click ``Toolbox`` in the
+``View`` menu.
+
+DX cluster
+----------
+
+A DX cluster is essentially a server through which amateur radio
+operators can report and receive updates about QSOs that are in progress
+across the bands. PyQSO is able to connect to a DX cluster that operates
+using the Telnet protocol to provide a text-based alert service. As a
+result of the many different Telnet-based software products that DX
+clusters run, PyQSO currently outputs the raw data received from the DX
+cluster rather than trying to parse it in some way.
+
+Click on the ``Connect to Telnet Server`` button and enter the DX server
+details in the dialog that appears. If no port is specified, PyQSO will
+use the default value of 23. A username and password may also need to be
+supplied. Once connected, the server output will appear in the DX
+cluster frame (see figure:dx_cluster_). A command can also
+be sent to the server by typing it into the entry box and clicking the
+adjacent ``Send Command`` button.
+
+ .. _figure:dx_cluster:
+ .. figure:: images/dx_cluster.png
+ :align: center
+
+ The DX cluster frame.
+
+Grey line
+---------
+
+The grey line tool (see figure:grey_line_) can be used to
+check which parts of the world are in darkness. The position of the grey
+line is automatically updated every 30 minutes.
+
+ .. _figure:grey_line:
+ .. figure:: images/grey_line.png
+ :align: center
+
+ The grey line tool.
+
+Awards
+------
+
+The awards progress tracker (see figure:awards_) updates its data
+each time a record is added, deleted, or modified. Currently only the
+DXCC award is supported (visit the `ARRL DXCC website <http://www.arrl.org/dxcc>`_ for more
+information).
+
+ .. _figure:awards:
+ .. figure:: images/awards.png
+ :align: center
+
+ The award progress tracker.
+
diff --git a/pyqso/adif.py b/pyqso/adif.py
index 151df5a..949bf33 100644
--- a/pyqso/adif.py
+++ b/pyqso/adif.py
@@ -1,7 +1,6 @@
#!/usr/bin/env python
-# File: adif.py
-# Copyright (C) 2012 Christian Jacobs.
+# Copyright (C) 2012 Christian T. Jacobs.
# This file is part of PyQSO.
@@ -54,12 +53,12 @@ AVAILABLE_FIELD_NAMES_ORDERED = ["CALL", "QSO_DATE", "TIME_ON", "FREQ", "BAND",
AVAILABLE_FIELD_NAMES_FRIENDLY = {"CALL":"Callsign",
"QSO_DATE":"Date",
"TIME_ON":"Time",
- "FREQ":"Frequency",
+ "FREQ":"Frequency (MHz)",
"BAND":"Band",
"MODE":"Mode",
"TX_PWR":"TX Power (W)",
- "RST_SENT":"TX RST",
- "RST_RCVD":"RX RST",
+ "RST_SENT":"RST Sent",
+ "RST_RCVD":"RST Received",
"QSL_SENT":"QSL Sent",
"QSL_RCVD":"QSL Received",
"NOTES":"Notes",
@@ -164,7 +163,7 @@ class ADIF:
# Note: This is based on the code written by OK4BX.
# (http://web.bxhome.org/blog/ok4bx/2012/05/adif-parser-python)
fields_and_data_dictionary = {}
- fields_and_data = re.findall('<(.*?):(\d*).*?>([^<\t\n\r\f\v\Z]+)', t)
+ fields_and_data = re.findall('<(.*?):(\d*).*?>([^<\t\n\r\f\v]+)', t)
for fd in fields_and_data:
# Let's force all field names to be in upper case.
# This will help us later when comparing the field names
@@ -181,7 +180,6 @@ class ADIF:
elif(field_name == "CALL"):
# Also force all the callsigns to be in upper case.
field_data = field_data.upper()
-
if(field_name in AVAILABLE_FIELD_NAMES_ORDERED):
field_data_type = AVAILABLE_FIELD_NAMES_TYPES[field_name]
if(self.is_valid(field_name, field_data, field_data_type)):
@@ -212,7 +210,7 @@ class ADIF:
<adif_ver:%d>%s
<programid:5>PyQSO
-<programversion:8>0.2a-dev
+<programversion:3>0.2
<eoh>\n""" % (dt, len(records), len(str(ADIF_VERSION)), ADIF_VERSION))
# Then write each log to the file.
@@ -395,11 +393,14 @@ class ADIF:
class TestADIF(unittest.TestCase):
+ """ The unit tests for the ADIF module. """
def setUp(self):
+ """ Set up the ADIF object needed for the unit tests. """
self.adif = ADIF()
def test_adif_read(self):
+ """ Check that a single ADIF record can be read and parsed correctly. """
f = open("ADIF.test_read.adi", 'w')
f.write("""Some test ADI data.<eoh>
@@ -415,7 +416,88 @@ class TestADIF(unittest.TestCase):
assert(len(records[0].keys()) == len(expected_records[0].keys()))
assert(records == expected_records)
+ def test_adif_read_multiple(self):
+ """ Check that multiple ADIF records can be read and parsed correctly. """
+ f = open("ADIF.test_read_multiple.adi", 'w')
+ f.write("""Some test ADI data.<eoh>
+
+<call:4>TEST<band:3>40m<mode:2>CW
+<qso_date:8:d>20130322<time_on:4>1955<eor>
+
+<call:8>TEST2ABC<band:3>20m<mode:3>SSB
+<qso_date:8>20150227<time_on:4>0820<eor>
+
+<call:5>HELLO<band:2>2m<mode:2>FM<qso_date:8:d>20150227<time_on:4>0832<eor>""")
+ f.close()
+
+ records = self.adif.read("ADIF.test_read_multiple.adi")
+ expected_records = [{'TIME_ON': '1955', 'BAND': '40m', 'CALL': 'TEST', 'MODE': 'CW', 'QSO_DATE': '20130322'}, {'TIME_ON': '0820', 'BAND': '20m', 'CALL': 'TEST2ABC', 'MODE': 'SSB', 'QSO_DATE': '20150227'}, {'TIME_ON': '0832', 'BAND': '2m', 'CALL': 'HELLO', 'MODE': 'FM', 'QSO_DATE': '20150227'}]
+ print "Imported records: ", records
+ print "Expected records: ", expected_records
+ assert(len(records) == 3)
+ for i in range(len(expected_records)):
+ assert(len(records[i].keys()) == len(expected_records[i].keys()))
+ assert(records == expected_records)
+
+ def test_adif_read_alphabet(self):
+ """ Check that none of the letters of the alphabet are ignored during parsing. """
+ f = open("ADIF.test_read_alphabet.adi", 'w')
+ f.write("""Some test ADI data.<eoh>
+<call:64>ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ<eor>""")
+ f.close()
+
+ records = self.adif.read("ADIF.test_read_alphabet.adi")
+ expected_records = [{'CALL': 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'}]
+ print "Imported records: ", records
+ print "Expected records: ", expected_records
+ assert(len(records) == 1)
+ assert(len(records[0].keys()) == len(expected_records[0].keys()))
+ assert(records == expected_records)
+
+ def test_adif_read_capitalisation(self):
+ """ Check that the CALL field is capitalised correctly. """
+ f = open("ADIF.test_read_capitalisation.adi", 'w')
+ f.write("""Some test ADI data.<eoh>
+<call:4>test<eor>""")
+ f.close()
+
+ records = self.adif.read("ADIF.test_read_capitalisation.adi")
+ expected_records = [{'CALL': 'TEST'}]
+ print "Imported records: ", records
+ print "Expected records: ", expected_records
+ assert(len(records) == 1)
+ assert(len(records[0].keys()) == len(expected_records[0].keys()))
+ assert(records == expected_records)
+
+ def test_adif_read_header_only(self):
+ """ Check that no records are read in if the ADIF file only contains header information. """
+ f = open("ADIF.test_read_header_only.adi", 'w')
+ f.write("""Some test ADI data.<eoh>""")
+ f.close()
+
+ records = self.adif.read("ADIF.test_read_header_only.adi")
+ expected_records = []
+ print "Imported records: ", records
+ print "Expected records: ", expected_records
+ assert(len(records) == 0)
+ assert(records == expected_records)
+
+ def test_adif_read_no_header(self):
+ """ Check that an ADIF file can be parsed with no header information. """
+ f = open("ADIF.test_read_no_header.adi", 'w')
+ f.write("""<call:4>TEST<band:3>40m<mode:2>CW<qso_date:8:d>20130322<time_on:4>1955<eor>""")
+ f.close()
+
+ records = self.adif.read("ADIF.test_read_no_header.adi")
+ expected_records = [{'TIME_ON': '1955', 'BAND': '40m', 'CALL': 'TEST', 'MODE': 'CW', 'QSO_DATE': '20130322'}]
+ print "Imported records: ", records
+ print "Expected records: ", expected_records
+ assert(len(records) == 1)
+ assert(len(records[0].keys()) == len(expected_records[0].keys()))
+ assert(records == expected_records)
+
def test_adif_write(self):
+ """ Check that records can be written to an ADIF file correctly. """
records = [{"CALL":"TEST123", "QSO_DATE":"20120402", "TIME_ON":"1234", "FREQ":"145.500", "BAND":"2m", "MODE":"FM", "RST_SENT":"59", "RST_RCVD":"59"},
{"CALL":"TEST123", "QSO_DATE":"20130312", "TIME_ON":"0101", "FREQ":"145.750", "BAND":"2m", "MODE":"FM"}]
self.adif.write(records, "ADIF.test_write.adi")
@@ -426,7 +508,7 @@ class TestADIF(unittest.TestCase):
assert("""
<adif_ver:3>1.0
<programid:5>PyQSO
-<programversion:8>0.2a-dev
+<programversion:3>0.2
<eoh>
<call:7>TEST123
<qso_date:8>20120402
@@ -448,8 +530,10 @@ class TestADIF(unittest.TestCase):
f.close()
def test_adif_write_sqlite3_Row(self):
+ """ Check that records can be written to an ADIF file from a test database file. """
import sqlite3
- self.connection = sqlite3.connect("./unittest_resources/test.db")
+ import os.path
+ self.connection = sqlite3.connect(os.path.dirname(os.path.realpath(__file__))+"/unittest_resources/test.db")
self.connection.row_factory = sqlite3.Row
c = self.connection.cursor()
@@ -465,7 +549,7 @@ class TestADIF(unittest.TestCase):
assert("""
<adif_ver:3>1.0
<programid:5>PyQSO
-<programversion:8>0.2a-dev
+<programversion:3>0.2
<eoh>
<call:7>TEST123
<qso_date:8>20120402
@@ -489,6 +573,7 @@ class TestADIF(unittest.TestCase):
self.connection.close()
def test_adif_is_valid(self):
+ """ Check that ADIF field validation is working correctly for different data types. """
assert(self.adif.is_valid("CALL", "TEST123", "S") == True)
assert(self.adif.is_valid("QSO_DATE", "20120402", "D") == True)
assert(self.adif.is_valid("TIME_ON", "1230", "T") == True)
diff --git a/pyqso/auxiliary_dialogs.py b/pyqso/auxiliary_dialogs.py
index cea12c3..d37a84d 100644
--- a/pyqso/auxiliary_dialogs.py
+++ b/pyqso/auxiliary_dialogs.py
@@ -1,7 +1,6 @@
#!/usr/bin/env python
-# File: auxiliary_dialogs.py
-# Copyright (C) 2013 Christian Jacobs.
+# Copyright (C) 2013 Christian T. Jacobs.
# This file is part of PyQSO.
@@ -25,7 +24,7 @@ def error(parent, message):
""" Display an error message. """
logging.error(message)
dialog = Gtk.MessageDialog(parent, Gtk.DialogFlags.DESTROY_WITH_PARENT,
- Gtk.MessageType.ERROR, Gtk.ButtonsType.OK, message)
+ Gtk.MessageType.ERROR, Gtk.ButtonsType.OK, message, title="Error")
dialog.run()
dialog.destroy()
return
@@ -34,7 +33,7 @@ def info(parent, message):
""" Display some information. """
logging.debug(message)
dialog = Gtk.MessageDialog(parent, Gtk.DialogFlags.DESTROY_WITH_PARENT,
- Gtk.MessageType.INFO, Gtk.ButtonsType.OK, message)
+ Gtk.MessageType.INFO, Gtk.ButtonsType.OK, message, title="Information")
dialog.run()
dialog.destroy()
return
@@ -43,7 +42,7 @@ def question(parent, message):
""" Ask the user a question. The dialog comes with 'Yes' and 'No' response buttons. """
dialog = Gtk.MessageDialog(parent, Gtk.DialogFlags.DESTROY_WITH_PARENT,
Gtk.MessageType.QUESTION, Gtk.ButtonsType.YES_NO,
- message)
+ message, title="Question")
response = dialog.run()
dialog.destroy()
return response
diff --git a/pyqso/awards.py b/pyqso/awards.py
index 41d4c3a..bd50a83 100644
--- a/pyqso/awards.py
+++ b/pyqso/awards.py
@@ -1,7 +1,6 @@
#!/usr/bin/env python
-# File: awards.py
-# Copyright (C) 2013 Christian Jacobs.
+# Copyright (C) 2013 Christian T. Jacobs.
# This file is part of PyQSO.
diff --git a/pyqso/callsign_lookup.py b/pyqso/callsign_lookup.py
index 13986b2..571c0de 100644
--- a/pyqso/callsign_lookup.py
+++ b/pyqso/callsign_lookup.py
@@ -1,7 +1,6 @@
#!/usr/bin/env python
-# File: callsign_lookup.py
-# Copyright (C) 2013 Christian Jacobs.
+# Copyright (C) 2013 Christian T. Jacobs.
# This file is part of PyQSO.
@@ -20,6 +19,7 @@
from gi.repository import Gtk, GObject
import logging
+import unittest
import httplib
from xml.dom import minidom
@@ -38,11 +38,15 @@ class CallsignLookup():
def connect(self, username, password):
""" Initiate a session with the qrz.com server. Hopefully this will return a session key. """
logging.debug("Connecting to the qrz.com server...")
- self.connection = httplib.HTTPConnection('xmldata.qrz.com')
- request = '/xml/current/?username=%s;password=%s;agent=pyqso' % (username, password)
- self.connection.request('GET', request)
- response = self.connection.getresponse()
-
+ try:
+ self.connection = httplib.HTTPConnection('xmldata.qrz.com')
+ request = '/xml/current/?username=%s;password=%s;agent=pyqso' % (username, password)
+ self.connection.request('GET', request)
+ response = self.connection.getresponse()
+ except:
+ error(parent=self.parent, message="Could not connect to the qrz.com server. Check connection to the internets?")
+ return False
+
xml_data = minidom.parseString(response.read())
session_node = xml_data.getElementsByTagName('Session')[0] # There should only be one Session element
session_key_node = session_node.getElementsByTagName('Key')
@@ -98,7 +102,7 @@ class CallsignLookup():
if(len(callsign_addr1_node) > 0):
fields_and_data["ADDRESS"] = callsign_addr1_node[0].firstChild.nodeValue
if(len(callsign_addr2_node) > 0): # Add the second line of the address, if present
- fields_and_data["ADDRESS"] = fields_and_data["ADDRESS"] + ", " + callsign_addr2_node[0].firstChild.nodeValue
+ fields_and_data["ADDRESS"] = (fields_and_data["ADDRESS"] + ", " if len(callsign_addr1_node) > 0 else "") + callsign_addr2_node[0].firstChild.nodeValue
callsign_state_node = callsign_node.getElementsByTagName('state')
if(len(callsign_state_node) > 0):
@@ -127,7 +131,7 @@ class CallsignLookup():
# If there is no Callsign element, then print out the error message in the Session element
session_node = xml_data.getElementsByTagName('Session')
if(len(session_node) > 0):
- session_error_node = session_node.getElementsByTagName('Error')
+ session_error_node = session_node[0].getElementsByTagName('Error')
if(len(session_error_node) > 0):
session_error = session_error_node[0].firstChild.nodeValue
error(parent=self.parent, message=session_error)
@@ -164,3 +168,28 @@ class CallsignLookup():
callsign = full_callsign
return callsign
+class TestCallsignLookup(unittest.TestCase):
+ """ The unit tests for the CallsignLookup class. """
+
+ def setUp(self):
+ """ Set up the CallsignLookup object needed for the unit tests. """
+ self.cl = CallsignLookup(parent=None)
+
+ def test_strip(self):
+ callsign = "EA3/MYCALL/MM"
+ assert self.cl.strip(callsign) == "MYCALL"
+
+ def test_strip_prefix_only(self):
+ callsign = "EA3/MYCALL"
+ assert self.cl.strip(callsign) == "MYCALL"
+
+ def test_strip_suffix_only(self):
+ callsign = "MYCALL/M"
+ assert self.cl.strip(callsign) == "MYCALL"
+
+ def test_strip_no_prefix_or_suffix(self):
+ callsign = "MYCALL"
+ assert self.cl.strip(callsign) == "MYCALL"
+
+if(__name__ == '__main__'):
+ unittest.main()
diff --git a/pyqso/dx_cluster.py b/pyqso/dx_cluster.py
index 16324a5..d32f99c 100644
--- a/pyqso/dx_cluster.py
+++ b/pyqso/dx_cluster.py
@@ -1,7 +1,6 @@
#!/usr/bin/env python
-# File: dx_cluster.py
-# Copyright (C) 2013 Christian Jacobs.
+# Copyright (C) 2013 Christian T. Jacobs.
# This file is part of PyQSO.
@@ -154,8 +153,11 @@ class DXCluster(Gtk.VBox):
""" 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()
- text = text.replace(u"\u0007", "") # Remove the BEL Unicode character from the end of the line
-
+ try:
+ text = text.replace(u"\u0007", "") # Remove the BEL Unicode character from the end of the line
+ except UnicodeDecodeError as e:
+ pass
+
# Allow auto-scrolling to the new text entry if the focus is already at
# the very end of the Gtk.TextView. Otherwise, don't auto-scroll
# in case the user is reading something further up.
diff --git a/pyqso/grey_line.py b/pyqso/grey_line.py
index b56cd25..1d550d2 100644
--- a/pyqso/grey_line.py
+++ b/pyqso/grey_line.py
@@ -1,7 +1,6 @@
#!/usr/bin/env python
-# File: grey_line.py
-# Copyright (C) 2013 Christian Jacobs.
+# Copyright (C) 2013 Christian T. Jacobs.
# This file is part of PyQSO.
@@ -24,13 +23,14 @@ from datetime import datetime
try:
import numpy
import matplotlib
+ logging.debug("Using version %s of matplotlib." % (matplotlib.__version__))
matplotlib.use('Agg')
matplotlib.rcParams['font.size'] = 10.0
from mpl_toolkits.basemap import Basemap
from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg as FigureCanvas
have_necessary_modules = True
except ImportError:
- logging.error("Could not import a non-standard Python module needed by the GreyLine class. Check that all the PyQSO dependencies are satisfied.")
+ logging.error("Could not import a non-standard Python module needed by the GreyLine class, or the version of the non-standard module is too old. Check that all the PyQSO dependencies are satisfied.")
have_necessary_modules = False
class GreyLine(Gtk.VBox):
diff --git a/pyqso/log.py b/pyqso/log.py
index 954375f..5788fe8 100644
--- a/pyqso/log.py
+++ b/pyqso/log.py
@@ -1,7 +1,6 @@
#!/usr/bin/env python
-# File: log.py
-# Copyright (C) 2013 Christian Jacobs.
+# Copyright (C) 2013 Christian T. Jacobs.
# This file is part of PyQSO.
@@ -172,7 +171,27 @@ class Log(Gtk.ListStore):
return
def remove_duplicates(self):
- """ Find the duplicates in the log, based on the CALL, QSO_DATE, TIME_ON, FREQ and MODE fields. Return a tuple containing the number of duplicates in the log, and the number of duplicates successfully removed. Hopefully these will be the same. """
+ """ Remove any duplicate records from the log. Return the total number of duplicates, and the number of duplicates that were successfully removed. Hopefully these will be the same. """
+ duplicates = self.get_duplicates()
+ if(len(duplicates) == 0):
+ return (0, 0) # Nothing to do here.
+
+ removed = 0 # Count the number of records that are removed. Hopefully this will be the same as len(duplicates).
+ while removed != len(duplicates): # Unfortunately, in certain cases, extra passes may be necessary to ensure that all duplicates are removed.
+ path = Gtk.TreePath(0) # Start with the first row in the log.
+ iter = self.get_iter(path)
+ while iter is not None:
+ row_index = self.get_value(iter, 0) # Get the index.
+ if(row_index in duplicates): # Is this a duplicate row? If so, delete it.
+ self.delete_record(row_index, iter)
+ removed += 1
+ iter = self.iter_next(iter) # Move on to the next row, until iter_next returns None.
+
+ assert(removed == len(duplicates))
+ return (len(duplicates), removed)
+
+ def get_duplicates(self):
+ """ Find the duplicates in the log, based on the CALL, QSO_DATE, TIME_ON, FREQ and MODE fields, and return a list of their row IDs. """
duplicates = []
try:
with self.connection:
@@ -185,25 +204,10 @@ class Log(Gtk.ListStore):
result = c.fetchall()
for rowid in result:
duplicates.append(rowid[0]) # Get the integer from inside the tuple.
- if(len(duplicates) == 0):
- return (0, 0) # Nothing to do here.
except (sqlite.Error, IndexError) as e:
logging.exception(e)
- return (0, 0)
-
- removed = 0 # Count the number of records that are removed. Hopefully this will be the same as len(duplicates).
- path = Gtk.TreePath(0) # Start with the first row in the log.
- iter = self.get_iter(path)
- while iter is not None:
- row_index = self.get_value(iter, 0) # Get the index.
- if(row_index in duplicates): # Is this a duplicate row? If so, delete it.
- self.delete_record(row_index, iter)
- removed += 1
- iter = self.iter_next(iter) # Move on to the next row, until iter_next returns None.
-
- assert(len(duplicates) == removed)
- return (len(duplicates), removed)
-
+ return duplicates
+
def get_record_by_index(self, index):
""" Return a record with a given index in the log. The record is represented by a dictionary of field-value pairs. """
try:
@@ -372,6 +376,13 @@ class TestLog(unittest.TestCase):
print "Number of records in the log: ", number_of_records
assert(number_of_records == 2) # There should be 2 records
+ def test_log_get_duplicates(self):
+ query = "INSERT INTO test VALUES (NULL, ?, ?, ?, ?, ?, ?, ?, ?)"
+ c = self.connection.cursor()
+ n = 5 # The total number of records to insert.
+ for i in range(0, n):
+ c.execute(query, (self.fields_and_data["CALL"], self.fields_and_data["QSO_DATE"], self.fields_and_data["TIME_ON"], self.fields_and_data["FREQ"], self.fields_and_data["BAND"], self.fields_and_data["MODE"], self.fields_and_data["RST_SENT"], self.fields_and_data["RST_RCVD"]))
+ assert len(self.log.get_duplicates()) == n-1 # Expecting n-1 duplicates.
if(__name__ == '__main__'):
unittest.main()
diff --git a/pyqso/log_name_dialog.py b/pyqso/log_name_dialog.py
index be25c5b..1cdf306 100644
--- a/pyqso/log_name_dialog.py
+++ b/pyqso/log_name_dialog.py
@@ -1,7 +1,6 @@
#!/usr/bin/env python
-# File: new_log_dialog.py
-# Copyright (C) 2013 Christian Jacobs.
+# Copyright (C) 2013 Christian T. Jacobs.
# This file is part of PyQSO.
diff --git a/pyqso/logbook.py b/pyqso/logbook.py
index 31c67ce..35c3d06 100644
--- a/pyqso/logbook.py
+++ b/pyqso/logbook.py
@@ -1,7 +1,6 @@
-#!/usr/bin/env python
-# File: logbook.py
+#!/usr/bin/env python
-# Copyright (C) 2012 Christian Jacobs.
+# Copyright (C) 2012 Christian T. Jacobs.
# This file is part of PyQSO.
@@ -114,7 +113,7 @@ class Logbook(Gtk.Notebook):
self.logs.append(l)
except (sqlite.Error, IndexError) as e:
logging.exception(e)
- logging.exception("Oops! Something went wrong when trying to retrieve the logs from the logbook.")
+ error(parent = self.parent, message = "Oops! Something went wrong when trying to retrieve the logs from the logbook. Perhaps the logbook file is encrypted, corrupted, or in the wrong format?")
return
logging.debug("All logs retrieved successfully. Now attempting to render them all in the Gtk.Notebook...")
@@ -795,7 +794,14 @@ class Logbook(Gtk.Notebook):
return
def add_record_callback(self, widget):
- log_index = self._get_log_index()
+ # Get the log index
+ try:
+ log_index = self._get_log_index()
+ if(log_index is None):
+ raise ValueError("The log index could not be determined. Perhaps you tried adding a record when the Summary page was selected?")
+ except ValueError as e:
+ error(self.parent, e)
+ return
log = self.logs[log_index]
dialog = RecordDialog(parent=self.parent, log=log, index=None)
@@ -812,7 +818,7 @@ class Logbook(Gtk.Notebook):
fields_and_data = {}
field_names = AVAILABLE_FIELD_NAMES_ORDERED
for i in range(0, len(field_names)):
- #TODO: Validate user input!
+ # Validate user input.
fields_and_data[field_names[i]] = dialog.get_data(field_names[i])
if(not(adif.is_valid(field_names[i], fields_and_data[field_names[i]], AVAILABLE_FIELD_NAMES_TYPES[field_names[i]]))):
# Data is not valid - inform the user.
@@ -834,8 +840,16 @@ class Logbook(Gtk.Notebook):
return
def delete_record_callback(self, widget):
- log_index = self._get_log_index()
+ # Get the log index
+ try:
+ log_index = self._get_log_index()
+ if(log_index is None):
+ raise ValueError("The log index could not be determined. Perhaps you tried deleting a record when the Summary page was selected?")
+ except ValueError as e:
+ error(self.parent, e)
+ return
log = self.logs[log_index]
+
(sort_model, path) = self.treeselection[log_index].get_selected_rows() # Get the selected row in the log
try:
sort_iter = sort_model.get_iter(path[0])
@@ -862,7 +876,14 @@ class Logbook(Gtk.Notebook):
# Note: the path and view_column arguments need to be passed in
# since they associated with the row-activated signal.
- log_index = self._get_log_index()
+ # Get the log index
+ try:
+ log_index = self._get_log_index()
+ if(log_index is None):
+ raise ValueError("The log index could not be determined. Perhaps you tried editing a record when the Summary page was selected?")
+ except ValueError as e:
+ error(self.parent, e)
+ return
log = self.logs[log_index]
(sort_model, path) = self.treeselection[log_index].get_selected_rows() # Get the selected row in the log
@@ -892,7 +913,7 @@ class Logbook(Gtk.Notebook):
fields_and_data = {}
field_names = AVAILABLE_FIELD_NAMES_ORDERED
for i in range(0, len(field_names)):
- #TODO: Validate user input!
+ # Validate user input.
fields_and_data[field_names[i]] = dialog.get_data(field_names[i])
if(not(adif.is_valid(field_names[i], fields_and_data[field_names[i]], AVAILABLE_FIELD_NAMES_TYPES[field_names[i]]))):
# Data is not valid - inform the user.
@@ -970,3 +991,25 @@ class Logbook(Gtk.Notebook):
break
return log_index
+class TestLogbook(unittest.TestCase):
+ """ The unit tests for the Logbook class. """
+
+ def setUp(self):
+ """ Set up the Logbook object and connection to the test database needed for the unit tests. """
+ import os
+ self.logbook = Logbook(parent=None)
+ success = self.logbook.db_connect(os.path.dirname(os.path.realpath(__file__))+"/unittest_resources/test.db")
+ assert success
+
+ def tearDown(self):
+ """ Disconnect from the test database. """
+ success = self.logbook.db_disconnect()
+ assert success
+
+ def test_log_name_exists(self):
+ """ Check that only the log called 'test' exists. """
+ assert self.logbook.log_name_exists("test") # Log 'test' exists.
+ assert not self.logbook.log_name_exists("hello") # Log 'hello' should not exist.
+
+if(__name__ == '__main__'):
+ unittest.main()
diff --git a/pyqso/menu.py b/pyqso/menu.py
index 4750d5b..5ba6c51 100644
--- a/pyqso/menu.py
+++ b/pyqso/menu.py
@@ -1,7 +1,6 @@
#!/usr/bin/env python
-# logbook: menu.py
-# Copyright (C) 2012 Christian Jacobs.
+# Copyright (C) 2012 Christian T. Jacobs.
# This logbook is part of PyQSO.
diff --git a/pyqso/preferences_dialog.py b/pyqso/preferences_dialog.py
index 7d32404..8a38cdf 100644
--- a/pyqso/preferences_dialog.py
+++ b/pyqso/preferences_dialog.py
@@ -1,7 +1,6 @@
#!/usr/bin/env python
-# File: preferences_dialog.py
-# Copyright (C) 2013 Christian Jacobs.
+# Copyright (C) 2013 Christian T. Jacobs.
# This file is part of PyQSO.
@@ -31,8 +30,7 @@ except ImportError:
logging.error("Could not import the Hamlib module!")
have_hamlib = False
-from pyqso.adif import AVAILABLE_FIELD_NAMES_FRIENDLY, AVAILABLE_FIELD_NAMES_ORDERED
-FREQUENCY_UNITS = ["Hz", "kHz", "MHz", "GHz"]
+from pyqso.adif import AVAILABLE_FIELD_NAMES_FRIENDLY, AVAILABLE_FIELD_NAMES_ORDERED, MODES
class PreferencesDialog(Gtk.Dialog):
@@ -171,31 +169,6 @@ class ViewPage(Gtk.VBox):
frame.add(hbox)
self.pack_start(frame, False, False, 2)
- # Default values
- frame = Gtk.Frame()
- frame.set_label("Default values")
- vbox = Gtk.VBox()
-
- hbox_temp = Gtk.HBox()
- label = Gtk.Label("Default unit of frequency: ")
- label.set_width_chars(17)
- label.set_alignment(0, 0.5)
- hbox_temp.pack_start(label, False, False, 2)
-
- self.sources["DEFAULT_FREQ_UNIT"] = Gtk.ComboBoxText()
- for unit in FREQUENCY_UNITS:
- self.sources["DEFAULT_FREQ_UNIT"].append_text(unit)
- (section, option) = ("view", "default_freq_unit")
- if(have_config and config.has_option(section, option)):
- self.sources["DEFAULT_FREQ_UNIT"].set_active(FREQUENCY_UNITS.index(config.get(section, option)))
- else:
- self.sources["DEFAULT_FREQ_UNIT"].set_active(FREQUENCY_UNITS.index("MHz")) # Set to MHz as the default option.
- hbox_temp.pack_start(self.sources["DEFAULT_FREQ_UNIT"], False, False, 2)
- vbox.pack_start(hbox_temp, False, False, 2)
-
- frame.add(vbox)
- self.pack_start(frame, False, False, 2)
-
self.label = Gtk.Label("Note: View-related changes will not take effect\nuntil PyQSO is restarted.")
self.pack_start(self.label, False, False, 2)
@@ -207,7 +180,6 @@ class ViewPage(Gtk.VBox):
data = {}
for field_name in AVAILABLE_FIELD_NAMES_ORDERED:
data[field_name] = self.sources[field_name].get_active()
- data["DEFAULT_FREQ_UNIT"] = self.sources["DEFAULT_FREQ_UNIT"].get_active_text()
return data
class HamlibPage(Gtk.VBox):
@@ -328,6 +300,50 @@ class RecordsPage(Gtk.VBox):
frame.add(vbox)
self.pack_start(frame, False, False, 2)
+
+ ## Default values frame
+ frame = Gtk.Frame()
+ frame.set_label("Default values")
+ vbox = Gtk.VBox()
+
+ # Mode
+ hbox_temp = Gtk.HBox()
+ label = Gtk.Label("Mode: ")
+ label.set_width_chars(17)
+ label.set_alignment(0, 0.5)
+ hbox_temp.pack_start(label, False, False, 2)
+
+ self.sources["DEFAULT_MODE"] = Gtk.ComboBoxText()
+ for mode in MODES:
+ self.sources["DEFAULT_MODE"].append_text(mode)
+ (section, option) = ("records", "default_mode")
+ if(have_config and config.has_option(section, option)):
+ self.sources["DEFAULT_MODE"].set_active(MODES.index(config.get(section, option)))
+ else:
+ self.sources["DEFAULT_MODE"].set_active(MODES.index(""))
+ hbox_temp.pack_start(self.sources["DEFAULT_MODE"], False, False, 2)
+ vbox.pack_start(hbox_temp, False, False, 2)
+
+ # Power
+ hbox_temp = Gtk.HBox()
+ label = Gtk.Label("TX Power (W): ")
+ label.set_width_chars(17)
+ label.set_alignment(0, 0.5)
+ hbox_temp.pack_start(label, False, False, 2)
+
+ self.sources["DEFAULT_POWER"] = Gtk.Entry()
+ (section, option) = ("records", "default_power")
+ if(have_config and config.has_option(section, option)):
+ self.sources["DEFAULT_POWER"].set_text(config.get(section, option))
+ else:
+ self.sources["DEFAULT_POWER"].set_text("")
+ hbox_temp.pack_start(self.sources["DEFAULT_POWER"], False, False, 2)
+ vbox.pack_start(hbox_temp, False, False, 2)
+
+ frame.add(vbox)
+ self.pack_start(frame, False, False, 2)
+
+
# Callsign lookup frame
frame = Gtk.Frame()
frame.set_label("Callsign lookup")
@@ -387,6 +403,10 @@ class RecordsPage(Gtk.VBox):
data = {}
data["AUTOCOMPLETE_BAND"] = self.sources["AUTOCOMPLETE_BAND"].get_active()
data["USE_UTC"] = self.sources["USE_UTC"].get_active()
+
+ data["DEFAULT_MODE"] = self.sources["DEFAULT_MODE"].get_active_text()
+ data["DEFAULT_POWER"] = self.sources["DEFAULT_POWER"].get_text()
+
data["QRZ_USERNAME"] = self.sources["QRZ_USERNAME"].get_text()
data["QRZ_PASSWORD"] = base64.b64encode(self.sources["QRZ_PASSWORD"].get_text())
data["IGNORE_PREFIX_SUFFIX"] = self.sources["IGNORE_PREFIX_SUFFIX"].get_active()
diff --git a/pyqso/record_dialog.py b/pyqso/record_dialog.py
index 6df2bfc..74625cd 100644
--- a/pyqso/record_dialog.py
+++ b/pyqso/record_dialog.py
@@ -1,7 +1,6 @@
#!/usr/bin/env python
-# File: record_dialog.py
-# Copyright (C) 2013 Christian Jacobs.
+# Copyright (C) 2013 Christian T. Jacobs.
# This file is part of PyQSO.
@@ -124,12 +123,7 @@ class RecordDialog(Gtk.Dialog):
# FREQ
hbox_temp = Gtk.HBox(spacing=0)
- (section, option) = ("view", "default_freq_unit")
- if(have_config and config.has_option(section, option)):
- frequency_unit = config.get(section, option)
- else:
- frequency_unit = "MHz"
- label = Gtk.Label(AVAILABLE_FIELD_NAMES_FRIENDLY["FREQ"] + " (" + frequency_unit + ")", halign=Gtk.Align.START)
+ label = Gtk.Label(AVAILABLE_FIELD_NAMES_FRIENDLY["FREQ"], halign=Gtk.Align.START)
label.set_alignment(0, 0.5)
label.set_width_chars(15)
hbox_temp.pack_start(label, False, False, 2)
@@ -378,6 +372,23 @@ class RecordDialog(Gtk.Dialog):
# Automatically fill in the current date and time
self.set_current_datetime_callback()
+ ## Set up default field values
+ # Mode
+ (section, option) = ("records", "default_mode")
+ if(have_config and config.has_option(section, option)):
+ mode = config.get(section, option)
+ else:
+ mode = ""
+ self.sources["MODE"].set_active(MODES.index(mode))
+
+ # Power
+ (section, option) = ("records", "default_power")
+ if(have_config and config.has_option(section, option)):
+ power = config.get(section, option)
+ else:
+ power = ""
+ self.sources["TX_PWR"].set_text(power)
+
if(have_hamlib):
# If the Hamlib module is present, then use it to fill in the Frequency field if desired.
if(have_config and config.has_option("hamlib", "autofill") and config.has_option("hamlib", "rig_model") and config.has_option("hamlib", "rig_pathname")):
@@ -478,7 +489,7 @@ class RecordDialog(Gtk.Dialog):
# Check whether we want to ignore any prefixes (e.g. "IA/") or suffixes "(e.g. "/M") in the callsign
# before performing the lookup.
if(have_config and config.has_option("records", "ignore_prefix_suffix")):
- ignore_prefix_suffix = config.get("records", "ignore_prefix_suffix")
+ ignore_prefix_suffix = (config.get("records", "ignore_prefix_suffix") == "True")
else:
ignore_prefix_suffix = True
@@ -500,7 +511,7 @@ class RecordDialog(Gtk.Dialog):
def set_current_datetime_callback(self, widget=None):
""" Insert the current date and time. """
- # Check if a configuration file is present.
+ # Check if a configuration file is present.
config = ConfigParser.ConfigParser()
have_config = (config.read(expanduser('~/.pyqso.ini')) != [])
diff --git a/pyqso/telnet_connection_dialog.py b/pyqso/telnet_connection_dialog.py
index d45c741..8c499b7 100644
--- a/pyqso/telnet_connection_dialog.py
+++ b/pyqso/telnet_connection_dialog.py
@@ -1,7 +1,6 @@
#!/usr/bin/env python
-# File: telnet_connection_dialog.py
-# Copyright (C) 2013 Christian Jacobs.
+# Copyright (C) 2013 Christian T. Jacobs.
# This file is part of PyQSO.
diff --git a/pyqso/toolbar.py b/pyqso/toolbar.py
index 02bc9c1..61cb18c 100644
--- a/pyqso/toolbar.py
+++ b/pyqso/toolbar.py
@@ -1,7 +1,6 @@
#!/usr/bin/env python
-# File: toolbar.py
-# Copyright (C) 2013 Christian Jacobs.
+# Copyright (C) 2013 Christian T. Jacobs.
# This file is part of PyQSO.
diff --git a/pyqso/toolbox.py b/pyqso/toolbox.py
index ba492f6..49241b0 100644
--- a/pyqso/toolbox.py
+++ b/pyqso/toolbox.py
@@ -1,7 +1,6 @@
#!/usr/bin/env python
-# File: toolbox.py
-# Copyright (C) 2013 Christian Jacobs.
+# Copyright (C) 2013 Christian T. Jacobs.
# This file is part of PyQSO.
diff --git a/setup.py b/setup.py
index f7c0daf..a8884dd 100644
--- a/setup.py
+++ b/setup.py
@@ -1,7 +1,6 @@
#!/usr/bin/env python
-# File: setup.py
-# Copyright (C) 2013 Christian Jacobs.
+# Copyright (C) 2013 Christian T. Jacobs.
# This file is part of PyQSO.
@@ -21,9 +20,10 @@
from distutils.core import setup
setup(name='PyQSO',
- version='0.2a-dev',
+ version='0.2',
description='A contact logging tool for amateur radio operators.',
- author='Christian Jacobs',
+ author='Christian T. Jacobs',
+ author_email='c.jacobs10 at imperial.ac.uk',
url='https://github.com/ctjacobs/pyqso',
packages=['pyqso'],
package_dir = {'pyqso': 'pyqso'},
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-hamradio/pyqso.git
More information about the pkg-hamradio-commits
mailing list