summaryrefslogtreecommitdiff
path: root/grc/src/gui/Messages.py
diff options
context:
space:
mode:
authorjblum2008-09-07 21:38:12 +0000
committerjblum2008-09-07 21:38:12 +0000
commitc86f6c23c6883f73d953d64c28ab42cedb77e4d7 (patch)
tree0193b2a649eb0f7f1065912862de340a02848e16 /grc/src/gui/Messages.py
parentddec4fc07744a6519086b1b111f29d551b7f19c6 (diff)
downloadgnuradio-c86f6c23c6883f73d953d64c28ab42cedb77e4d7.tar.gz
gnuradio-c86f6c23c6883f73d953d64c28ab42cedb77e4d7.tar.bz2
gnuradio-c86f6c23c6883f73d953d64c28ab42cedb77e4d7.zip
Merged r9481:9518 on jblum/grc_reorganize into trunk. Reorganized grc source under gnuradio.grc module. Trunk passes make distcheck.
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@9525 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'grc/src/gui/Messages.py')
-rw-r--r--grc/src/gui/Messages.py101
1 files changed, 101 insertions, 0 deletions
diff --git a/grc/src/gui/Messages.py b/grc/src/gui/Messages.py
new file mode 100644
index 000000000..1d9a80211
--- /dev/null
+++ b/grc/src/gui/Messages.py
@@ -0,0 +1,101 @@
+"""
+Copyright 2007 Free Software Foundation, Inc.
+This file is part of GNU Radio
+
+GNU Radio Companion 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 2
+of the License, or (at your option) any later version.
+
+GNU Radio Companion 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 this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+"""
+
+from .. platforms.base.Constants import VERSION
+import traceback
+import sys
+
+## A list of functions that can receive a message.
+MESSENGERS_LIST = list()
+
+def register_messenger(messenger):
+ """
+ Append the given messenger to the list of messengers.
+ @param messenger a method thats takes a string
+ """
+ MESSENGERS_LIST.append(messenger)
+
+def send(message):
+ """
+ Give the message to each of the messengers.
+ @param message a message string
+ """
+ for messenger in MESSENGERS_LIST: messenger(message)
+
+#register stdout by default
+register_messenger(sys.stdout.write)
+
+###########################################################################
+# Special functions for specific program functionalities
+###########################################################################
+def send_init():
+ send("""<<< Welcome to GRC %s >>>\n"""%VERSION)
+
+def send_page_switch(file_path):
+ send('\nShowing: "%s"\n'%file_path)
+
+################# functions for loading flow graphs ########################################
+def send_start_load(file_path):
+ send('\nLoading: "%s"'%file_path + '\n')
+
+def send_error_load(error):
+ send('>>> Error: %s\n'%error)
+ traceback.print_exc()
+
+def send_end_load():
+ send(">>> Done\n")
+
+def send_fail_load(error):
+ send('Parser Error: %s\n'%error)
+ send(">>> Failue\n")
+ traceback.print_exc()
+
+################# functions for generating flow graphs ########################################
+def send_start_gen(file_path):
+ send('\nGenerating: "%s"'%file_path + '\n')
+
+def send_fail_gen(error):
+ send('Generate Error: %s\n'%error)
+ send(">>> Failue\n")
+ traceback.print_exc()
+
+################# functions for executing flow graphs ########################################
+def send_start_exec(file_path):
+ send('\nExecuting: "%s"'%file_path + '\n')
+
+def send_verbose_exec(verbose):
+ send(verbose)
+
+def send_end_exec():
+ send("\n>>> Done\n")
+
+################# functions for saving flow graphs ########################################
+def send_fail_save(file_path):
+ send('>>> Error: Cannot save: %s\n'%file_path)
+
+################# functions for connections ########################################
+def send_fail_connection():
+ send('>>> Warning: A connection can only be created between a source and an unconnected sink.\n')
+
+################# functions for preferences ########################################
+def send_fail_load_preferences(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)