summaryrefslogtreecommitdiff
path: root/grc/main.py
diff options
context:
space:
mode:
Diffstat (limited to 'grc/main.py')
-rwxr-xr-xgrc/main.py56
1 files changed, 46 insertions, 10 deletions
diff --git a/grc/main.py b/grc/main.py
index 0edab40769..4d04608269 100755
--- a/grc/main.py
+++ b/grc/main.py
@@ -15,13 +15,12 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-import argparse
+import argparse, logging, sys
-import gtk
-from gnuradio import gr
-
-from .gui.Platform import Platform
-from .gui.ActionHandler import ActionHandler
+import gi
+gi.require_version('Gtk', '3.0')
+gi.require_version('PangoCairo', '1.0')
+from gi.repository import Gtk
VERSION_AND_DISCLAIMER_TEMPLATE = """\
@@ -32,24 +31,61 @@ GRC comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it.
"""
+LOG_LEVELS = {
+ 'debug': logging.DEBUG,
+ 'info': logging.INFO,
+ 'warning': logging.WARNING,
+ 'error': logging.ERROR,
+ 'critical': logging.CRITICAL,
+}
+
def main():
+ from gnuradio import gr
parser = argparse.ArgumentParser(
description=VERSION_AND_DISCLAIMER_TEMPLATE % gr.version())
parser.add_argument('flow_graphs', nargs='*')
+ parser.add_argument('--log', choices=['debug', 'info', 'warning', 'error', 'critical'], default='warning')
args = parser.parse_args()
try:
- gtk.window_set_default_icon(gtk.IconTheme().load_icon('gnuradio-grc', 256, 0))
+ Gtk.window_set_default_icon(Gtk.IconTheme().load_icon('gnuradio-grc', 256, 0))
except:
pass
+ # Enable logging
+ # Note: All other modules need to use the 'grc.<module>' convention
+ log = logging.getLogger('grc')
+ log.setLevel(logging.DEBUG)
+
+ # Console formatting
+ console = logging.StreamHandler()
+ console.setLevel(LOG_LEVELS[args.log])
+
+ #msg_format = '[%(asctime)s - %(levelname)8s] --- %(message)s (%(filename)s:%(lineno)s)'
+ msg_format = '[%(levelname)s] %(message)s (%(filename)s:%(lineno)s)'
+ date_format = '%I:%M'
+ formatter = logging.Formatter(msg_format, datefmt=date_format)
+
+ #formatter = utils.log.ConsoleFormatter()
+ console.setFormatter(formatter)
+ log.addHandler(console)
+
+ log.debug("Running main")
+
+ # Delay importing until the logging is setup
+ from .gui.Platform import Platform
+ from .gui.Application import Application
+
+ log.debug("Loading platform")
platform = Platform(
- prefs_file=gr.prefs(),
version=gr.version(),
version_parts=(gr.major_version(), gr.api_version(), gr.minor_version()),
+ prefs=gr.prefs(),
install_prefix=gr.prefix()
)
- ActionHandler(args.flow_graphs, platform)
- gtk.main()
+ log.debug("Loading application")
+ app = Application(args.flow_graphs, platform)
+ log.debug("Running")
+ sys.exit(app.run())