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
Signed by: virtubox
GPG Key ID: 22EB296C97BAD476
5 changed files with 32 additions and 4 deletions

View File

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

View File

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

View File

@ -206,12 +206,15 @@ def check_dns(self, acme_domains):
def cert_check(self, wo_domain_name):
"""Check certificate existance with acme.sh and return Boolean"""
WOAcme.export_cert(self)
WOFileUtils.convertFileBestGuess(self, "cert.csv",
"/var/lib/wo/")
# set variable acme_cert
acme_cert = False
# define new csv dialect
csv.register_dialect('acmeconf', delimiter='|')
# 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')
for row in reader:
# check if domain exist

View File

@ -3,6 +3,7 @@
import os
import pwd
import shutil
import codecs
from wo.core.logging import Log
@ -385,3 +386,27 @@ def enabledisable(self, path, enable=True):
return True
else:
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"""
# WordOps version
wo_version = "3.12.3"
wo_version = "3.12.4"
# WordOps packages versions
wo_wp_cli = "2.4.0"
wo_adminer = "4.7.5"