Use json instead of ujson module

https://ask.replit.com/t/c-stdlib-in-a-python-repl-for-c-extensions-missing-importerror-libstdc-so-6-cannot-open-shared-object-file/1330

Signed-off-by: Ari Archer <ari.web.xyz@gmail.com>
This commit is contained in:
Ari Archer 2022-08-23 04:02:33 +03:00
parent 7cf06b4406
commit 74b0253d8b
Signed by untrusted user who does not match committer: ari
GPG key ID: A50D5B4B599AF8A2
2 changed files with 6 additions and 8 deletions

View file

@ -4,4 +4,3 @@ sqlalchemy-utils
flask flask
psutil psutil
distro distro
ujson

View file

@ -4,8 +4,7 @@
import asyncio import asyncio
import datetime as dt import datetime as dt
# import ujson # type: ignore import json
import json as ujson # For now
import logging import logging
import os import os
import platform import platform
@ -66,7 +65,7 @@ def dump_config() -> None:
log("Dumping config") log("Dumping config")
with open(CONFIG_PATH, "w") as cfg: with open(CONFIG_PATH, "w") as cfg:
ujson.dump(CONFIG, cfg, indent=4) json.dump(CONFIG, cfg, indent=4)
def log(message: str) -> None: def log(message: str) -> None:
@ -108,11 +107,11 @@ def str_to_command(command: str) -> List[List[str]]:
if len(CACHE["s2c"]) > CONFIG["cache-sz"]: if len(CACHE["s2c"]) > CONFIG["cache-sz"]:
CACHE["s2c"].clear() CACHE["s2c"].clear()
elif command in CACHE["s2c"]: elif command in CACHE["s2c"]:
return ujson.loads(CACHE["s2c"][command]) return json.loads(CACHE["s2c"][command])
result: List[List[str]] = [line.split(" ") for line in command.strip().split("\n")] result: List[List[str]] = [line.split(" ") for line in command.strip().split("\n")]
CACHE["s2c"][command] = ujson.dumps(result) CACHE["s2c"][command] = json.dumps(result)
return result return result
@ -353,7 +352,7 @@ Executed query `{uncode(sql_query)}`
Usage: config""" Usage: config"""
await self._send_message( await self._send_message(
m(f"\n```json\n{uncode(ujson.dumps(CONFIG, indent=4))}\n```", message) m(f"\n```json\n{uncode(json.dumps(CONFIG, indent=4))}\n```", message)
) )
async def cmd_sh( async def cmd_sh(
@ -637,7 +636,7 @@ def main() -> int:
print(" || Loading config... ", end="") print(" || Loading config... ", end="")
with open(CONFIG_PATH, "r") as cfg: with open(CONFIG_PATH, "r") as cfg:
CONFIG.update(ujson.load(cfg)) CONFIG.update(json.load(cfg))
print("done") print("done")
# Ping server # Ping server