1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
"""
editor.py - S.Fourmanoit <syfou@users.sourceforge.net>, 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.'
|