Skip to content

Make date parsing more flexible #96

@datadavev

Description

@datadavev

tstamp = datetime.datetime.strptime(tstamp, "%Y-%m-%dT%H:%M:%S.%fZ")

Seeing exception in /var/log/dataone/identifier_es/application.log:

Traceback (most recent call last):
  File "/home/vieglais/.local/bin/d1sysmetaes", line 11, in <module>
    load_entry_point('d1-metrics', 'console_scripts', 'd1sysmetaes')()
  File "/home/vieglais/git/metrics-service/src/d1_metrics/d1_metrics/es_sysmeta_sync.py", line 666, in main
    start_date = findMostRecentRecord(record_file_path)
  File "/home/vieglais/git/metrics-service/src/d1_metrics/d1_metrics/es_sysmeta_sync.py", line 544, in findMostRecentRecord
    tstamp = datetime.datetime.strptime(tstamp, "%Y-%m-%dT%H:%M:%S.%fZ")
  File "/usr/lib/python3.6/_strptime.py", line 565, in _strptime_datetime
    tt, fraction = _strptime(data_string, format)
  File "/usr/lib/python3.6/_strptime.py", line 362, in _strptime
    (data_string, format))

A simple fix is to catch the error and try a fallback time pattern.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions