Fix cert.csv utf-8

This commit is contained in:
VirtuBox
2020-10-14 18:17:06 +02:00
parent 256a07b4a5
commit c0547392e9
2 changed files with 7 additions and 28 deletions

View File

@@ -51,11 +51,14 @@ class WOAcme:
"""Export acme.sh csv certificate list"""
# check acme.sh is installed
WOAcme.check_acme(self)
if not WOShellExec.cmd_exec(
self, "{0} ".format(WOAcme.wo_acme_exec) +
"--list --listraw > /var/lib/wo/cert.csv"):
acme_list = WOShellExec.cmd_exec_stdout(
self, "{0} ".format(WOAcme.wo_acme_exec) +
"--list --listraw")
if acme_list:
WOFileUtils.textwrite(self, '/var/lib/wo/cert.csv', acme_list)
WOFileUtils.chmod(self, '/var/lib/wo/cert.csv', 0o600)
else:
Log.error(self, "Unable to export certs list")
WOFileUtils.chmod(self, '/var/lib/wo/cert.csv', 0o600)
def setupletsencrypt(self, acme_domains, acmedata):
"""Issue SSL certificates with acme.sh"""

View File

@@ -386,27 +386,3 @@ class WOFileUtils():
return True
else:
return False
def convertFileBestGuess(self, filename, filepath):
"""Convert file to utf-8"""
sourceFormats = ['ascii', 'iso-8859-1']
for format in sourceFormats:
try:
os.chdir(filepath)
with codecs.open(filename, 'rU', format) as sourceFile:
with codecs.open(
'tmp' + '/' + sourceFile, 'w', 'utf-8') as targetFile:
for line in sourceFile:
targetFile.write(line)
return
except UnicodeDecodeError:
pass
if os.path.exists("/tmp/{0}".format(filename)):
try:
self.rm(filepath + filename)
self.mvfile("/tmp/{0}".format(filename), filepath + filename)
except Exception as e:
Log.debug(self, "{0}".format(e))
Log.error(
self,
"Unable to move file : {0} ".format(filepath + filename))