log2zulip: Replace ujson with json.
This commit is contained in:
parent
7d1a56fb2b
commit
d05e932968
|
@ -18,7 +18,6 @@ except ImportError:
|
|||
pass
|
||||
|
||||
import json
|
||||
import ujson
|
||||
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "../../"))
|
||||
import zulip
|
||||
|
@ -71,7 +70,7 @@ def process_logs():
|
|||
mkdir_p(os.path.dirname(data_file_path))
|
||||
if not os.path.exists(data_file_path):
|
||||
open(data_file_path, "w").write("{}")
|
||||
last_data = ujson.loads(open(data_file_path).read())
|
||||
last_data = json.loads(open(data_file_path).read())
|
||||
new_data = {}
|
||||
for log_file in log_files:
|
||||
file_data = last_data.get(log_file, {})
|
||||
|
@ -94,7 +93,7 @@ def process_logs():
|
|||
process_lines(new_lines, filename)
|
||||
file_data["last"] += len(new_lines)
|
||||
new_data[log_file] = file_data
|
||||
open(data_file_path, "w").write(ujson.dumps(new_data))
|
||||
open(data_file_path, "w").write(json.dumps(new_data))
|
||||
|
||||
if __name__ == "__main__":
|
||||
if os.path.exists(lock_path):
|
||||
|
@ -105,8 +104,8 @@ if __name__ == "__main__":
|
|||
open(lock_path, "w").write("1")
|
||||
zulip_client = zulip.Client(config_file="/etc/log2zulip.zuliprc")
|
||||
try:
|
||||
log_files = ujson.loads(open(control_path, "r").read())
|
||||
except Exception:
|
||||
log_files = json.loads(open(control_path, "r").read())
|
||||
except (json.JSONDecodeError, IOError):
|
||||
print("Could not load control data from %s" % (control_path,))
|
||||
traceback.print_exc()
|
||||
sys.exit(1)
|
||||
|
|
Loading…
Reference in a new issue