created copyto method

modified:   modules/pip.py
This commit is contained in:
Ronny Abraham 2016-09-21 15:44:46 +03:00
parent e4f80bf0ae
commit 8a3a66a9fd

View file

@ -141,13 +141,16 @@ def freeze(param=False):
@task @task
def copy(branch): def copyto(branch):
""" """
copy requirements from the specified branch to the current branch copy requirements from the current branch to the specified branch
this only changes the requirements on the local branches. It does not this only changes the requirements on the local branches. It does not
upload remotely. This is because I want to use deploy.sync to do all upload remotely. This is because I want to use deploy.sync to do all
remote updates remote updates
Keyword Arguments:
branch -- the branch to copy to
""" """
configuration = env.config configuration = env.config
@ -161,11 +164,10 @@ def copy(branch):
"values.".format(branch=branch, branchlist=branch_list), "values.".format(branch=branch, branchlist=branch_list),
ERROR_BAD_BRANCH_PARAM) ERROR_BAD_BRANCH_PARAM)
elif configuration.project.branch == 'development': elif branch == 'development':
printerr( printerr(
"This method copies to current branch which is you set to " "This method does not allow copying to development branch",
"development. That is not allowed for sanity reasons.",
ERROR_BAD_BRANCH_PARAM) ERROR_BAD_BRANCH_PARAM)
elif configuration.project.branch == branch: elif configuration.project.branch == branch:
@ -175,24 +177,10 @@ def copy(branch):
"This will simply copy over \n\tthe requirements file for " "This will simply copy over \n\tthe requirements file for "
"this branch with itself", ERROR_BAD_BRANCH_PARAM) "this branch with itself", ERROR_BAD_BRANCH_PARAM)
print "current: %s" % configuration.virtualenv.requirements.filepath
from initialize import get_config from initialize import get_config
branch_config = get_config(branch) branch_config = get_config(branch)
print "current filepath: %s" % \
configuration.virtualenv.requirements.filepath
print "current filename: %s" % \
configuration.virtualenv.requirements.filename
print
print "branch filepath: %s" % \
branch_config.virtualenv.requirements.filepath
print "branch filename: %s" % \
branch_config.virtualenv.requirements.filename
current_local_path = os.path.join( current_local_path = os.path.join(
configuration.virtualenv.requirements.local, configuration.virtualenv.requirements.local,
configuration.virtualenv.requirements.filename) configuration.virtualenv.requirements.filename)
@ -201,16 +189,22 @@ def copy(branch):
configuration.virtualenv.requirements.local, configuration.virtualenv.requirements.local,
branch_config.virtualenv.requirements.filename) branch_config.virtualenv.requirements.filename)
print "current_local : %s" % current_local_path print "current_local_path: %s" % current_local_path
print "branch_local : %s" % branch_local_path print "branch_local_path: %s" % branch_local_path
print message = "Copying file from current branch '{branch_src}' to " \
print "destination branch '{branch_dst}'. Continue? Y/n ".format(
print branch_src=configuration.project.branch, branch_dst=branch)
message = "Copying file from branch {branch_src} to " \
"branch {branch_dst}. Continue? Y/n ".format(
branch_src=branch, branch_dst=configuration.project.branch)
from utils import prompt_continue from utils import prompt_continue
prompt_continue(message=message) prompt_continue(message=message)
from utils import upload_template
upload_template(
filename=configuration.virtualenv.requirements.filename,
destination=branch_local_path,
context=None,
use_jinja=False,
use_sudo=False,
backup=True,
template_dir=configuration.virtualenv.requirements.local)