def put(src, dst): if is_local(env.host_string): return shutil.copyfile(src, dst) else: return fabric_put(src, dst)
def put(src, dst): if is_local(env.host_string): return shutil.copyfile(src, dst) else: return fabric_put(src, dst)
def upload_deploy_key(self, private_key, remote_user, project_name): """ upload deploy key :param string private_key: private key local path default is ~/.ssh/.deploies/`github`.rsa :param string remote_user: remote user name to deploy :param string project_name: a project name :param string github: github repo name :param bool force_renew: try to replace deploy key when use auto-generate :param int key_length: must a legal ssh key length value. default is 8192 ..note:: if you use github and want to use auto generate private-key feature. there is two ways can do this: - you must set access token in your ~/.gitconfig file - you must disable github two-factor authentication, input your username and password. currently, we use `<remote_user>@cabric` as our deploy key name. so if you upload your key use to other purpose, don't use `@cabric` as key suffix. if github deploy key already exist and you want to replace deploy key. you must set `--fresh-new' option. cabric allow each machine deploy multiple github project, but disallow deploy same name project in one user. if you still want do this. - you can set github value if you use it. - deploy them in different remote user. ..note:: currently, this only works on linux. :return: """ if not os.path.exists(private_key): self.error("deploy key `%s' is not exists,please set it." % private_key) if os.path.exists(private_key): self.print_message("upload deploy key...") remote_key = self.get_remote_key(remote_user, project_name) remote_key_root = os.path.dirname(remote_key) run('test -e {0} || mkdir -p {0}'.format(remote_key_root), remote_user) with settings(warn_only=True): run('chmod 700 -Rf {}'.format(remote_key_root), remote_user) fabric_put(private_key, remote_key) run('chmod 600 -f {}'.format(remote_key)) run('chown {1} -f {0}'.format(remote_key, remote_user)) pass pass