00001 """
00002 Copyright 2007 Free Software Foundation, Inc.
00003 This file is part of GNU Radio
00004
00005 GNU Radio Companion is free software; you can redistribute it and/or
00006 modify it under the terms of the GNU General Public License
00007 as published by the Free Software Foundation; either version 2
00008 of the License, or (at your option) any later version.
00009
00010 GNU Radio Companion is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00013 GNU General Public License for more details.
00014
00015 You should have received a copy of the GNU General Public License
00016 along with this program; if not, write to the Free Software
00017 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
00018 """
00019
00020
00021
00022
00023 from Constants import VERSION
00024 import traceback
00025 import sys
00026
00027
00028 MESSENGERS_LIST = list()
00029
00030 def register_messenger(messenger):
00031 """!
00032 Append the given messenger to the list of messengers.
00033 @param messenger a method thats takes a string
00034 """
00035 MESSENGERS_LIST.append(messenger)
00036
00037 def send(message):
00038 """!
00039 Give the message to each of the messengers.
00040 @param message a message string
00041 """
00042 for messenger in MESSENGERS_LIST: messenger(message)
00043
00044
00045 register_messenger(sys.stdout.write)
00046
00047
00048
00049
00050 def send_init():
00051 send("""<<< Welcome to GRC %s >>>\n"""%VERSION)
00052
00053 def send_page_switch(file_path):
00054 send('\nShowing: "%s"\n'%file_path)
00055
00056
00057 def send_start_load(file_path):
00058 send('\nLoading: "%s"'%file_path + '\n')
00059
00060 def send_error_load(error):
00061 send('>>> Error: %s\n'%error)
00062 traceback.print_exc()
00063
00064 def send_end_load():
00065 send(">>> Done\n")
00066
00067 def send_fail_load(error):
00068 send('Parser Error: %s\n'%error)
00069 send(">>> Failue\n")
00070 traceback.print_exc()
00071
00072
00073 def send_start_gen(file_path):
00074 send('\nGenerating: "%s"'%file_path + '\n')
00075
00076 def send_fail_gen(error):
00077 send('Generate Error: %s\n'%error)
00078 send(">>> Failue\n")
00079 traceback.print_exc()
00080
00081
00082 def send_start_exec(file_path):
00083 send('\nExecuting: "%s"'%file_path + '\n')
00084
00085 def send_verbose_exec(verbose):
00086 send(verbose)
00087
00088 def send_end_exec():
00089 send("\n>>> Done\n")
00090
00091
00092 def send_fail_save(file_path):
00093 send('>>> Error: Cannot save: %s\n'%file_path)
00094
00095
00096 def send_fail_connection():
00097 send('>>> Warning: A connection can only be created between a source and an unconnected sink.\n')
00098
00099
00100 def send_fail_load_preferences(prefs_file_path):
00101 send('>>> Error: Cannot load preferences file: "%s"\n'%prefs_file_path)
00102
00103 def send_fail_save_preferences(prefs_file_path):
00104 send('>>> Error: Cannot save preferences file: "%s"\n'%prefs_file_path)
00105