コード例 #1
0
ファイル: fs.py プロジェクト: mwcz/vim-netranger
 def exec_fs_server_cmd(self, cmd, src_arr, dst=None, on_exit=None):
     src = ' '.join(['"{}"'.format(s) for s in src_arr])
     if dst:
         dst = '"{}"'.format(dst)
         cmd = 'python {} {} {} {}'.format(FS.FScmds, cmd, src, dst)
         Shell.run_async(cmd, on_exit=on_exit)
     else:
         cmd = 'python {} {} {}'.format(FS.FScmds, cmd, src)
         Shell.run_async(cmd, on_exit=on_exit)
コード例 #2
0
    def NETROpen(self, open_cmd=None, rifle_cmd=None, use_rifle=True):
        """
        The real work for opening directories is handled in on_bufenter. For openning files, we check if there's rifle rule to open the file. Otherwise, open it in vim.
        """
        curNode = self.curNode
        if curNode.isINFO:
            return

        if open_cmd is None:
            if curNode.isDir:
                open_cmd = 'edit'
            else:
                open_cmd = VimVar('NETROpenCmd')

        fullpath = curNode.fullpath
        if curNode.isDir:
            if curNode.size == '?' or curNode.size == '':
                VimErrorMsg('Permission Denied: {}'.format(curNode.name))
                return
            self.vim.command('silent {} {}'.format(open_cmd, fullpath))
            # manually call on_bufenter as vim might not trigger BufEnter with the above command
            self.on_bufenter(self.vim.eval("winnr()"))
        else:
            if self.rclone is not None and self.isRemotePath(fullpath):
                self.rclone.ensure_downloaded(fullpath)

            if rifle_cmd is None:
                rifle_cmd = self.rifle.decide_open_cmd(fullpath)

            if use_rifle and rifle_cmd is not None:
                Shell.run_async(rifle_cmd.format(fullpath))
            else:
                try:
                    self.vim.command('{} {}'.format(open_cmd, fullpath))
                except Exception as e:
                    err_msg = str(e)
                    if 'E325' not in err_msg:
                        VimErrorMsg(err_msg)
コード例 #3
0
ファイル: fs.py プロジェクト: mwcz/vim-netranger
 def exec_rclone_server_cmd(self, cmd, on_exit, arguments):
     fname = tempfile.mkstemp()[1]
     with open(fname, 'ab') as f:
         pickle.dump(arguments, f)
     Shell.run_async('python {} {} {}'.format(Rclone.FScmds, cmd, fname),
                     on_exit=on_exit)