def excepthook(type, value, trace): if type == KeyboardInterrupt: print "" return pyvim.echoline(">>Error(%s): %s: " % (LOGFILE, type.__name__ + str(value))) log.error("Uncaught exception:", exc_info =(type, value, trace))
def showpos(response): try: linenu = int(response.msg) except: return vim.current.window.cursor = ( linenu, 0 ) vim.command("normal zt") pyvim.redraw() pyvim.echoline(response.msg)
def search_from_db(patten): try: r = urllib2.urlopen("http://localhost/wubi/search?patten=%s" % patten) w = json.loads(r.read()) cache[patten] = w return w except Exception, e: pyvim.echoline(str(e)) return ([], [])
def setcount(patten, num): w, ass = cache.pop(patten) if len(w) -1 < num: return ww = w[num] url = "http://localhost/wubi/setcount?patten=%s&word=%s" % (patten, ww.encode('utf8')) try: urllib2.urlopen(url) except Exception, e: pyvim.echoline(str(e))
def gototag(): backpos = vim.current.window.cursor client = VuiClient() client.sethandle(110, showpos) client.sethandle(200, showpos) client.request("/open/tag", {"values": get_file_tag(vim.current.buffer.name)}) response = client.response() if response.code > 200: vim.current.window.cursor = backpos pyvim.echoline("Quit")
def _goto(self, index): tag = self.taglist[index] g.taglist_cur = self.taglist tag.goto() TagStack().push(tag) g.taglist_cur = None pyvim.echoline('Tag(%s) goto %s/%s kind: %s. [%s]' % (tag.tag, index + 1, self.num, tag.kind, g.msg))
def listdir(path): s, o = runssh(path, 'ls -L --color=never -1 -p') if s != 0: pyvim.echoline('ssh error: %s' % o) return None, None logging.error(o) lines = o.split('\n') fs = [] dirs = [] for line in lines: if line[-1] == '/': dirs.append(line[0:-1]) else: fs.append(line) return (dirs, fs)
def listdir(path): s, o = runssh(path, "ls -L --color=never -1 -p") if s != 0: pyvim.echoline("ssh error: %s" % o) return None, None logging.info(o) lines = o.split("\n") fs = [] dirs = [] for line in lines: if line[-1] == "/": dirs.append(line[0:-1]) else: fs.append(line) return (dirs, fs)
def FrainAddInclude(path): if not FrainList.get_instance(): return project = FrainList().cur_project() if not project: return if not os.path.isdir(path): pyvim.echoline('%s is not dir' % path) return path = os.path.realpath(path) project.add_c_include(path) Project.update_c_include()
def Tag(tag=None): if not tag: tag = pyvim.current_word() root = pyvim.get_cur_root() if not root: pyvim.echoline('not in project path') return taglist, err = libtag.find_tag(root, tag) if not taglist: pyvim.echoline(err) return frame = TagFrame(taglist) frame.goto()
def push(tmp_file, scp_path): t = paser(scp_path) if not t: return user, host, path = t cmd = 'scp -o ConnectTimeout=3 %s %s%s:%s ' % ( tmp_file, user, host, path) pyvim.echoline('start scp: %s' % scp_path) code, o = commands.getstatusoutput(cmd) if code == 0: pyvim.echoline('Push success: %s' % scp_path) else: logging.error(cmd) pyvim.echoline('Push fail: %s' % scp_path, hl=True)
def pull(scp_path, tempfile): t = paser(scp_path) if not t: return user, host, path = t cmd = "scp -o ConnectTimeout=3 %s%s:%s %s" % (user, host, path, tempfile) pyvim.echoline("start scp: %s" % scp_path) code, o = commands.getstatusoutput(cmd) if code == 0: pyvim.echoline("Pull success: %s" % scp_path) else: logging.error(cmd) pyvim.echoline("Pull fail: %s" % scp_path, hl=True) return return tempfile
def handle100(response): time.sleep(0.2) os.system('wmctrl -a VuiRpcQs') pyvim.echoline(response.reason)
def showfile(response): filepath = response.msg vim.command("silent edit %s" % filepath) pyvim.redraw() pyvim.echoline(filepath)