From 0e4db25dca7dadcbf5b418e5564b756544f71bfd Mon Sep 17 00:00:00 2001 From: Date: Wed, 21 Sep 2005 16:36:04 -0400 Subject: [PATCH] New test script: test/editor.py Make it easier to debug the contextual configuration menu. --- test/README | 1 + test/editor.py | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 test/editor.py diff --git a/test/README b/test/README index 3997389..372d153 100644 --- a/test/README +++ b/test/README @@ -18,3 +18,4 @@ widgets.py - a demonstration of widgets creation for adesklets threading.py - a demonstration of threads usage with adesklets +editor.py - external editor launching test diff --git a/test/editor.py b/test/editor.py new file mode 100644 index 0000000..4157e75 --- /dev/null +++ b/test/editor.py @@ -0,0 +1,52 @@ +""" +editor.py - S.Fourmanoit , 2005 + +adesklets test script for editor launch, similar to what the Configure Menu +in many desklet returns, but with pause. You have to exit the editor for +the script to continue. Start with: + +python editor.py +""" +from os import environ, getenv, system, unlink +from os.path import join, isfile + +# Test function +# +def launch(msg): + print msg + print >> file('/tmp/editor.txt','w'), msg + if len(display): + if len(xterm) > 0: + if len(editor) > 0: + cmdline = '%s -e %s /tmp/editor.txt' % (xterm[0], editor) + print "Command line is '%s'." % cmdline + print 'Command line returned %d (0 is OK)' % system(cmdline) + else: + print 'editor not found.' + else: + print 'xterm not found.' + else: + print 'display not found.' + +# Get the pertinent information +# +display = getenv('DISPLAY','') +xterm = [join(p,'xterm') + for p in getenv('PATH','').split(':') if isfile(join(p,'xterm'))] +editor = getenv('EDITOR','') + +# Display this information +# +print """=== System information === + +Display : '%s' +xterm paths : %s +Editor : '%s' +""" % (editor, display, xterm) + +# Now, let's test the launch. +# +launch('Launching editor in xterm without adesklets.') +environ['ADESKLETS_ID'] = '0'; import adesklets +launch('Launching editor in xterm with adesklets.') +print 'Now exiting.' -- 2.11.4.GIT