sudo('touch /etc/pip.conf') sudo('echo "[global]" >> /etc/pip.conf') sudo('echo "timeout = 600" >> /etc/pip.conf') sudo('echo "index-url = https://{}/simple/" >> /etc/pip.conf'.format( os.environ['conf_pypi_mirror'])) sudo('echo "trusted-host = {}" >> /etc/pip.conf'.format( os.environ['conf_pypi_mirror'])) sudo('touch /home/{}/pip_china_ensured'.format(args.user)) if __name__ == "__main__": print("Configure connections") env['connection_attempts'] = 100 env.key_filename = [args.keyfile] env.host_string = '{}@{}'.format(args.user, args.hostname) deeper_config = json.loads(args.additional_config) if args.region == 'cn-north-1': change_pkg_repos() create_china_pip_conf_file() print("Updating repositories and installing requested tools.") if not ensure_pkg(args.user): sys.exit(1) print("Installing python packages: {}".format(args.pip_packages)) if not ensure_pip(args.pip_packages): sys.exit(1) sys.exit(0)
if not exists('/home/{}/pip_china_ensured'.format(args.user)): sudo('touch /etc/pip.conf') sudo('echo "[global]" >> /etc/pip.conf') sudo('echo "timeout = 600" >> /etc/pip.conf') sudo('echo "index-url = https://{}/simple/" >> /etc/pip.conf'.format(os.environ['conf_pypi_mirror'])) sudo('echo "trusted-host = {}" >> /etc/pip.conf'.format(os.environ['conf_pypi_mirror'])) sudo('touch /home/{}/pip_china_ensured'.format(args.user)) if __name__ == "__main__": print("Configure connections") env['connection_attempts'] = 100 env.key_filename = [args.keyfile] env.host_string = '{}@{}'.format(args.user, args.hostname) deeper_config = json.loads(args.additional_config) if args.region == 'cn-north-1': change_pkg_repos() create_china_pip_conf_file() print("Updating hosts file") update_hosts_file(args.user) print("Updating repositories and installing requested tools.") ensure_pkg(args.user) print("Installing python packages: {}".format(args.pip_packages)) ensure_pip(args.pip_packages)