mirror of
https://github.com/sususweet/midea-meiju-codec.git
synced 2026-02-27 14:16:35 +00:00
Merge pull request #109 from rengaryang/rengar_dev
fix: write lua files with utf-8 encoding,the env as below:haos 17.0…
This commit is contained in:
@@ -172,7 +172,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType):
|
|||||||
from .const import BIT_LUA
|
from .const import BIT_LUA
|
||||||
bit_lua = base64.b64decode(BIT_LUA.encode("utf-8")).decode("utf-8")
|
bit_lua = base64.b64decode(BIT_LUA.encode("utf-8")).decode("utf-8")
|
||||||
try:
|
try:
|
||||||
with open(bit, "wt") as fp:
|
with open(bit, "wt", encoding="utf-8") as fp:
|
||||||
fp.write(bit_lua)
|
fp.write(bit_lua)
|
||||||
except PermissionError as e:
|
except PermissionError as e:
|
||||||
MideaLogger.error(f"Failed to create bit.lua at {bit}: {e}")
|
MideaLogger.error(f"Failed to create bit.lua at {bit}: {e}")
|
||||||
@@ -180,7 +180,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType):
|
|||||||
import tempfile
|
import tempfile
|
||||||
temp_dir = tempfile.gettempdir()
|
temp_dir = tempfile.gettempdir()
|
||||||
bit = os.path.join(temp_dir, "bit.lua")
|
bit = os.path.join(temp_dir, "bit.lua")
|
||||||
with open(bit, "wt") as fp:
|
with open(bit, "wt", encoding="utf-8") as fp:
|
||||||
fp.write(bit_lua)
|
fp.write(bit_lua)
|
||||||
MideaLogger.warning(f"Using temporary file for bit.lua: {bit}")
|
MideaLogger.warning(f"Using temporary file for bit.lua: {bit}")
|
||||||
|
|
||||||
|
|||||||
@@ -492,7 +492,7 @@ class MeijuCloud(MideaCloud):
|
|||||||
self._security.aes_decrypt_with_fixed_key(lua))
|
self._security.aes_decrypt_with_fixed_key(lua))
|
||||||
stream = stream.replace("\r\n", "\n")
|
stream = stream.replace("\r\n", "\n")
|
||||||
fnm = f"{path}/{response['fileName']}"
|
fnm = f"{path}/{response['fileName']}"
|
||||||
async with aiofiles.open(fnm, "w") as fp:
|
async with aiofiles.open(fnm, "w", encoding="utf-8") as fp:
|
||||||
await fp.write(stream)
|
await fp.write(stream)
|
||||||
return fnm
|
return fnm
|
||||||
|
|
||||||
@@ -744,7 +744,7 @@ class MSmartHomeCloud(MideaCloud):
|
|||||||
self._security.aes_decrypt_with_fixed_key(lua))
|
self._security.aes_decrypt_with_fixed_key(lua))
|
||||||
stream = stream.replace("\r\n", "\n")
|
stream = stream.replace("\r\n", "\n")
|
||||||
fnm = f"{path}/{response['fileName']}"
|
fnm = f"{path}/{response['fileName']}"
|
||||||
async with aiofiles.open(fnm, "w") as fp:
|
async with aiofiles.open(fnm, "w", encoding="utf-8") as fp:
|
||||||
await fp.write(stream)
|
await fp.write(stream)
|
||||||
return fnm
|
return fnm
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user