Skip to content
Snippets Groups Projects
Commit c4330723 authored by Christoph Alt's avatar Christoph Alt
Browse files

removed a useless try catch and made another except more verbose

parent 18cdf7e2
No related merge requests found
Pipeline #42691 passed with stage
in 31 seconds
...@@ -41,10 +41,6 @@ def data_point_factory(run, *, ...@@ -41,10 +41,6 @@ def data_point_factory(run, *,
tag_keys = run.keys() - no_tag_keys - field_keys - {time_key} tag_keys = run.keys() - no_tag_keys - field_keys - {time_key}
tags = {key: run[key]for key in tag_keys} tags = {key: run[key]for key in tag_keys}
time = run[time_key] time = time_conversion(run[time_key])
try:
time = time_conversion(time)
except ValueError:
logger.warn(f"{time} could not be transformed with the current pattern")
pass
return DataPoint(measurement_name, time, fields=fields, tags=tags) return DataPoint(measurement_name, time, fields=fields, tags=tags)
...@@ -5,6 +5,10 @@ from datetime import datetime ...@@ -5,6 +5,10 @@ from datetime import datetime
from typing import Union, Tuple from typing import Union, Tuple
from pathlib import Path from pathlib import Path
import logging
logger = logging.getLogger(__file__)
def remove_newline(string: str) -> str: def remove_newline(string: str) -> str:
return string.replace("\n", " ").strip() return string.replace("\n", " ").strip()
...@@ -55,7 +59,7 @@ def file_time_to_sec(file_path) -> int: ...@@ -55,7 +59,7 @@ def file_time_to_sec(file_path) -> int:
def time_conversion(time_stamp, *, pattern="%Y-%m-%d %H:%M:%S"): def time_conversion(time_stamp, *, pattern="%Y-%m-%d %H:%M:%S"):
try: try:
return int(time_stamp) return int(time_stamp)
except ValueError: except ValueError as e:
pass logger.exception(e)
return int(datetime.strptime(time_stamp, pattern).timestamp()) return int(datetime.strptime(time_stamp, pattern).timestamp())
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment