Beispiel #1
0
    def install_rclone(self):
        import platform
        import zipfile

        rclone_dir = Vim.UserInput(
            'Rclone not in PATH. Install it at (modify/enter)',
            os.path.expanduser('~/rclone'))
        Shell.mkdir(rclone_dir)

        system = platform.system().lower()
        processor = 'amd64'
        if '386' in platform.processor():
            processor = '386'
        else:
            # Should support arm??
            pass

        url = f'https://downloads.rclone.org/rclone-current-{system}-{processor}.zip'
        zip_fname = os.path.join(rclone_dir, 'rclone.zip')
        Shell.urldownload(url, zip_fname)
        zip_ref = zipfile.ZipFile(zip_fname, 'r')
        zip_ref.extractall(rclone_dir)
        for entry in zip_ref.NameToInfo:
            if entry.endswith('rclone'):
                Shell.cp(os.path.join(rclone_dir, entry), rclone_dir)
                Shell.chmod(os.path.join(rclone_dir, 'rclone'), 755)

        zip_ref.close()
        os.remove(zip_fname)

        shellrc = Vim.UserInput(
            'Update PATH in (leave blank to set manually later)',
            Shell.shellrc())
        if len(shellrc) > 0:
            with open(shellrc, 'a') as f:
                f.write(f'PATH={rclone_dir}:$PATH\n')
        os.environ['PATH'] += ':' + rclone_dir
Beispiel #2
0
    def unmodify(self, fullpath):

        ans = Vim.UserInput("This will discard any made changes. Proceed "
                            "anyway? (y/n)")
        if ans == 'y':
            self.run_cmd('checkout {}'.format(fullpath))