Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid format timestamp #62

Open
balagpy opened this issue Oct 28, 2020 · 9 comments
Open

Invalid format timestamp #62

balagpy opened this issue Oct 28, 2020 · 9 comments

Comments

@balagpy
Copy link

balagpy commented Oct 28, 2020

Hi Team,

I am facing the following error, pls help me..

(venv) ubuntu@ip:~/cs-suite$ python3 cs.py -env aws
Traceback (most recent call last):
File "cs.py", line 6, in
from modules import logger
File "/home/ubuntu/cs-suite/modules/logger.py", line 17, in
formatter = CustomJsonFormatter('(timestamp) (level) (name) (message)')
File "/home/ubuntu/cs-suite/venv/lib/python3.8/site-packages/pythonjsonlogger/jsonlogger.py", line 115, in init
logging.Formatter.init(self, *args, **kwargs)
File "/usr/lib/python3.8/logging/init.py", line 576, in init
self._style.validate()
File "/usr/lib/python3.8/logging/init.py", line 429, in validate
raise ValueError("Invalid format '%s' for '%s' style" % (self._fmt, self.default_format[0]))
ValueError: Invalid format '(timestamp) (level) (name) (message)' for '%' style

@shivankar-madaan
Copy link
Contributor

Hi @balagpy
The current tool is un-tested on python3
Could you possibly give a try with python 2.7?

@balagpy
Copy link
Author

balagpy commented Oct 28, 2020

Thanks for the reply @shivankar-madaan - Let me try on python 2.7

@balagpy
Copy link
Author

balagpy commented Oct 28, 2020

Hi @shivankar-madaan tried in python 2.7, but it throwing the following error

cs-suite$ sudo python cs.py
Traceback (most recent call last):
File "cs.py", line 6, in
from modules import logger
File "/Users/balajipr/cs-suite/modules/logger.py", line 2, in
from pythonjsonlogger import jsonlogger
ImportError: No module named pythonjsonlogger

@shivankar-madaan
Copy link
Contributor

Hi @balagpy
were you able to run setup.py or install all the requirements from requirement.txt
or could you try installing python-json-logger module of python

Do let me know if it works

@balagpy
Copy link
Author

balagpy commented Oct 29, 2020

Installed python-JSON-logger module
after getting this error @shivankar-madaan

Traceback (most recent call last):
File "cs.py", line 117, in
main()
File "cs.py", line 67, in main
from modules import awsaudit
File "/Users/balajipr/cs-suite/modules/awsaudit.py", line 30, in
account_name = get_account_alias() or get_account_id()
File "/Users/balajipr/cs-suite/modules/awsaudit.py", line 15, in get_account_alias
account_details = json.loads(str(account_details))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/init.py", line 338, in loads
return _default_decoder.decode(s)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 366, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 384, in raw_decode
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

@shivankar-madaan
Copy link
Contributor

@balagpy have you set the AWS keys on the cli?

@balagpy
Copy link
Author

balagpy commented Oct 30, 2020

@shivankar-madaan Yes, configured aws keys on the cli.

@shivankar-madaan
Copy link
Contributor

@balagpy what output are you getting for "aws iam list-account-aliases"
You don't need to share the output, but is it in json or empty?

@harishbsrinivas
Copy link

harishbsrinivas commented Jan 6, 2021

I worked around this error by adding the validate=False parameter to the CustomJsonFormatter in modules/logger.py

formatter = CustomJsonFormatter('(timestamp) (level) (name) (message)',validate=False)

I have tested this on Python 3.8 after pulling from https://github.com/almoore/cs-suite

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants