mirror of
https://github.com/certbot/certbot.git
synced 2026-08-03 16:12:13 +02:00
Incorporated Kuba's feedback
This commit is contained in:
+12
-12
@@ -83,7 +83,7 @@ def copy_config(server_root, temp_dir):
|
|||||||
:rtype: `tuple` of `list` of `str`
|
:rtype: `tuple` of `list` of `str`
|
||||||
|
|
||||||
"""
|
"""
|
||||||
copied_files, copied_dirs = list(), list()
|
copied_files, copied_dirs = [], []
|
||||||
dir_len = len(os.path.dirname(server_root))
|
dir_len = len(os.path.dirname(server_root))
|
||||||
|
|
||||||
for config_path, config_dirs, config_files in os.walk(server_root):
|
for config_path, config_dirs, config_files in os.walk(server_root):
|
||||||
@@ -91,7 +91,7 @@ def copy_config(server_root, temp_dir):
|
|||||||
os.mkdir(temp_path)
|
os.mkdir(temp_path)
|
||||||
|
|
||||||
copied_all = True
|
copied_all = True
|
||||||
copied_files_in_current_dir = list()
|
copied_files_in_current_dir = []
|
||||||
for config_file in config_files:
|
for config_file in config_files:
|
||||||
config_file_path = os.path.join(config_path, config_file)
|
config_file_path = os.path.join(config_path, config_file)
|
||||||
temp_file_path = os.path.join(temp_path, config_file)
|
temp_file_path = os.path.join(temp_path, config_file)
|
||||||
@@ -202,15 +202,15 @@ def verify_config(args):
|
|||||||
:param argparse.Namespace args: Parsed command line arguments
|
:param argparse.Namespace args: Parsed command line arguments
|
||||||
|
|
||||||
"""
|
"""
|
||||||
try:
|
with open(os.devnull, "w") as devnull:
|
||||||
with open(os.devnull, "w") as devnull:
|
try:
|
||||||
subprocess.check_call([args.apache_ctl, "-d", args.server_root,
|
subprocess.check_call([args.apache_ctl, "-d", args.server_root,
|
||||||
"-f", args.config_file, "-t"],
|
"-f", args.config_file, "-t"],
|
||||||
stdout=devnull, stderr=subprocess.STDOUT)
|
stdout=devnull, stderr=subprocess.STDOUT)
|
||||||
except OSError:
|
except OSError:
|
||||||
sys.exit(_NO_APACHECTL)
|
sys.exit(_NO_APACHECTL)
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
sys.exit("Syntax check from apachectl failed")
|
sys.exit("Syntax check from apachectl failed")
|
||||||
|
|
||||||
|
|
||||||
def locate_config(apache_ctl):
|
def locate_config(apache_ctl):
|
||||||
@@ -234,9 +234,9 @@ def locate_config(apache_ctl):
|
|||||||
for line in output.splitlines():
|
for line in output.splitlines():
|
||||||
# Relevant output lines are of the form: -D DIRECTIVE="VALUE"
|
# Relevant output lines are of the form: -D DIRECTIVE="VALUE"
|
||||||
if "HTTPD_ROOT" in line:
|
if "HTTPD_ROOT" in line:
|
||||||
server_root = line[line.find("\"")+1:-1]
|
server_root = line[line.find('"')+1:-1]
|
||||||
elif "SERVER_CONFIG_FILE" in line:
|
elif "SERVER_CONFIG_FILE" in line:
|
||||||
config_file = line[line.find("\"")+1:-1]
|
config_file = line[line.find('"')+1:-1]
|
||||||
|
|
||||||
if not (server_root and config_file):
|
if not (server_root and config_file):
|
||||||
sys.exit("Unable to locate Apache configuration. Please run this "
|
sys.exit("Unable to locate Apache configuration. Please run this "
|
||||||
@@ -283,7 +283,7 @@ def get_args():
|
|||||||
def main():
|
def main():
|
||||||
"""Main script execution"""
|
"""Main script execution"""
|
||||||
args = get_args()
|
args = get_args()
|
||||||
if not args.server_root:
|
if args.server_root is None:
|
||||||
args.server_root, args.config_file = locate_config(args.apache_ctl)
|
args.server_root, args.config_file = locate_config(args.apache_ctl)
|
||||||
|
|
||||||
verify_config(args)
|
verify_config(args)
|
||||||
@@ -296,7 +296,7 @@ def main():
|
|||||||
with contextlib.closing(tarfile.open(tarpath, mode="w:gz")) as tar:
|
with contextlib.closing(tarfile.open(tarpath, mode="w:gz")) as tar:
|
||||||
tar.add(tempdir, arcname=".")
|
tar.add(tempdir, arcname=".")
|
||||||
|
|
||||||
# Submit tarpath
|
# TODO: Submit tarpath
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
+2
-2
@@ -10,7 +10,7 @@ import unittest
|
|||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
import letshelp_letsencrypt.letshelp_letsencrypt_apache as letshelp_le_apache
|
import letshelp_letsencrypt.apache as letshelp_le_apache
|
||||||
|
|
||||||
|
|
||||||
_PARTIAL_CONF_PATH = os.path.join("mods-available", "ssl.load")
|
_PARTIAL_CONF_PATH = os.path.join("mods-available", "ssl.load")
|
||||||
@@ -25,7 +25,7 @@ _SECRET_FILE = pkg_resources.resource_filename(
|
|||||||
__name__, os.path.join("testdata", "super_secret_file.txt"))
|
__name__, os.path.join("testdata", "super_secret_file.txt"))
|
||||||
|
|
||||||
|
|
||||||
_MODULE_NAME = "letshelp_letsencrypt.letshelp_letsencrypt_apache"
|
_MODULE_NAME = "letshelp_letsencrypt.apache"
|
||||||
|
|
||||||
|
|
||||||
_COMPILE_SETTINGS = """Server version: Apache/2.4.10 (Debian)
|
_COMPILE_SETTINGS = """Server version: Apache/2.4.10 (Debian)
|
||||||
@@ -1,11 +1,22 @@
|
|||||||
|
import sys
|
||||||
|
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
from setuptools import find_packages
|
from setuptools import find_packages
|
||||||
|
|
||||||
|
|
||||||
install_requires = ["mock<1.1.0",]
|
install_requires = []
|
||||||
|
if sys.version_info < (2, 7):
|
||||||
|
install_requires.append("mock<1.1.0")
|
||||||
|
else:
|
||||||
|
install_requires.append("mock")
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="letshelp-letsencrypt",
|
name="letshelp-letsencrypt",
|
||||||
packages=find_packages(),
|
packages=find_packages(),
|
||||||
install_requires=install_requires,
|
install_requires=install_requires,
|
||||||
|
entry_points={
|
||||||
|
'console_scripts': [
|
||||||
|
"letshelp-letsencrypt-apache = letshelp_letsencrypt.apache:main",
|
||||||
|
],
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user