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')
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")
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")
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)
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)
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)
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
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)
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)
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