mirror of
https://github.com/certbot/certbot.git
synced 2026-07-30 16:14:44 +02:00
more concise file content search using list comprehension
This commit is contained in:
@@ -58,12 +58,7 @@ def checkForApacheConfInclude(mainConfig):
|
|||||||
searchStr = "Include " + APACHE_CHALLENGE_CONF
|
searchStr = "Include " + APACHE_CHALLENGE_CONF
|
||||||
#conf = open(mainConfig, 'r+')
|
#conf = open(mainConfig, 'r+')
|
||||||
conf = open(mainConfig, 'r')
|
conf = open(mainConfig, 'r')
|
||||||
flag = False
|
if not any(line.startswith(searchStr) for line in conf):
|
||||||
for line in conf:
|
|
||||||
if line.startswith(searchStr):
|
|
||||||
flag = True
|
|
||||||
break
|
|
||||||
if not flag:
|
|
||||||
#conf.write(searchStr)
|
#conf.write(searchStr)
|
||||||
process = subprocess.Popen(["echo", "\n" + searchStr], stdout=subprocess.PIPE)
|
process = subprocess.Popen(["echo", "\n" + searchStr], stdout=subprocess.PIPE)
|
||||||
subprocess.check_output(["sudo", "tee", "-a", mainConfig], stdin=process.stdout)
|
subprocess.check_output(["sudo", "tee", "-a", mainConfig], stdin=process.stdout)
|
||||||
|
|||||||
Reference in New Issue
Block a user