mirror of
https://github.com/frappe/bench.git
synced 2024-11-11 15:51:03 +00:00
Merge branch 'master' into vm_build
This commit is contained in:
commit
e6c1d5a3cc
@ -215,7 +215,7 @@ def is_version_upgrade(app='frappe', bench_path='.', branch=None):
|
|||||||
|
|
||||||
local_version = get_major_version(get_current_version(app, bench_path=bench_path))
|
local_version = get_major_version(get_current_version(app, bench_path=bench_path))
|
||||||
upstream_version = get_major_version(upstream_version)
|
upstream_version = get_major_version(upstream_version)
|
||||||
|
|
||||||
if upstream_version - local_version > 0:
|
if upstream_version - local_version > 0:
|
||||||
return (True, local_version, upstream_version)
|
return (True, local_version, upstream_version)
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ from datetime import datetime
|
|||||||
from bench.utils import which, exec_cmd
|
from bench.utils import which, exec_cmd
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
log.setLevel(logging.ERROR)
|
log.setLevel(logging.DEBUG)
|
||||||
|
|
||||||
def print_bench_version(ctx, param, value):
|
def print_bench_version(ctx, param, value):
|
||||||
"""Prints current bench version"""
|
"""Prints current bench version"""
|
||||||
@ -82,6 +82,12 @@ bench_command.add_command(remote_urls)
|
|||||||
from bench.commands.install import install
|
from bench.commands.install import install
|
||||||
bench_command.add_command(install)
|
bench_command.add_command(install)
|
||||||
|
|
||||||
|
from bench.config.common_site_config import get_config
|
||||||
|
try:
|
||||||
|
from urlparse import urlparse
|
||||||
|
except ImportError:
|
||||||
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
@click.command('migrate-env')
|
@click.command('migrate-env')
|
||||||
@click.argument('python', type = str)
|
@click.argument('python', type = str)
|
||||||
@click.option('--no-backup', default = False, help = 'Do not backup the existing Virtual Environment')
|
@click.option('--no-backup', default = False, help = 'Do not backup the existing Virtual Environment')
|
||||||
@ -89,6 +95,23 @@ def migrate_env(python, no_backup = False):
|
|||||||
"""
|
"""
|
||||||
Migrate Virtual Environment to desired Python Version.
|
Migrate Virtual Environment to desired Python Version.
|
||||||
"""
|
"""
|
||||||
|
try:
|
||||||
|
# Clear Cache before Bench Dies.
|
||||||
|
config = get_config(bench_path = os.getcwd())
|
||||||
|
rredis = urlparse(config['redis_cache'])
|
||||||
|
|
||||||
|
redis = '{redis} -p {port}'.format(
|
||||||
|
redis = which('redis-cli'),
|
||||||
|
port = rredis.port
|
||||||
|
)
|
||||||
|
|
||||||
|
log.debug('Clearing Redis Cache...')
|
||||||
|
exec_cmd('{redis} FLUSHALL'.format(redis = redis))
|
||||||
|
log.debug('Clearing Redis DataBase...')
|
||||||
|
exec_cmd('{redis} FLUSHDB'.format(redis = redis))
|
||||||
|
except Exception:
|
||||||
|
log.warn('Please ensure Redis Connections are running or Daemonized.')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# This is with the assumption that a bench is set-up within path.
|
# This is with the assumption that a bench is set-up within path.
|
||||||
path = os.getcwd()
|
path = os.getcwd()
|
||||||
@ -111,6 +134,7 @@ def migrate_env(python, no_backup = False):
|
|||||||
|
|
||||||
# WARNING: This is an archive, you might have to use virtualenv --relocate
|
# WARNING: This is an archive, you might have to use virtualenv --relocate
|
||||||
# That's because virtualenv creates symlinks with shebangs pointing to executables.
|
# That's because virtualenv creates symlinks with shebangs pointing to executables.
|
||||||
|
# shebangs, shebangs - ricky martin.
|
||||||
|
|
||||||
# ...and shutil.copytree is a f*cking mess.
|
# ...and shutil.copytree is a f*cking mess.
|
||||||
os.rename(source, dest)
|
os.rename(source, dest)
|
||||||
|
@ -16,6 +16,13 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
folders_in_bench = ('apps', 'sites', 'config', 'logs', 'config/pids')
|
folders_in_bench = ('apps', 'sites', 'config', 'logs', 'config/pids')
|
||||||
|
|
||||||
|
def safe_decode(string, encoding = 'utf-8'):
|
||||||
|
try:
|
||||||
|
string = string.decode(encoding)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
return string
|
||||||
|
|
||||||
def get_frappe(bench_path='.'):
|
def get_frappe(bench_path='.'):
|
||||||
frappe = get_env_cmd('frappe', bench_path=bench_path)
|
frappe = get_env_cmd('frappe', bench_path=bench_path)
|
||||||
if not os.path.exists(frappe):
|
if not os.path.exists(frappe):
|
||||||
@ -351,7 +358,7 @@ def get_git_version():
|
|||||||
'''returns git version from `git --version`
|
'''returns git version from `git --version`
|
||||||
extracts version number from string `get version 1.9.1` etc'''
|
extracts version number from string `get version 1.9.1` etc'''
|
||||||
version = get_cmd_output("git --version")
|
version = get_cmd_output("git --version")
|
||||||
version = version.decode('utf-8')
|
version = safe_decode(version)
|
||||||
version = version.strip().split()[2]
|
version = version.strip().split()[2]
|
||||||
version = '.'.join(version.split('.')[0:2])
|
version = '.'.join(version.split('.')[0:2])
|
||||||
return float(version)
|
return float(version)
|
||||||
|
@ -59,7 +59,7 @@ def install_bench(args):
|
|||||||
})
|
})
|
||||||
|
|
||||||
success = run_os_command({
|
success = run_os_command({
|
||||||
'pip': "sudo pip install ansible==2.4.1"
|
'pip': "sudo pip install ansible==2.5.0"
|
||||||
})
|
})
|
||||||
|
|
||||||
if not success:
|
if not success:
|
||||||
@ -82,6 +82,14 @@ def install_bench(args):
|
|||||||
if args.user == 'root':
|
if args.user == 'root':
|
||||||
raise Exception('Please run this script as a non-root user with sudo privileges, but without using sudo or pass --user=USER')
|
raise Exception('Please run this script as a non-root user with sudo privileges, but without using sudo or pass --user=USER')
|
||||||
|
|
||||||
|
# Python executable
|
||||||
|
if not args.production:
|
||||||
|
dist_name, dist_version = get_distribution_info()
|
||||||
|
if dist_name=='centos':
|
||||||
|
args.python = 'python3.6'
|
||||||
|
else:
|
||||||
|
args.python = 'python3'
|
||||||
|
|
||||||
# create user if not exists
|
# create user if not exists
|
||||||
extra_vars = vars(args)
|
extra_vars = vars(args)
|
||||||
extra_vars.update(frappe_user=args.user)
|
extra_vars.update(frappe_user=args.user)
|
||||||
@ -371,6 +379,11 @@ def parse_commandline_args():
|
|||||||
parser.add_argument('--admin-password', dest='admin_password', help='Set admin password')
|
parser.add_argument('--admin-password', dest='admin_password', help='Set admin password')
|
||||||
parser.add_argument('--bench-name', dest='bench_name', help='Create bench with specified name. Default name is frappe-bench')
|
parser.add_argument('--bench-name', dest='bench_name', help='Create bench with specified name. Default name is frappe-bench')
|
||||||
|
|
||||||
|
# Python interpreter to be used
|
||||||
|
parser.add_argument('--python', dest='python', default='python',
|
||||||
|
help=argparse.SUPPRESS
|
||||||
|
)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
return args
|
return args
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
register: bench_stat
|
register: bench_stat
|
||||||
|
|
||||||
- name: python3 bench init for develop
|
- name: python3 bench init for develop
|
||||||
command: bench init {{ bench_path }} --frappe-branch {{ branch }} --python python3
|
command: bench init {{ bench_path }} --frappe-branch {{ branch }} --python {{ python }}
|
||||||
args:
|
args:
|
||||||
creates: "{{ bench_path }}"
|
creates: "{{ bench_path }}"
|
||||||
when: not bench_stat.stat.exists and not production
|
when: not bench_stat.stat.exists and not production
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
|
- name: Install IUS repo for python 3.6
|
||||||
|
become: yes
|
||||||
|
become_user: root
|
||||||
|
yum:
|
||||||
|
name: https://centos7.iuscommunity.org/ius-release.rpm
|
||||||
|
state: present
|
||||||
|
|
||||||
- name: "Setup prerequisites using yum"
|
- name: "Setup prerequisites using yum"
|
||||||
become: yes
|
become: yes
|
||||||
become_user: root
|
become_user: root
|
||||||
@ -23,6 +30,7 @@
|
|||||||
- ntp
|
- ntp
|
||||||
- openssl-devel
|
- openssl-devel
|
||||||
- postfix
|
- postfix
|
||||||
|
- python36u
|
||||||
- python-devel
|
- python-devel
|
||||||
- python-setuptools
|
- python-setuptools
|
||||||
- python-pip
|
- python-pip
|
||||||
|
Loading…
Reference in New Issue
Block a user