Skip to content

Commit

Permalink
More fixes for UTF-8 characters in manifests files
Browse files Browse the repository at this point in the history
  • Loading branch information
pyhalov committed Mar 11, 2020
1 parent 900da3c commit a2b4a1f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
12 changes: 6 additions & 6 deletions src/modules/client/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -3702,9 +3702,9 @@ def _create_fast_lookups(self, progtrack=None):
of, op = self.temporary_file(close=False)
bf, bp = self.temporary_file(close=False)

sf = os.fdopen(sf, "w")
of = os.fdopen(of, "w")
bf = os.fdopen(bf, "w")
sf = os.fdopen(sf, "w", encoding="UTF-8")
of = os.fdopen(of, "w", encoding="UTF-8")
bf = os.fdopen(bf, "w", encoding="UTF-8")

# We need to make sure the files are coordinated.
timestamp = int(time.time())
Expand Down Expand Up @@ -3837,7 +3837,7 @@ def _load_actdict(self, progtrack):

try:
of = open(os.path.join(self.__action_cache_dir,
"actions.offsets"), "r")
"actions.offsets"), "r", encoding="UTF-8")
except IOError as e:
if e.errno != errno.ENOENT:
raise
Expand Down Expand Up @@ -3902,7 +3902,7 @@ def _get_stripped_actions_file(self, internal=False):
return the corresponding file object."""

sf = open(os.path.join(self.__action_cache_dir,
"actions.stripped"), "r")
"actions.stripped"), "r", encoding="UTF-8")
sversion = sf.readline().rstrip()
stimestamp = sf.readline().rstrip()
if internal:
Expand All @@ -3917,7 +3917,7 @@ def _load_conflicting_keys(self):

pth = os.path.join(self.__action_cache_dir, "keys.conflicting")
try:
with open(pth, "r") as fh:
with open(pth, "r", encoding="UTF-8") as fh:
version = fh.readline().rstrip()
if version != "VERSION 1":
return None
Expand Down
4 changes: 2 additions & 2 deletions src/modules/client/transport/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -1686,7 +1686,7 @@ def _prefetch_manifests_list(self, mxfr, mlist, excludes=misc.EmptyI):
continue

try:
mf = open(dl_path)
mf = open(dl_path, "r", encoding="UTF-8")
mcontent = mf.read()
mf.close()
manifest.FactoredManifest(fmri,
Expand Down Expand Up @@ -1776,7 +1776,7 @@ def _verify_manifest(self, fmri, mfstpath=None, content=None, pub=None):
return False

if mfstpath:
mf = open(mfstpath)
mf = open(mfstpath, "r", encoding="UTF-8")
mcontent = mf.read()
mf.close()
elif content is not None:
Expand Down
14 changes: 7 additions & 7 deletions src/modules/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1229,7 +1229,7 @@ def search_dict(file_path, excludes, return_line=False,
log = lambda x: None

try:
file_handle = open(file_path, "r")
file_handle = open(file_path, "r", encoding="UTF-8")
except EnvironmentError as e:
if e.errno != errno.ENOENT:
raise
Expand Down Expand Up @@ -1364,7 +1364,7 @@ def store(self, mfst_path):
e.filename)
raise

mfile = os.fdopen(fd, "w")
mfile = os.fdopen(fd, "w", encoding="UTF-8")

#
# We specifically avoid sorting manifests before writing
Expand Down Expand Up @@ -1668,7 +1668,7 @@ def __storebytype(self):
except EnvironmentError as e:
raise apx._convert_error(e)

f = os.fdopen(fd, "w")
f = os.fdopen(fd, "w", encoding="UTF-8")
try:
for a in acts:
f.write("{0}\n".format(a))
Expand All @@ -1695,7 +1695,7 @@ def create_cache(name, refs):
try:
fd, fn = tempfile.mkstemp(dir=t_dir,
prefix=name + ".")
with os.fdopen(fd, "w") as f:
with os.fdopen(fd, "w", encoding="UTF-8") as f:
f.writelines(refs())
os.chmod(fn, PKG_FILE_MODE)
portable.rename(fn, self.__cache_path(name))
Expand Down Expand Up @@ -1745,7 +1745,7 @@ def __load_cached_data(self, name):
if os.path.exists(mpath):
# we have cached copy on disk; use it
try:
with open(mpath, "r") as f:
with open(mpath, "r", encoding="UTF-8") as f:
self._cache[name] = [
a for a in
(
Expand Down Expand Up @@ -1830,7 +1830,7 @@ def gen_actions_by_type(self, atype, attr_match=None, excludes=EmptyI):
attr_match = _compile_fnpats(attr_match)

try:
with open(mpath, "r") as f:
with open(mpath, "r", encoding="UTF-8") as f:
for l in f:
a = actions.fromstr(l.rstrip())
if (excludes and
Expand Down Expand Up @@ -1889,7 +1889,7 @@ def __load_attributes(self):
mpath = self.__cache_path("manifest.set")
if not os.path.exists(mpath):
return False
with open(mpath, "r") as f:
with open(mpath, "r", encoding="UTF-8") as f:
for l in f:
a = actions.fromstr(l.rstrip())
if not self.excludes or \
Expand Down

0 comments on commit a2b4a1f

Please sign in to comment.