Skip to content
Snippets Groups Projects
Commit cd44df15 authored by Lan Dam's avatar Lan Dam
Browse files

report and skip if can't read a file

parent a41506c6
No related branches found
No related tags found
1 merge request!130report and skip if can't read a file in RT130
Pipeline #2576 passed with stage
in 2 minutes and 28 seconds
...@@ -4,7 +4,7 @@ RT130 object to hold and process RefTek data ...@@ -4,7 +4,7 @@ RT130 object to hold and process RefTek data
import os import os
from pathlib import Path from pathlib import Path
from typing import Tuple, List, Union from typing import Tuple, List, Union
import traceback
import numpy as np import numpy as np
from sohstationviewer.model.reftek.from_rt2ms import ( from sohstationviewer.model.reftek.from_rt2ms import (
...@@ -89,8 +89,15 @@ class RT130(DataTypeModel): ...@@ -89,8 +89,15 @@ class RT130(DataTypeModel):
path2file = Path(path).joinpath(file_name) path2file = Path(path).joinpath(file_name)
if not validate_file(path2file, file_name): if not validate_file(path2file, file_name):
continue continue
if not self.read_reftek_130(path2file): try:
read_text(path2file, file_name, self.log_data['TEXT']) if not self.read_reftek_130(path2file):
read_text(path2file, self.log_data['TEXT'])
except Exception:
fmt = traceback.format_exc()
self.track_info(f"Skip file {path2file} can't be read "
f"due to error: {str(fmt)}",
LogType.WARNING)
count += 1 count += 1
if count % 50 == 0: if count % 50 == 0:
self.track_info( self.track_info(
...@@ -133,7 +140,13 @@ class RT130(DataTypeModel): ...@@ -133,7 +140,13 @@ class RT130(DataTypeModel):
:param path2file: absolute path to file :param path2file: absolute path to file
""" """
rt130 = core.Reftek130.from_file(path2file) try:
rt130 = core.Reftek130.from_file(path2file)
except Exception:
fmt = traceback.format_exc()
self.track_info(f"Skip file {path2file} can't be read "
f"due to error: {str(fmt)}", LogType.WARNING)
return
unique, counts = np.unique(rt130._data["packet_type"], unique, counts = np.unique(rt130._data["packet_type"],
return_counts=True) return_counts=True)
nbr_packet_type = dict(zip(unique, counts)) nbr_packet_type = dict(zip(unique, counts))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment