carbonblack / cbapi-python

Carbon Black API - Python language bindings
Other
147 stars 86 forks source link

Time format exception #20

Closed askthedragon closed 8 years ago

askthedragon commented 8 years ago

Here's one that's popping up with the new CB API: we're getting dates back in RESTful queries that do not fit the expected date format (cb_datetime_format = "%Y-%m-%d %H:%M:%S.%f") resulting in exceptions like "time data '2016-07-10 10:05:01' does not match format '%Y-%m-%d %H:%M:%S.%f'". I think this is for events originating on OS X (and maybe Linux).

askthedragon commented 8 years ago

File "D:\Projects\rad\misc\cbfetch\venv\lib\site-packages\cbapi\response\models.py", line 1195, in all_events list(self.children) + list(self.regmods) + list(self.crossprocs)) File "D:\Projects\rad\misc\cbfetch\venv\lib\site-packages\cbapi\response\models.py", line 1188, in children yield self._event_parser.parse_childproc(i, raw_childproc) File "D:\Projects\rad\misc\cbfetch\venv\lib\site-packages\cbapi\response\models.py", line 966, in parse_childproc timestamp = datetime.strptime(parts[0], cb_datetime_format) File "C:\Tools\WinPython\python-2.7.10.amd64\Lib_strptime.py", line 325, in _strptime (data_string, format)) ValueError: time data '2016-07-11T19:52:31.918000Z' does not match format '%Y-%m-%d %H:%M:%S.%f'