Fix cert.csv encoding to utf-8

This commit is contained in:
VirtuBox
2020-10-14 15:29:06 +02:00
parent 3ffeec6ef4
commit c3076cfdfe
5 changed files with 32 additions and 4 deletions

View File

@@ -9,7 +9,7 @@
# ------------------------------------------------------------------------- # -------------------------------------------------------------------------
# wget -qO wo wops.cc && sudo -E bash wo # wget -qO wo wops.cc && sudo -E bash wo
# ------------------------------------------------------------------------- # -------------------------------------------------------------------------
# Version 3.12.3 - 2020-10-13 # Version 3.12.4 - 2020-10-14
# ------------------------------------------------------------------------- # -------------------------------------------------------------------------
# CONTENTS # CONTENTS

View File

@@ -27,7 +27,7 @@ if os.geteuid() == 0:
os.makedirs('/var/lib/wo/tmp/') os.makedirs('/var/lib/wo/tmp/')
setup(name='wordops', setup(name='wordops',
version='3.12.3', version='3.12.4',
description='An essential toolset that eases server administration', description='An essential toolset that eases server administration',
long_description=LONG, long_description=LONG,
long_description_content_type='text/markdown', long_description_content_type='text/markdown',

View File

@@ -206,12 +206,15 @@ class WOAcme:
def cert_check(self, wo_domain_name): def cert_check(self, wo_domain_name):
"""Check certificate existance with acme.sh and return Boolean""" """Check certificate existance with acme.sh and return Boolean"""
WOAcme.export_cert(self) WOAcme.export_cert(self)
WOFileUtils.convertFileBestGuess(self, "cert.csv",
"/var/lib/wo/")
# set variable acme_cert # set variable acme_cert
acme_cert = False acme_cert = False
# define new csv dialect # define new csv dialect
csv.register_dialect('acmeconf', delimiter='|') csv.register_dialect('acmeconf', delimiter='|')
# open file # open file
certfile = open('/var/lib/wo/cert.csv', mode='r', encoding='utf-8') certfile = open('/var/lib/wo/cert.csv',
mode='r', encoding='utf-8')
reader = csv.reader(certfile, 'acmeconf') reader = csv.reader(certfile, 'acmeconf')
for row in reader: for row in reader:
# check if domain exist # check if domain exist

View File

@@ -3,6 +3,7 @@ import fileinput
import os import os
import pwd import pwd
import shutil import shutil
import codecs
from wo.core.logging import Log from wo.core.logging import Log
@@ -385,3 +386,27 @@ class WOFileUtils():
return True return True
else: else:
return False return False
def writeConversion(self, file):
with codecs.open('tmp' + '/' + file, 'w', 'utf-8') as targetFile:
for line in file:
targetFile.write(line)
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:
self.writeConversion(sourceFile)
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 change owner : {0} ".format(path))

View File

@@ -14,7 +14,7 @@ class WOVar():
"""Intialization of core variables""" """Intialization of core variables"""
# WordOps version # WordOps version
wo_version = "3.12.3" wo_version = "3.12.4"
# WordOps packages versions # WordOps packages versions
wo_wp_cli = "2.4.0" wo_wp_cli = "2.4.0"
wo_adminer = "4.7.5" wo_adminer = "4.7.5"