MrPowerScripts / reddit-karma-farming-bot

"Is karma really that important to you? Damn bro, you need a life" - YouTube Comment
https://mrpowerscripts.com
MIT License
295 stars 119 forks source link

JSON encoding problems. #75

Closed JGCoelho closed 3 years ago

JGCoelho commented 4 years ago

The bot is crashing when calling the method set_user_info() from db.py

Traceback (most recent call last):
  File "./src/run.py", line 9, in <module>
    init.init()
  File "/home/karma-farm-reddit/src/init.py", line 63, in init
    set_user_info()
  File "/home/karma-farm-reddit/src/db.py", line 41, in set_user_info
    db_config.upsert({"config": "user", "value": j}, Config.config == "user")
  File "/home/karma-farm-reddit/venv/lib/python3.7/site-packages/tinydb/table.py", line 393, in upsert
    updated_docs = self.update(document, cond)
  File "/home/karma-farm-reddit/venv/lib/python3.7/site-packages/tinydb/table.py", line 358, in update
    self._update_table(updater)
  File "/home/karma-farm-reddit/venv/lib/python3.7/site-packages/tinydb/table.py", line 605, in _update_table
    tables = self._storage.read()
  File "/home/karma-farm-reddit/venv/lib/python3.7/site-packages/tinydb/storages.py", line 120, in read
    return json.load(self._handle)
  File "/usr/lib/python3.7/json/__init__.py", line 296, in load
    parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
  File "/usr/lib/python3.7/json/__init__.py", line 348, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.7/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.7/json/decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 22397 (char 22396)

I think the error comes from me not being able to decode it can't decode the variable j, that is a dictionary. It's expecting part of it to be enclosed in double quotes. The dictionary j is all in single quotes, it looks like this.

[...]'pref_clickgadget': 5, 'created': 1546632362.0, 'gold_creddits': 0, 'created_utc': 1546603562.0, 'has_ios_subscription': False, 'pref_show_twitter': False, 'in_beta': False, 'comment_karma': 5281[...]

What is causing that and how do I solve it? It is running on a Debian GNU/Linux 10 Release 10 server. I ran the bot using the run_linux.sh file.

MrPowerScripts commented 3 years ago

removing as this won't be an issue in upcoming 4.0 release