~barcc/acire/gnome-vfs

« back to all changes in this revision

Viewing changes to bin/acire

  • Committer: Jono Bacon
  • Date: 2010-01-08 19:25:15 UTC
  • Revision ID: jono@ubuntu.com-20100108192515-xawwoht85luyz2k5
Added Python VTE support: this makes it easier to show output and support
command line snippets.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
import gtk
21
21
import fnmatch
22
22
import re
23
 
import subprocess
 
23
import vte
24
24
 
25
25
# Check if we are working in the source tree or from the installed 
26
26
# package and mangle the python path accordingly
76
76
        self.snippets_tv = self.builder.get_object("snippets_tv")
77
77
        self.description_label = self.builder.get_object("description_label")
78
78
        self.location_label = self.builder.get_object("location_label")
 
79
        self.terminal_scroll = self.builder.get_object("terminal_scroll")
79
80
 
 
81
        # set up terminal
 
82
        self.terminal = vte.Terminal()
 
83
        self.terminal_scroll.add(self.terminal)
 
84
        self.terminal.fork_command()
 
85
        self.terminal.show()
 
86
        
80
87
        self.snippetsdir = "/usr/share/python-snippets"
81
88
        self.snippetsfiles = []
82
89
        self.snippetsdata = []
186
193
    def run_snippet(self, widget, data=None):
187
194
        """Run the currently selected snippet"""
188
195
 
189
 
        fn = os.path.join(self.snippetsdir, self.current_filename)
190
 
        subprocess.Popen(['python', fn])
 
196
        cmd = "/usr/bin/python"
 
197
        argv = [cmd, self.current_filename]
 
198
        directory = self.snippetsdir
 
199
        self.terminal.fork_command(command=cmd, argv=argv, envv=None, directory=directory)
191
200
                                
192
201
    def get_snippets_file_list(self):
193
202
        """Read in the snippets directory and put all Python files into a list."""
198
207
            for f in files:
199
208
                if fnmatch.fnmatch(f, "*.py"):
200
209
                    self.snippetsfiles.append(os.path.join(path,f))
201
 
                    print f
202
210
 
203
211
        self.scan_for_metadata()
204
212