Ejemplo n.º 1
0
def git_reset(use_sudo=False):
    """
        Reset git to last version
    """
    func = use_sudo and sudo or run
    with in_project():
        func('git reset --hard')
Ejemplo n.º 2
0
def django_cleanpyc(use_sudo=False):
    """
        Run python manage.py cleanpyc
    """
    func = use_sudo and sudo or run
    with in_project():
        func("find . -type f -name '*.py[co]' -delete")
Ejemplo n.º 3
0
def django_cleanpyc(use_sudo=False):
    """
        Run python manage.py cleanpyc
    """
    func = use_sudo and sudo or run
    with in_project():
        func("find . -name '*.pyc' -delete")
Ejemplo n.º 4
0
def install_requirements(use_sudo=False, exists_action='i'):
    "Install the required packages from the requirements file using pip"
    func = use_sudo and sudo or run
    with venv():
        with in_project():
            func(
                "pip install -r requirements.txt --exists-action=%s" % exists_action)
Ejemplo n.º 5
0
def install_lib(lib_name, use_sudo=False):
    """
        Install lib with given name
    """
    func = use_sudo and sudo or run
    with venv():
        with in_project():
            func("pip install %s" % lib_name)
Ejemplo n.º 6
0
def django_env(command, use_sudo=False):
    """
        run command in django environment
    """
    func = use_sudo and sudo or run

    with venv():
        with in_project():
            func(command)
Ejemplo n.º 7
0
def get_current_id(use_sudo=False):
    """

    :return:
    """
    func = use_sudo and sudo or run
    with in_project():
        id = func('git rev-parse HEAD')
    return id
Ejemplo n.º 8
0
def django_env(command, use_sudo=False):
    """
        run command in django environment
    """
    func = use_sudo and sudo or run

    with venv():
        with in_project():
            func(command)
Ejemplo n.º 9
0
def git_checkout(use_sudo=False):
    """
        Checkout a branch or tag
    """
    func = use_sudo and sudo or run
    with in_project():
        if env.git_branch:
            func('git checkout %(git_branch)s' % env)
        else:
            func('git checkout %(git_tag)s' % env)
Ejemplo n.º 10
0
def git_update_project(use_sudo=False):
    """
        Update git repository
    """
    func = use_sudo and sudo or run
    with in_project():
        if env.git_branch:
            func('git pull')
        else:
            func('git fetch --tags')
        git_checkout(use_sudo)
Ejemplo n.º 11
0
def get_logs(since=None, use_sudo=False):
    """
        save formated git logs to file in project_path, read all logs,
        delete tmp file, create a dict and return all logs
    """
    func = use_sudo and sudo or run
    command = 'git log --format="%s"' % GIT_LOG_FORMAT
    if since:
        command += ' %(since)s..HEAD' % {'since': since}
    command += ' > ' + GIT_LOG_FILENAME
    with in_project():
        func(command)
        get(os.path.join(env.project_path, GIT_LOG_FILENAME), GIT_LOG_FILENAME)
        f = open(GIT_LOG_FILENAME, 'r')
        r = f.readlines()
        f.close()
        os.remove(GIT_LOG_FILENAME)

    log = [row.strip().split("\x1f") for row in r]
    log = [dict(zip(GIT_COMMIT_FIELDS, row)) for row in log]
    return log