From f2e2d8e2b6d45be16124253d87ecbfe388ad20ba Mon Sep 17 00:00:00 2001 From: banana Date: Thu, 11 Mar 2021 16:45:24 +0000 Subject: [PATCH] Added exception handling --- OpusData.R | 17 ++++++----------- usb-detect/usb-detect.sh | 2 +- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/OpusData.R b/OpusData.R index a76635a..6d31f96 100644 --- a/OpusData.R +++ b/OpusData.R @@ -4,18 +4,14 @@ source("ReadOpus.R") # Determine file path -#path <- commandArgs(trailingOnly = TRUE)[1] -#file_name <- commandArgs(trailingOnly = TRUE)[2] -#file_path <- paste0(path, file_name) file_path <- commandArgs(trailingOnly = TRUE)[1] -print(file_path) - # Convert opus binary file into dataframe -data <- read_opus_univ(file_path, 5) - -# Replace last "." with "_", add ".DPT" -#file_name <- paste0(sub(".([^.]*)$", "_\\1", file_name), ".DPT") +tryCatch(data <- read_opus_univ(file_path, 5), error=function(e){ + print("Failed converting OPUS file") + exit() + } +) # Determine target, where the result should appear target_path <- paste0("/tmp/", sub('.*\\/', "", file_path)) @@ -27,7 +23,6 @@ file.create(target_path) write.table(data, target_path, row.names = FALSE, col.names = FALSE, sep = ",") # Call python script -system(paste('python3 transferData.py', target_path)) -#py_run_file("transfer.py",local=FALSE, convert=FALSE) +system(paste('./transfer-data.sh', target_path)) diff --git a/usb-detect/usb-detect.sh b/usb-detect/usb-detect.sh index a753ceb..366f513 100755 --- a/usb-detect/usb-detect.sh +++ b/usb-detect/usb-detect.sh @@ -29,7 +29,7 @@ echo "Extracting data..." shopt -s nullglob found=0 -for f in $MOUNTPOINT/*.[0-9] +for f in $MOUNTPOINT/*.? do found=1 echo "Processing $f..."