Site: new desklet, pacmansentry 0.0.1
[adesklets.git] / test / editor.py
blob4157e754181aec8c71ab961eaf1f3f173ef91506
1 """
2 editor.py - S.Fourmanoit <syfou@users.sourceforge.net>, 2005
4 adesklets test script for editor launch, similar to what the Configure Menu
5 in many desklet returns, but with pause. You have to exit the editor for
6 the script to continue. Start with:
8 python editor.py
9 """
10 from os import environ, getenv, system, unlink
11 from os.path import join, isfile
13 # Test function
15 def launch(msg):
16 print msg
17 print >> file('/tmp/editor.txt','w'), msg
18 if len(display):
19 if len(xterm) > 0:
20 if len(editor) > 0:
21 cmdline = '%s -e %s /tmp/editor.txt' % (xterm[0], editor)
22 print "Command line is '%s'." % cmdline
23 print 'Command line returned %d (0 is OK)' % system(cmdline)
24 else:
25 print 'editor not found.'
26 else:
27 print 'xterm not found.'
28 else:
29 print 'display not found.'
31 # Get the pertinent information
33 display = getenv('DISPLAY','')
34 xterm = [join(p,'xterm')
35 for p in getenv('PATH','').split(':') if isfile(join(p,'xterm'))]
36 editor = getenv('EDITOR','')
38 # Display this information
40 print """=== System information ===
42 Display : '%s'
43 xterm paths : %s
44 Editor : '%s'
45 """ % (editor, display, xterm)
47 # Now, let's test the launch.
49 launch('Launching editor in xterm without adesklets.')
50 environ['ADESKLETS_ID'] = '0'; import adesklets
51 launch('Launching editor in xterm with adesklets.')
52 print 'Now exiting.'