Skip to content
Snippets Groups Projects

Improve checking the size of data before processing

Merged Lan Dam requested to merge improve_check_dir_size into master
@@ -18,7 +18,7 @@ def _get_file_type(path2file: str) -> str:
+ TEXT if strip() can be used for the first 64 bytes
+ MSEED if channel name of the first record can be read
+ RT130 is decided using obspy method _is_reftek130()
+ binary if none of the above types are detected.
+ BINARY if none of the above types are detected.
:param path2file: absolute path to file
:return: file's type
"""
@@ -291,6 +291,12 @@ def _get_dir_size(dir_path: str, req_wf_chans: List[Union[str, int]]):
def _abort_dialog(msg: str) -> bool:
"""
Provide confirming dialog for user to continue or not
:param msg: message of what need to be confirmed
:return: True for the confirmation. False for the cancel.
"""
dlg = QMessageBox()
dlg.setText(msg)
dlg.setInformativeText('Do you want to proceed?')
@@ -308,6 +314,13 @@ def _abort_dialog(msg: str) -> bool:
def _check_folders_size(dir_paths: List[str],
req_wf_chans: List[Union[str, int]]
) -> Dict[str, int]:
"""
Check the folders in the list dir_paths for size of data files and count of
text file or binary.
:param dir_paths: list of paths to check for sizes
:param req_wf_chans: requirement of waveform channels
:return: dictionary of size or count info in the dir_paths
"""
final_result = {'data_size': 0, 'text_count': 0, 'binary_count': 0}
for dir_path in dir_paths:
if not os.path.isdir(dir_path):
@@ -338,9 +351,11 @@ def check_folders_size(dir_paths: List[str],
Check the folders in the list dir_paths:
+ If found data in folders, return True if size <= BIG_FILE_SIZE.
Otherwise, ask user to continue or not.
+ If there're no data files at all, report the files found and ask user to
+ If there are no data files at all, report the files found and ask user to
continue or not
:param dir_paths: list of paths to check for sizes
:param req_wf_chans: requirement of waveform channels
:return: True if the check is passed and False otherwise
"""
try:
final_result = _check_folders_size(dir_paths, req_wf_chans)
Loading