refactor get_certbot_version into certbot_call, reusing its workspace

This commit is contained in:
Erica Portnoy 2019-08-26 17:50:16 -07:00
parent 48144d4fcb
commit 230af95640
2 changed files with 9 additions and 17 deletions

View file

@ -39,7 +39,15 @@ def _prepare_args_env(certbot_args, directory_url, http_01_port, tls_alpn_01_por
new_environ['TMPDIR'] = workspace
additional_args = []
if misc.get_certbot_version(workspace) >= LooseVersion('0.30.0'):
version_output = subprocess.check_output(['certbot', '--version'],
universal_newlines=True, stderr=subprocess.STDOUT,
cwd=workspace)
# Typical response is: output = 'certbot 0.31.0.dev0'
version_str = version_output.split(' ')[1].strip()
version = LooseVersion(version_str)
if version >= LooseVersion('0.30.0'):
additional_args.append('--no-random-sleep-on-renew')
if force_renew:

View file

@ -209,22 +209,6 @@ shutil.rmtree(well_known)
shutil.rmtree(tempdir)
def get_certbot_version(workspace):
"""
Find the version of the certbot available in PATH.
:return str: the certbot version
"""
workspace = os.environ.get('WORKSPACE', os.path.join(os.getcwd(), '.certbot_test_workspace'))
if not os.path.exists(workspace):
os.mkdir(workspace)
output = subprocess.check_output(['certbot', '--version'],
universal_newlines=True, stderr=subprocess.STDOUT,
cwd=workspace)
# Typical response is: output = 'certbot 0.31.0.dev0'
version_str = output.split(' ')[1].strip()
return LooseVersion(version_str)
def generate_csr(domains, key_path, csr_path, key_type=RSA_KEY_TYPE):
"""
Generate a private key, and a CSR for the given domains using this key.