Changeset 1459 for trunk/peppy/major.py

Show
Ignore:
Timestamp:
07/06/08 16:09:42 (5 months ago)
Author:
rob
Message:

Fixed #484: Added RunFilter? command to run an arbitary program using current buffer as input

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/peppy/major.py

    r1457 r1459  
    10341034            self.scriptArgs = argstring 
    10351035             
    1036         if self.buffer.readonly or not self.classprefs.autosave_before_run: 
    1037             msg = "You must save this file to the local filesystem\nbefore you can run it through the interpreter." 
    1038             dlg = wx.MessageDialog(wx.GetApp().GetTopWindow(), msg, "Save the file!", wx.OK | wx.ICON_ERROR ) 
    1039             retval=dlg.ShowModal() 
    1040             return 
    1041         else: 
    1042             self.save() 
    1043  
    10441036        bangpath = None 
    10451037        first = self.GetLine(0) 
     
    10631055        else: 
    10641056            cmd = self.getCommandLine(bangpath) 
     1057            self.startCommandLine(cmd) 
     1058     
     1059    def expandCommandLine(self, cmd): 
     1060        """Expand the command line to include the filename of the buffer""" 
     1061        if '%' in cmd: 
     1062            cmd = cmd % self.buffer.getFilename() 
     1063        else: 
     1064            cmd = "%s %s" % (cmd, self.buffer.getFilename()) 
     1065        return cmd 
     1066     
     1067    def startCommandLine(self, cmd): 
     1068        """Attempt to create a process using the command line""" 
     1069        if hasattr(self, 'process'): 
     1070            self.frame.setStatusText("Already running a process.") 
     1071        else: 
     1072            if self.buffer.readonly or not self.classprefs.autosave_before_run: 
     1073                msg = "You must save this file to the local filesystem\nbefore you can run it through the interpreter." 
     1074                dlg = wx.MessageDialog(wx.GetApp().GetTopWindow(), msg, "Save the file!", wx.OK | wx.ICON_ERROR ) 
     1075                retval=dlg.ShowModal() 
     1076                return 
     1077            else: 
     1078                self.save() 
     1079 
     1080            cmd = self.expandCommandLine(cmd) 
    10651081            if self.classprefs.output_log == 0: 
    10661082                output = self