2
0
mirror of https://github.com/frappe/bench.git synced 2024-09-23 04:29:02 +00:00

add bench shell fix #47

This commit is contained in:
Pratik Vyas 2014-08-27 17:23:04 +05:30
parent cd8de918ea
commit c989a974b5

View File

@ -17,6 +17,7 @@ from .config import generate_nginx_config, generate_supervisor_config
import os
import sys
import logging
import copy
logger = logging.getLogger('bench')
@ -30,6 +31,20 @@ def frappe(bench='.'):
os.chdir(os.path.join(bench, 'sites'))
os.execv(f, [f] + sys.argv[2:])
@click.command()
def shell(bench='.'):
if not os.environ.get('SHELL'):
print "Cannot get shell"
sys.exit(1)
if not os.path.exists('sites'):
print "sites dir doesn't exist"
sys.exit(1)
env = copy.copy(os.environ)
env['PS1'] = '(' + os.path.basename(os.path.dirname(os.path.abspath(__file__))) + ')' + env.get('PS1', '')
env['PATH'] = os.path.dirname(os.path.abspath(os.path.join('env','bin')) + ':' + env['PATH'])
os.chdir('sites')
os.execve(env['SHELL'], [env['SHELL']], env)
@click.group()
def bench(bench='.'):
"Bench manager for Frappe"
@ -265,3 +280,4 @@ bench.add_command(start)
bench.add_command(set_nginx_port)
bench.add_command(set_default_site)
bench.add_command(migrate_3to4)
bench.add_command(shell)