[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 05/23: grc: refactoring Messages.py
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 05/23: grc: refactoring Messages.py |
Date: |
Sat, 28 Nov 2015 21:18:06 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
jcorgan pushed a commit to branch master
in repository gnuradio.
commit 5c544a06e2d129a5ac0d2cfe6fc0b4d32e8a1849
Author: Sebastian Koslowski <address@hidden>
Date: Mon Oct 12 16:33:53 2015 +0200
grc: refactoring Messages.py
---
grc/base/FlowGraph.py | 2 +-
grc/gui/Messages.py | 81 +++++++++++++++++++++++++++++++++------------------
2 files changed, 53 insertions(+), 30 deletions(-)
diff --git a/grc/base/FlowGraph.py b/grc/base/FlowGraph.py
index f61542c..5d600e2 100644
--- a/grc/base/FlowGraph.py
+++ b/grc/base/FlowGraph.py
@@ -368,7 +368,7 @@ class FlowGraph(Element):
block = self.get_new_block('dummy_block')
# Ugly ugly ugly
_initialize_dummy_block(block, block_n)
- Messages.send_error_msg_load('Block key "%s" not found in %s'
% (key, self.get_parent()))
+ Messages.send_error_msg_load('Block key "%s" not found' % key)
block.import_data(block_n)
#build the connections
diff --git a/grc/gui/Messages.py b/grc/gui/Messages.py
index 61692b4..32c6cf1 100644
--- a/grc/gui/Messages.py
+++ b/grc/gui/Messages.py
@@ -21,8 +21,9 @@ import traceback
import sys
import os
-## A list of functions that can receive a message.
+# A list of functions that can receive a message.
MESSENGERS_LIST = list()
+_indent = ''
def register_messenger(messenger):
@@ -35,6 +36,11 @@ def register_messenger(messenger):
MESSENGERS_LIST.append(messenger)
+def set_indent(level=0):
+ global _indent
+ _indent = ' ' * level
+
+
def send(message):
"""
Give the message to each of the messengers.
@@ -42,17 +48,22 @@ def send(message):
Args:
message: a message string
"""
- for messenger in MESSENGERS_LIST: messenger(message)
+ for messenger in MESSENGERS_LIST:
+ messenger(_indent + message)
-#register stdout by default
+# register stdout by default
register_messenger(sys.stdout.write)
+
###########################################################################
# Special functions for specific program functionalities
###########################################################################
def send_init(platform):
p = platform
- get_paths = lambda x: (os.path.abspath(os.path.expanduser(x)), x)
+
+ def get_paths(x):
+ return os.path.abspath(os.path.expanduser(x)), x
+
send('\n'.join([
"<<< Welcome to %s %s >>>" % (p.get_name(), p.get_version()),
"",
@@ -60,71 +71,83 @@ def send_init(platform):
"Block paths:"
] + [
"\t%s" % path + (" (%s)" % opath if opath != path else "")
- for path, opath in map(get_paths, p.get_block_paths())
+ for path, opath in map(get_paths, p.get_block_paths())
]) + "\n")
+
def send_page_switch(file_path):
- send('\nShowing: "%s"\n'%file_path)
+ send('\nShowing: "%s"\n' % file_path)
+
-################# functions for loading blocks
########################################
def send_xml_errors_if_any(xml_failures):
if xml_failures:
- send('\nXML parser: Found {0} erroneous XML file{1} while loading the
block tree '
- '(see "Help/Parser errors" for
details)\n'.format(len(xml_failures), 's' if len(xml_failures) > 1 else ''))
+ send('\nXML parser: Found {0} erroneous XML file{1} while loading the '
+ 'block tree (see "Help/Parser errors" for details)\n'.format(
+ len(xml_failures), 's' if len(xml_failures) > 1 else ''))
+
-################# functions for loading flow graphs
########################################
def send_start_load(file_path):
- send('\nLoading: "%s"'%file_path + '\n')
+ send('\nLoading: "%s"\n' % file_path)
+
def send_error_msg_load(error):
send('>>> Error: %s\n' % error)
+
def send_error_load(error):
send_error_msg_load(error)
traceback.print_exc()
+
def send_end_load():
send('>>> Done\n')
+
def send_fail_load(error):
- send('Error: %s\n'%error)
- send('>>> Failure\n')
+ send('Error: %s\n>>> Failure\n' % error)
traceback.print_exc()
-################# functions for generating flow graphs
########################################
+
def send_start_gen(file_path):
- send('\nGenerating: "%s"'%file_path + '\n')
+ send('\nGenerating: %r\n' % file_path)
+
+
+def send_auto_gen(file_path):
+ send('>>> Generating: %r\n' % file_path)
+
def send_fail_gen(error):
- send('Generate Error: %s\n'%error)
- send('>>> Failure\n')
+ send('Generate Error: %s\n>>> Failure\n' % error)
traceback.print_exc()
-################# functions for executing flow graphs
########################################
+
def send_start_exec(file_path):
- send('\nExecuting: ' + repr(file_path) + '\n')
+ send('\nExecuting: %r\n' % file_path)
+
def send_verbose_exec(verbose):
send(verbose)
-def send_end_exec(returncode=0):
- send('\n>>> Done%s\n' % (" (return code %s)" % returncode if returncode
else ""))
-################# functions for saving flow graphs
########################################
+def send_end_exec(code=0):
+ send('\n>>> Done%s\n' % (" (return code %s)" % code if code else ""))
+
+
def send_fail_save(file_path):
- send('>>> Error: Cannot save: %s\n'%file_path)
+ send('>>> Error: Cannot save: %s\n' % file_path)
+
-################# functions for connections
########################################
def send_fail_connection():
send('>>> Error: Cannot create connection.\n')
-################# functions for preferences
########################################
+
def send_fail_load_preferences(prefs_file_path):
- send('>>> Error: Cannot load preferences file: "%s"\n'%prefs_file_path)
+ send('>>> Error: Cannot load preferences file: "%s"\n' % prefs_file_path)
+
def send_fail_save_preferences(prefs_file_path):
- send('>>> Error: Cannot save preferences file: "%s"\n'%prefs_file_path)
+ send('>>> Error: Cannot save preferences file: "%s"\n' % prefs_file_path)
+
-################# functions for warning
########################################
def send_warning(warning):
- send('>>> Warning: %s\n'%warning)
+ send('>>> Warning: %s\n' % warning)
- [Commit-gnuradio] [gnuradio] 02/23: grc: move docstring extraction into subprocess, (continued)
- [Commit-gnuradio] [gnuradio] 02/23: grc: move docstring extraction into subprocess, git, 2015/11/28
- [Commit-gnuradio] [gnuradio] 17/23: grc: preserve block spacing when dragging multiple blocks into canvas boundary, git, 2015/11/28
- [Commit-gnuradio] [gnuradio] 16/23: grc: Added option to use the default editor when opening embedded python blocks, git, 2015/11/28
- [Commit-gnuradio] [gnuradio] 19/23: Merge remote-tracking branch 'drmpeg/dtv-coverity-clean', git, 2015/11/28
- [Commit-gnuradio] [gnuradio] 12/23: grc: added recently opened flowgraph submenu and toolbar button dropdown menu, git, 2015/11/28
- [Commit-gnuradio] [gnuradio] 06/23: grc: auto-generate missing hier_blocks, git, 2015/11/28
- [Commit-gnuradio] [gnuradio] 08/23: gr-dtv: Fix Coverity issue #1327535., git, 2015/11/28
- [Commit-gnuradio] [gnuradio] 09/23: gr-dtv: Fix Coverity issue #1327847., git, 2015/11/28
- [Commit-gnuradio] [gnuradio] 13/23: ctrlport: pc_throughput_avg registered, git, 2015/11/28
- [Commit-gnuradio] [gnuradio] 23/23: Merge branch 'maint', git, 2015/11/28
- [Commit-gnuradio] [gnuradio] 05/23: grc: refactoring Messages.py,
git <=