[tuxdroid-svn] r325 - api/python/trunk
Status: Beta
Brought to you by:
ks156
From: neimad <c2m...@c2...> - 2007-05-26 14:00:13
|
Author: neimad Date: 2007-05-26 15:59:44 +0200 (Sat, 26 May 2007) New Revision: 325 Modified: api/python/trunk/tux.py Log: * Only print the API version if run as a program. "Polluting" the output of the users of the API is not polite ;-) * Pint a hint on how to use the API interactively when python is launched is non-interactive mode. This is done by using a trick checking for the presence of readline in sys.modules. If someone knows of a better way... Modified: api/python/trunk/tux.py =================================================================== --- api/python/trunk/tux.py 2007-05-25 17:04:52 UTC (rev 324) +++ api/python/trunk/tux.py 2007-05-26 13:59:44 UTC (rev 325) @@ -9,8 +9,18 @@ import atexit global tux + +# If run as main, print version banner. Otherwise, keep quiet. +if __name__ == "__main__": + misc = tuxapi_class.TUXmisc(None) + misc.print_api_version() + del misc + # Trick to detect whether python is in interactive mode + if not 'readline' in sys.modules: + print "For interactive use, run: python -i tux.py" + sys.exit(0) + tux=tuxapi_class.TUXTCPCommunicator() -tux.misc.print_api_version() wavs=tuxapi_wav_merger.WavMerger(tux) tux.daemon.connect() tux.tts.connect() @@ -28,3 +38,4 @@ signal.signal(signal.SIGTERM, exit) signal.signal(signal.SIGINT, exit) atexit.register(my_exitfunct) + |