except the python UnicodeDecodeError in Emulator

This commit is contained in:
cuu 2019-05-13 19:43:43 +08:00
parent ce72585632
commit ed8699d6d4
2 changed files with 19 additions and 4 deletions

View File

@ -129,8 +129,11 @@ class FavListPage(Page):
stats = os.stat(v)
if stats.st_gid != self._Parent._FavGID: ## only favs
continue
try:
dirmap["gamedir"] = v.decode("utf8","ignore")
except:
dirmap["gamedir"] = v.decode("ascii","ignore")
dirmap["gamedir"] = v.decode("utf8")
ret.append(dirmap)
if os.path.isfile(v) and self._Emulator["FILETYPE"] == "file":
stats = os.stat(v)
@ -141,7 +144,11 @@ class FavListPage(Page):
pieces = bname.split(".")
if len(pieces) > 1:
if pieces[ len(pieces)-1 ].lower() in self._Emulator["EXT"]:
dirmap["file"] = v.decode("utf8")
try:
dirmap["file"] = v.decode("utf8","ignore")
except:
dirmap["file"] = v.decode("ascii","ignore")
ret.append(dirmap)
# else:

View File

@ -143,7 +143,11 @@ class RomListPage(Page):
continue
if FileExists(v+"/"+gameshell_bat):
dirmap["gamedir"] = v.decode("utf8")
try:
dirmap["gamedir"] = v.decode("utf8","ignore")
except:
dirmap["gamedir"] = v.decode("ascii","ignore")
ret.append(dirmap)
if os.path.isfile(v) and self._Emulator["FILETYPE"] == "file":
stats = os.stat(v)
@ -162,7 +166,11 @@ class RomListPage(Page):
pieces = bname.split(".")
if len(pieces) > 1:
if pieces[ len(pieces)-1 ].lower() in self._Emulator["EXT"]:
dirmap["file"] = v.decode("utf8")
try:
dirmap["file"] = v.decode("utf8","ignore")
except:
dirmap["file"] = v.decode("ascii","ignore")
ret.append(dirmap)
# else:
# print("not file or dir")