Fix utf8 encoding when reading files
This commit is contained in:
@@ -47,7 +47,7 @@ class WORepo():
|
||||
Log.debug(self, "{0}".format(e))
|
||||
Log.error(self, "Unable to add repo")
|
||||
if ppa is not None:
|
||||
WOShellExec.cmd_exec(self, "add-apt-repository -yu '{ppa_name}'"
|
||||
WOShellExec.cmd_exec(self, "LC_ALL=C.UTF-8 add-apt-repository -yu '{ppa_name}'"
|
||||
.format(ppa_name=ppa))
|
||||
|
||||
def remove(self, ppa=None, repo_url=None):
|
||||
|
||||
@@ -29,14 +29,14 @@ def GetDomainlevel(domain):
|
||||
"""
|
||||
This function returns the domain type : domain, subdomain,
|
||||
"""
|
||||
domain_name = domain.split('.')
|
||||
domain_name = domain.split('.').lower()
|
||||
if domain_name[0] == 'www':
|
||||
domain_name = domain_name[1:]
|
||||
domain_type = ''
|
||||
if os.path.isfile("/var/lib/wo/public_suffix_list.dat"):
|
||||
# Read mode opens a file for reading only.
|
||||
Suffix_file = open(
|
||||
"/var/lib/wo/public_suffix_list.dat", mode='rt', encoding='utf-8')
|
||||
"/var/lib/wo/public_suffix_list.dat", encoding='utf-8', )
|
||||
# Read all the lines into a list.
|
||||
for domain_suffix in Suffix_file:
|
||||
if (str(domain_suffix).strip()) == ('.'.join(domain_name[1:])):
|
||||
|
||||
@@ -109,7 +109,7 @@ class WOFileUtils():
|
||||
rstr: replace string
|
||||
"""
|
||||
try:
|
||||
Log.debug(self, "Doning search and replace, File:{0},"
|
||||
Log.debug(self, "Doing search and replace, File:{0},"
|
||||
"Source string:{1}, Dest String:{2}"
|
||||
.format(fnm, sstr, rstr))
|
||||
for line in fileinput.input(fnm, inplace=True):
|
||||
|
||||
Reference in New Issue
Block a user