Changeset 1483
- Timestamp:
- 07/10/08 18:14:45 (7 weeks ago)
- Location:
- trunk/peppy
- Files:
-
- 3 modified
-
lib/processmanager.py (modified) (2 diffs)
-
plugins/error_log.py (modified) (3 diffs)
-
plugins/project.py (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/peppy/lib/processmanager.py
r1464 r1483 121 121 # Use the unicode rightward double arrow as a delimiter 122 122 arrow = u"\u21d2 " 123 started = _("Started %s on") 124 cwd = _("cwd = ") 125 exit = _("exit code = %s") 126 finished = _("Finished %s on") 123 127 124 128 def __init__(self, cmd, working_dir, job_output): … … 133 137 self.exit_code = 0 134 138 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 135 152 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) 137 154 138 155 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()))) 140 157 141 158 def run(self, text=""): -
trunk/peppy/plugins/error_log.py
r1459 r1483 16 16 from peppy.sidebar import * 17 17 from peppy.minor import * 18 from peppy.lib.processmanager import Job 18 19 19 20 class LoggingSTC(PeppySTC, ClassPrefs, debugmixin): … … 88 89 #sys.stdout.write("match ends at %d" % i) 89 90 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 "" 90 108 91 109 def OnDoubleClick(self, evt): … … 100 118 if match: 101 119 filename = match.group(1) 120 if not filename.startswith("/"): 121 path = self.findAbsolutePath(line) 122 filename = os.path.join(path, filename) 102 123 line = match.group(2) 103 124 self.open("%s#%s" % (filename, line)) -
trunk/peppy/plugins/project.py
r1480 r1483 160 160 StrParam('build_command', '', 'shell command to build project, relative to working directory', fullwidth=True), 161 161 DirParam('run_dir', '', 'working directory in which to execute the project', fullwidth=True), 162 StrParam('run_command', '', 'shell command to execute e 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), 163 163 ) 164 164 … … 169 169 self.loadPrefs() 170 170 self.loadTags() 171 self.process = None 171 172 172 173 def __str__(self): … … 200 201 dprint("Failed writing project config file") 201 202 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): 203 213 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): 206 218 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() 207 225 208 226 … … 327 345 328 346 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) 333 351 334 352 … … 337 355 name = "Run..." 338 356 icon = 'icons/application.png' 339 default_menu = ("Project", 10 0)357 default_menu = ("Project", 101) 340 358 341 359 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 366 class 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() 346 377 347 378 … … 622 653 actions.append(SaveGlobalTemplate) 623 654 if mode.buffer.url in self.known_project_dirs: 624 actions.extend([SaveProjectTemplate, BuildProject, RunProject, 655 actions.extend([SaveProjectTemplate, 656 657 BuildProject, RunProject, StopProject, 625 658 626 659 RebuildCtags, LookupCtag])
