Example #1
0
def install():
    """ Installs and sets zsh as default shell """
    # update apt index
    update_index(quiet=False)

    # install zsh
    utils._deb.install('zsh')

    # install zsh examples
    utils._deb.install('zsh-lovers')

    # set as default shell for the user
    print(green('Re-enter your password to set zsh as default.'))
    with settings(hide('warnings'), warn_only=True):
        cmd = 'chsh -s /bin/zsh %s' % env.user
        while True:  # prompt password until success
            if not run(cmd).failed:
                break
            else:
                print(red('Wrong password, try again.'))

    # install git if is not available
    git_install()
    # install oh-my-zsh
    git_clone('git://github.com/robbyrussell/oh-my-zsh.git', '~/.oh-my-zsh')

    # zsh configuration file: plugins
    plugins = []
    recommended_plugins = (['git', 'github', 'git-flow', 'heroku',
                           'last-working-dir', 'pip', 'autojump',
                            'command-not-found', 'debian', 'encode64',
                            'vagrant', 'ruby'])
    recommended_plugins.sort()
    for plugin in recommended_plugins:
        if confirm('Would you like to use the %s plugin?' % plugin):
            plugins.append(plugin)
    plugins = ' '.join(plugins)

    # zsh configuration file: default editor
    editor = prompt('Please specify your default editor', default='vim')

    context = {
        'plugins': plugins,
        'default_editor': editor,
        'user': env.user
    }
    upload_template('fabfile/templates/zshrc', '.zshrc', context=context)

    # zsh fabric autocomplete
    put('fabfile/templates/zsh_fab', '.zsh_fab')

    # upload custom themes
    themes()

    print(green('If the shell does not change, restart your session.'))
Example #2
0
    def source_clone(self):
        '''
        Clone the charts source

        We only support a git source type right now, which can also
        handle git:// local paths as well
        '''

        if self.chart.source.type == 'git':
            if self.parent:
                LOG.info("Cloning %s/%s as dependency for %s",
                         self.chart.source.location, self.chart.source.subpath,
                         self.parent)
            else:
                LOG.info("Cloning %s/%s for release %s",
                         self.chart.source.location, self.chart.source.subpath,
                         self.chart.release_name)

            self._source_tmp_dir = git_clone(self.chart.source.location,
                                             self.chart.source.reference)

            return os.path.join(self._source_tmp_dir,
                                self.chart.source.subpath)

        else:
            LOG.exception("Unknown source type %s for chart %s",
                          self.chart.name, self.chart.source.type)
Example #3
0
def install():
    """ Installs and configures vim """
    # update apt index
    update_index(quiet=False)

    # install vim
    utils._deb.install('vim')

    # backup vim configuration folder
    if exists('.vim'):
        print(green('Backing up your vim configuration folder to .vim-bkp'))
        cmd = 'mv .vim .vim-bkp'
        run(cmd)

    # backup vim configuration file
    if exists('.vimrc'):
        print(green('Backing up your vim configuration file to .vimrc-bkp'))
        cmd = 'mv .vimrc .vimrc-bkp'
        run(cmd)

    # clone vim_config repository
    print(green('Cloning Vim_config repository.'))
    # install git if is not available
    git_install()
    git_clone('git://github.com/magnet-cl/Vim_config.git', '.vim')

    # install required packages by plugins
    print(green('Installing plugins dependencies.'))
    # ctags, better grep, python flake, latex, C/C++ omnicompletion
    plugins = ['exuberant-ctags', 'ack-grep', 'pyflakes', 'lacheck', 'clang',
               'rhino']
    for plugin in plugins:
        utils._deb.install(plugin)
    # install pip if is not available
    if not is_pip_installed():
        install_pip()
    if not py_is_installed('flake8'):
        py_install('flake8', use_sudo=True)  # python flake+pep8

    # installation script
    print(green('Installing Vim_config.'))
    cmd = 'source .vim/install.sh'
    run(cmd)
Example #4
0
def move_issues(mantis_issues,
                gitrepo,
                project_name,
                description,
                mantis_id=None,
                add_after=False,
                debug=False,
                verbose=False):
    # remember the current directory
    with TemporaryDirectory():
        # clone the GitHub project
        git_clone(gitrepo.ssh_url, debug=debug, verbose=verbose)

        # move into the repo sandbox directory
        os.chdir(project_name)

        # add all issues
        mantis_issues.add_issues(mantis_id=mantis_id,
                                 add_after=add_after,
                                 report_progress=__progress_reporter)

    print()
Example #5
0
def main():
    cmds = load_cmds(tools)
    parser = setupCmdLine(cmds)
    opts, args = parser.parse_args()
    try: git_repo = args[0]
    except: exit_msg(parser.get_usage())

    runlist = [cmd(primary_opt, debug=opts.debug)
               for cmd, primary_opt in zip(cmds, map(lambda x: getattr(opts, x.name, None), cmds))
               if primary_opt]

    if len(runlist) == 0: exit_msg("Must specify a command to be run")

    out = {}

    if opts.update:
        in_paths = [opts.update]
        out_path = opts.update
    else:
        in_paths = opts.in_paths
        out_path = opts.out_path

    for in_path in in_paths:
        d = json.load(open(in_path, "r"))
        for commit, vals in d.iteritems():
            if not commit in out: out[commit] = vals
            else: out[commit]["results"].update(vals["results"])

    try:
        git_new = tempfile.mkdtemp()
        log("Temp dir created: %s", git_new)
        log("Cloning repo: %s -> %s", git_repo, git_new)
        git_clone(git_repo, git_new)

        skip = []
        process =[]
        for comm in git_log(git_new):
            if comm["commit"] in out and all([c.name in out[comm["commit"]]["results"] for c in runlist]):
                skip.append(comm)
            else: process.append(comm)

        log("%d commits: processing %d, skipping %d" % (len(skip)+len(process),
                                                        len(process),
                                                        len(skip)))
        for idx, comm in enumerate(process):
            sha1 = comm["commit"]
            rec = {
                "date" : comm["date"].strftime("%Y-%m-%d %H-%M-%S %z"),
                "author" : comm["author"]
                }
            if sha1 in out and "results" in out[sha1]: rec["results"] = out[sha1]
            else: rec["results"] = {}

            if opts.reload: schedule = runlist
            else: schedule = [cmd for cmd in runlist if cmd.name not in rec["results"]]

            log("Checking out revision %s [%d/%d]", comm["commit"], idx+1, len(process))
            git_checkout(git_new, sha1)

            for cmd in schedule:
                rec["results"][cmd.name] = {}
                try: rec["results"][cmd.name] = cmd.run(git_new)
                except CmdError,e:
                    log("Command '%r' failed with %d", e.cmd, e.ret)
                    log("Output: %s", e.out)
                except Exception, e:
                    log("Failed to get output of command: %r",e)
Example #6
0
def compare_all(project_name,
                svn_base_url,
                git_url,
                ignored=None,
                num_to_process=None,
                pause_on_error=False,
                rel_subdir="tags",
                save_snapshot=False,
                command_verbose=False,
                debug=False,
                verbose=False):

    with TemporaryDirectory() as tmpdir:
        # check out Git version in 'pdaq-git' subdirectory
        if verbose:
            print("Check out from Git")
        git_wrkspc = os.path.join(tmpdir.name, project_name + "-git")
        try:
            git_clone(git_url,
                      recurse_submodules=True,
                      sandbox_dir=tmpdir.name,
                      target_dir=git_wrkspc,
                      debug=debug,
                      verbose=command_verbose)
        except GitException:
            if debug:
                traceback.print_exc()
            raise SystemExit("Failed to clone %s" % git_url)

        # check out SVN version in 'pdaq-svn' subdirectory
        if verbose:
            print("Check out from Subversion")
        svn_wrkspc = os.path.join(tmpdir.name, project_name + "-svn")
        try:
            svn_checkout(svn_url="/".join((svn_base_url, "trunk")),
                         target_dir=svn_wrkspc,
                         debug=debug,
                         verbose=command_verbose)
        except:
            # if there's no 'trunk' try just the base URL
            svn_checkout(svn_url=svn_base_url,
                         target_dir=svn_wrkspc,
                         debug=debug,
                         verbose=command_verbose)

        # compare trunk releases
        compare_loudly("trunk",
                       svn_wrkspc,
                       git_wrkspc,
                       ignored=ignored,
                       pause_on_error=pause_on_error,
                       debug=debug,
                       verbose=verbose)

        try:
            svn_rel_base = os.path.join(svn_base_url, rel_subdir)
            for _, release in list_projects(svn_rel_base,
                                            debug=debug,
                                            verbose=command_verbose):
                if not switch_subproject(release,
                                         git_wrkspc,
                                         svn_wrkspc,
                                         svn_rel_base,
                                         save_snapshot=save_snapshot,
                                         command_verbose=command_verbose,
                                         debug=debug,
                                         verbose=verbose):
                    continue

                compare_loudly(release,
                               svn_wrkspc,
                               git_wrkspc,
                               ignored=ignored,
                               pause_on_error=pause_on_error,
                               debug=debug,
                               verbose=verbose)

                if num_to_process is not None:
                    num_to_process -= 1
                    if num_to_process <= 0:
                        break
        except SVNConnectException:
            pass