def run(self): self.started = time.time() tid = gs.begin(DOMAIN, self.message, set_status=False, cancel=self.cancel) try: try: self.p = gs.popen( self.cmd, shell=self.shell, stderr=subprocess.STDOUT, environ=self.env, cwd=self.cwd, bufsize=1, ) CommandStdoutReader(self, self.p.stdout).start() except Exception as ex: self.x = ex finally: self.rcode = self.p.wait() if self.p else False finally: gs.end(tid) self.ended = time.time() self.on_done(self) for f in self.done: try: f(self) except Exception: gs.notice(DOMAIN, gs.traceback())
def on_done(new_name): if new_name == current_selection: return view.window().run_command("show_panel", {"panel": "console"}) gs.println(DOMAIN, 'Requested New Name: {0}'.format(new_name)) offset = '{0}:#{1}'.format(filename, region.begin()) command = ['gorename', '-v', '-offset', offset, '-to', new_name] gs.println(DOMAIN, 'CMD: {0}'.format(' '.join(command))) # Save all Go views for win in sublime.windows(): for v in win.views(): if not self._is_go_source(v): continue v.run_command("save") out = err = "" try: p = gs.popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, environ=os.environ) out = p.communicate()[0] gs.println('GsGorename', out) if p.returncode != 0: raise OSError("GoRename failed: %s" % command) except Exception as e: msg = gs.tbck.format_exc() gs.println(DOMAIN, msg)
def run(self): self.started = time.time() tid = gs.begin(DOMAIN, self.message, set_status=False, cancel=self.cancel) try: try: self.p = gs.popen(self.cmd, shell=self.shell, stderr=subprocess.STDOUT, environ=self.env, cwd=self.cwd, bufsize=1) CommandStdoutReader(self, self.p.stdout).start() except Exception as ex: self.x = ex finally: self.rcode = self.p.wait() if self.p else False finally: gs.end(tid) self.ended = time.time() self.on_done(self) for f in self.done: try: f(self) except Exception: gs.notice(DOMAIN, gs.traceback())
def on_done(new_name): if new_name == current_selection: return gs.println(DOMAIN, 'Requested New Name: {0}'.format(new_name)) offset = '{0}:#{1}'.format(filename, region.begin()) command = ['gorename', '-offset', offset, '-to', new_name] gs.println(DOMAIN, 'CMD: {0}'.format(' '.join(command))) out = "" try: p = gs.popen(command, stderr=subprocess.STDOUT) out = p.communicate()[0] if p.returncode != 0: raise OSError("GoRename failed") except Exception as e: msg = gs.tbck.format_exc() if out: msg = '{0}\n{1}'.format(msg, gs.ustr(out)) gs.show_output('GsGorename', msg, replace=False, merge_domain=False)