Changeset 1483

Show
Ignore:
Timestamp:
07/10/08 18:14:45 (7 weeks ago)
Author:
rob
Message:

Added build, run, and stop project commands
* changed output log to search upwards in the history looking for working directories when double clicking on a grep-like line
* added i18n text for process start/finish messages

Location:
trunk/peppy
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/peppy/lib/processmanager.py

    r1464 r1483  
    121121    # Use the unicode rightward double arrow as a delimiter 
    122122    arrow = u"\u21d2 " 
     123    started = _("Started %s on") 
     124    cwd = _("cwd = ") 
     125    exit = _("exit code = %s") 
     126    finished = _("Finished %s on") 
    123127     
    124128    def __init__(self, cmd, working_dir, job_output): 
     
    133137        self.exit_code = 0 
    134138     
     139    @classmethod 
     140    def matchCwd(cls, line): 
     141        """Evaluate if the line contains an embedded working directory specifier 
     142         
     143        """ 
     144        if line.startswith(cls.arrow): 
     145            start = len(cls.arrow) 
     146            #dprint(line[start:]) 
     147            if line[start:].startswith(_(cls.cwd)): 
     148                cwd = line[start + len(cls.cwd):].strip() 
     149                return cwd 
     150        return "" 
     151     
    135152    def getStartMessage(self): 
    136         return self.arrow + _("Started %s on %s") % (self.cmd, time.asctime(time.localtime(time.time()))) + "\n" 
     153        return "%s%s %s\n%s%s%s\n" % (self.arrow, self.started % self.cmd, time.asctime(time.localtime(time.time())), self.arrow, self.cwd, self.working_dir) 
    137154 
    138155    def getFinishMessage(self): 
    139         return self.arrow + _("exit code = %s") % self.exit_code + "\n" + self.arrow + _("Finished %s on %s") % (self.cmd, time.asctime(time.localtime(time.time()))) + "\n" 
     156        return "%s%s\n%s%s %s" % (self.arrow, self.exit % self.exit_code, self.arrow, self.finished % self.cmd, time.asctime(time.localtime(time.time()))) 
    140157 
    141158    def run(self, text=""): 
  • trunk/peppy/plugins/error_log.py

    r1459 r1483  
    1616from peppy.sidebar import * 
    1717from peppy.minor import * 
     18from peppy.lib.processmanager import Job 
    1819 
    1920class LoggingSTC(PeppySTC, ClassPrefs, debugmixin): 
     
    8889            #sys.stdout.write("match ends at %d" % i) 
    8990            self.last_matched_filename = pos + i 
     91     
     92    def findAbsolutePath(self, line): 
     93        """If the filename specified on the line is a relative path, search 
     94        upwards in the stc to locate a cwd specifier. 
     95         
     96        """ 
     97        while line > 0: 
     98            line -= 1 
     99            text = self.GetLine(line) 
     100            if text.startswith(Job.arrow): 
     101                #dprint("Found a candidate at %d: %s" % (line, text)) 
     102                cwd = Job.matchCwd(text) 
     103                if cwd is None: 
     104                    return "" 
     105                elif cwd: 
     106                    return cwd 
     107        return "" 
    90108 
    91109    def OnDoubleClick(self, evt): 
     
    100118            if match: 
    101119                filename = match.group(1) 
     120                if not filename.startswith("/"): 
     121                    path = self.findAbsolutePath(line) 
     122                    filename = os.path.join(path, filename) 
    102123                line = match.group(2) 
    103124                self.open("%s#%s" % (filename, line)) 
  • trunk/peppy/plugins/project.py

    r1480 r1483  
    160160        StrParam('build_command', '', 'shell command to build project, relative to working directory', fullwidth=True), 
    161161        DirParam('run_dir', '', 'working directory in which to execute the project', fullwidth=True), 
    162         StrParam('run_command', '', 'shell command to executee project, relative to working directory', fullwidth=True), 
     162        StrParam('run_command', '', 'shell command to execute project, absolute path needed or will search current PATH environment variable', fullwidth=True), 
    163163        ) 
    164164     
     
    169169        self.loadPrefs() 
    170170        self.loadTags() 
     171        self.process = None 
    171172     
    172173    def __str__(self): 
     
    200201            dprint("Failed writing project config file") 
    201202     
    202     def build(self): 
     203    def registerProcess(self, job): 
     204        self.process = job 
     205     
     206    def deregisterProcess(self, job): 
     207        self.process = None 
     208     
     209    def isRunning(self): 
     210        return bool(self.process) 
     211     
     212    def build(self, frame): 
    203213        dprint("Compiling %s in %s" % (self.build_command, self.build_dir)) 
    204      
    205     def run(self): 
     214        output = JobOutputSidebarController(frame, self.registerProcess, self.deregisterProcess) 
     215        ProcessManager().run(self.build_command, self.build_dir, output) 
     216     
     217    def run(self, frame): 
    206218        dprint("Running %s in %s" % (self.run_command, self.run_dir)) 
     219        output = JobOutputSidebarController(frame, self.registerProcess, self.deregisterProcess) 
     220        ProcessManager().run(self.run_command, self.run_dir, output) 
     221     
     222    def stop(self): 
     223        if self.process: 
     224            self.process.kill() 
    207225 
    208226 
     
    327345 
    328346    def isEnabled(self): 
    329         return bool(self.mode.project_info and self.mode.project_info.build_command) 
    330  
    331     def action(self, index=-1, multiplier=1): 
    332         self.mode.project_info.build() 
     347        return bool(self.mode.project_info and self.mode.project_info.build_command and not self.mode.project_info.isRunning()) 
     348 
     349    def action(self, index=-1, multiplier=1): 
     350        self.mode.project_info.build(self.frame) 
    333351 
    334352 
     
    337355    name = "Run..." 
    338356    icon = 'icons/application.png' 
    339     default_menu = ("Project", 100) 
     357    default_menu = ("Project", 101) 
    340358 
    341359    def isEnabled(self): 
    342         return bool(self.mode.project_info and self.mode.project_info.run_command) 
    343  
    344     def action(self, index=-1, multiplier=1): 
    345         self.mode.project_info.run() 
     360        return bool(self.mode.project_info and self.mode.project_info.run_command and not self.mode.project_info.isRunning()) 
     361 
     362    def action(self, index=-1, multiplier=1): 
     363        self.mode.project_info.run(self.frame) 
     364 
     365 
     366class StopProject(SelectAction): 
     367    """Stop the build or run of the project""" 
     368    name = "Stop" 
     369    icon = 'icons/stop.png' 
     370    default_menu = ("Project", 109) 
     371 
     372    def isEnabled(self): 
     373        return bool(self.mode.project_info and self.mode.project_info.run_command and self.mode.project_info.isRunning()) 
     374 
     375    def action(self, index=-1, multiplier=1): 
     376        self.mode.project_info.stop() 
    346377 
    347378 
     
    622653            actions.append(SaveGlobalTemplate) 
    623654        if mode.buffer.url in self.known_project_dirs: 
    624             actions.extend([SaveProjectTemplate, BuildProject, RunProject, 
     655            actions.extend([SaveProjectTemplate, 
     656                             
     657                            BuildProject, RunProject, StopProject, 
    625658                             
    626659                            RebuildCtags, LookupCtag])