Refactor function

This commit is contained in:
VirtuBox
2019-08-30 08:09:27 +02:00
parent ebea1e5e7d
commit 01c1c3909c
2 changed files with 14 additions and 14 deletions

View File

@@ -761,7 +761,8 @@ class WOSiteCreateController(CementBaseController):
(not pargs.letsencrypt == 'wildcard')): (not pargs.letsencrypt == 'wildcard')):
wo_subdomain = True wo_subdomain = True
# check if a wildcard cert for the root domain exist # check if a wildcard cert for the root domain exist
if checkWildcardExist(self, wo_root_domain): isWildcard = checkWildcardExist(self, wo_root_domain)
if isWildcard is True:
# copy the cert from the root domain # copy the cert from the root domain
copyWildcardCert(self, wo_domain, wo_root_domain) copyWildcardCert(self, wo_domain, wo_root_domain)
else: else:

View File

@@ -1479,19 +1479,18 @@ def checkWildcardExist(self, wo_domain_name):
# define new csv dialect # define new csv dialect
csv.register_dialect('acmeconf', delimiter='|') csv.register_dialect('acmeconf', delimiter='|')
# open file # open file
with open('/var/lib/wo/cert.csv', 'rt') as wo_cert: certfile = open('/var/lib/wo/cert.csv', 'rt')
reader = csv.reader(wo_cert, 'acmeconf') reader = csv.reader(certfile, 'acmeconf')
wo_wildcard_domain = ("*.{0}".format(wo_domain_name)) wo_wildcard_domain = ("*.{0}".format(wo_domain_name))
try: for row in reader:
for row in reader: if wo_wildcard_domain in row[2]:
if wo_wildcard_domain in row[2]: isWildcard = True
return True break
break else:
else: isWildcard = False
return False certfile.close()
except csv.Error as e:
Log.debug(self, "{0}".format(e)) return isWildcard
Log.error(self, "Failed to read cert list")
# copy wildcard certificate to a subdomain # copy wildcard certificate to a subdomain