funilrys / PyFunceble

The tool to check the availability or syntax of domain, IP or URL.
https://pyfunceble.github.io
Apache License 2.0
289 stars 44 forks source link

BUG: Object of type datetime is not JSON serializable #360

Closed spirillen closed 3 months ago

spirillen commented 3 months ago

Description

changed from stable to dev for testing latest commits

Configuration

Not relevant

Reproduction

  1. pyfunceble -f /tmp/zone.json

Expected behavior

Hmm wondering :beach_umbrella: :cocktail:

Screenshots

Versions

OS: Ubuntu 22.04

Python Version: 3.11

PyFunceble Version: 4.2.10.dev

Additional context

It seems you have changed a type in the DB which the program can't alter by it self

spirillen commented 3 months ago
Traceback (most recent call last):
File "/usr/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap
self.run()
File "/home/$USER/.local/lib/python3.11/site-packages/PyFunceble/cli/processes/workers/base.py", line 404, in run
raise exception
File "/home/$USER/.local/lib/python3.11/site-packages/PyFunceble/cli/processes/workers/base.py", line 376, in run
result = self.target(consumed)
^^^^^^^^^^^^^^^^^^^^^
File "/home/$USER/.local/lib/python3.11/site-packages/PyFunceble/cli/processes/workers/producer.py", line 411, in target
self.collection_query_tool.push(test_result)
File "/home/$USER/.local/lib/python3.11/site-packages/PyFunceble/query/collection.py", line 460, in wrapper
return func(self, *args, **kwargs)  # pylint: disable=not-callable
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/$USER/.local/lib/python3.11/site-packages/PyFunceble/query/collection.py", line 685, in push
self.__push_whois(checker_status)
File "/home/$USER/.local/lib/python3.11/site-packages/PyFunceble/query/collection.py", line 828, in __push_whois
response = self.session.post(
^^^^^^^^^^^^^^^^^^
File "/home/$USER/.local/lib/python3.11/site-packages/requests/sessions.py", line 637, in post
return self.request("POST", url, data=data, json=json, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/$USER/.local/lib/python3.11/site-packages/requests/sessions.py", line 575, in request
prep = self.prepare_request(req)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/$USER/.local/lib/python3.11/site-packages/requests/sessions.py", line 486, in prepare_request
p.prepare(
File "/home/$USER/.local/lib/python3.11/site-packages/requests/models.py", line 371, in prepare
self.prepare_body(data, files, json)
File "/home/$USER/.local/lib/python3.11/site-packages/requests/models.py", line 511, in prepare_body
body = complexjson.dumps(json, allow_nan=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/json/__init__.py", line 238, in dumps
**kw).encode(obj)
^^^^^^^^^^^
File "/usr/lib/python3.11/json/encoder.py", line 200, in encode
chunks = self.iterencode(o, _one_shot=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/json/encoder.py", line 258, in iterencode
return _iterencode(o, 0)
^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/json/encoder.py", line 180, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type datetime is not JSON serializable
^C
Thank you for using PyFunceble!
spirillen commented 3 months ago

This issue also appears when you are using CSV for datasets

pyfunceble --output-location ./ -f ad_servers.txt emd.txt exp.txt fsa.txt grm.txt hjk.txt mmt.txt pha.txt psh.txt pup.txt --database-type csv
Process pyfunceble_producer_worker_1:
Traceback (most recent call last):
File "/usr/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap
self.run()
File "/home/$USER/.local/lib/python3.11/site-packages/PyFunceble/cli/processes/workers/base.py", line 404, in run
raise exception
File "/home/$USER/.local/lib/python3.11/site-packages/PyFunceble/cli/processes/workers/base.py", line 376, in run
result = self.target(consumed)
^^^^^^^^^^^^^^^^^^^^^
File "/home/$USER/.local/lib/python3.11/site-packages/PyFunceble/cli/processes/workers/producer.py", line 411, in target
self.collection_query_tool.push(test_result)
File "/home/$USER/.local/lib/python3.11/site-packages/PyFunceble/query/collection.py", line 460, in wrapper
return func(self, *args, **kwargs)  # pylint: disable=not-callable
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/$USER/.local/lib/python3.11/site-packages/PyFunceble/query/collection.py", line 685, in push
self.__push_whois(checker_status)
File "/home/$USER/.local/lib/python3.11/site-packages/PyFunceble/query/collection.py", line 828, in __push_whois
response = self.session.post(
^^^^^^^^^^^^^^^^^^
File "/home/$USER/.local/lib/python3.11/site-packages/requests/sessions.py", line 637, in post
return self.request("POST", url, data=data, json=json, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/$USER/.local/lib/python3.11/site-packages/requests/sessions.py", line 575, in request
prep = self.prepare_request(req)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/$USER/.local/lib/python3.11/site-packages/requests/sessions.py", line 486, in prepare_request
p.prepare(
File "/home/$USER/.local/lib/python3.11/site-packages/requests/models.py", line 371, in prepare
self.prepare_body(data, files, json)
File "/home/$USER/.local/lib/python3.11/site-packages/requests/models.py", line 511, in prepare_body
body = complexjson.dumps(json, allow_nan=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/json/__init__.py", line 238, in dumps
**kw).encode(obj)
^^^^^^^^^^^
File "/usr/lib/python3.11/json/encoder.py", line 200, in encode
chunks = self.iterencode(o, _one_shot=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/json/encoder.py", line 258, in iterencode
return _iterencode(o, 0)
^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/json/encoder.py", line 180, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type datetime is not JSON serializable
^C
Thank you for using PyFunceble!