mirror of
https://github.com/frappe/bench.git
synced 2025-01-24 07:28:25 +00:00
refactor: change "no_backup" variable and cleanup comments
This commit is contained in:
parent
0c29bba659
commit
1259b089c8
@ -202,8 +202,8 @@ def find_benches(location):
|
||||
|
||||
@click.command('migrate-env')
|
||||
@click.argument('python', type=str)
|
||||
@click.option('--no-backup', is_flag=True)
|
||||
def migrate_env(python, no_backup=False):
|
||||
@click.option('--no-backup', 'backup', is_flag=True, default=True)
|
||||
def migrate_env(python, backup=True):
|
||||
"""Migrate Virtual Environment to desired Python Version"""
|
||||
from bench.utils import migrate_env
|
||||
migrate_env(python=python, no_backup=no_backup)
|
||||
migrate_env(python=python, backup=backup)
|
||||
|
@ -987,7 +987,7 @@ def in_virtual_env():
|
||||
|
||||
return False
|
||||
|
||||
def migrate_env(python, no_backup=False):
|
||||
def migrate_env(python, backup=False):
|
||||
from bench.config.common_site_config import get_config
|
||||
from bench.app import get_apps
|
||||
|
||||
@ -1015,15 +1015,12 @@ def migrate_env(python, no_backup=False):
|
||||
except:
|
||||
log.warn('Please ensure Redis Connections are running or Daemonized.')
|
||||
|
||||
# I know, bad name for a flag. Thanks, Ameya! :| - <achilles@frappe.io>
|
||||
if not no_backup:
|
||||
# Back, the f*ck up.
|
||||
# Backup venv: restore using `virtualenv --relocatable` if needed
|
||||
if backup:
|
||||
parch = os.path.join(path, 'archived_envs')
|
||||
if not os.path.exists(parch):
|
||||
os.mkdir(parch)
|
||||
|
||||
# Simply moving. Thanks, Ameya.
|
||||
# I'm keen to zip.
|
||||
source = os.path.join(path, 'env')
|
||||
target = parch
|
||||
|
||||
@ -1031,17 +1028,12 @@ def migrate_env(python, no_backup=False):
|
||||
stamp = datetime.now().strftime('%Y%m%d_%H%M%S')
|
||||
dest = os.path.join(path, str(stamp))
|
||||
|
||||
# WARNING: This is an archive, you might have to use virtualenv --relocate
|
||||
# That's because virtualenv creates symlinks with shebangs pointing to executables.
|
||||
# shebangs, shebangs - ricky martin.
|
||||
|
||||
# ...and shutil.copytree is a f*cking mess.
|
||||
os.rename(source, dest)
|
||||
shutil.move(dest, target)
|
||||
|
||||
# Create virtualenv using specified python
|
||||
try:
|
||||
log.debug('Setting up a New Virtual {} Environment'.format(python))
|
||||
|
||||
exec_cmd('{virtualenv} --python {python} {pvenv}'.format(virtualenv=virtualenv, python=python, pvenv=pvenv))
|
||||
|
||||
apps = ' '.join(["-e {}".format(os.path.join("apps", app)) for app in get_apps()])
|
||||
|
Loading…
x
Reference in New Issue
Block a user