Added exception handling

This commit is contained in:
banana 2021-03-11 16:45:24 +00:00
parent 7a7bf4a6b4
commit f2e2d8e2b6
2 changed files with 7 additions and 12 deletions

View File

@ -4,18 +4,14 @@
source("ReadOpus.R") source("ReadOpus.R")
# Determine file path # 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] file_path <- commandArgs(trailingOnly = TRUE)[1]
print(file_path)
# Convert opus binary file into dataframe # Convert opus binary file into dataframe
data <- read_opus_univ(file_path, 5) tryCatch(data <- read_opus_univ(file_path, 5), error=function(e){
print("Failed converting OPUS file")
# Replace last "." with "_", add ".DPT" exit()
#file_name <- paste0(sub(".([^.]*)$", "_\\1", file_name), ".DPT") }
)
# Determine target, where the result should appear # Determine target, where the result should appear
target_path <- paste0("/tmp/", sub('.*\\/', "", file_path)) 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 = ",") write.table(data, target_path, row.names = FALSE, col.names = FALSE, sep = ",")
# Call python script # Call python script
system(paste('python3 transferData.py', target_path)) system(paste('./transfer-data.sh', target_path))
#py_run_file("transfer.py",local=FALSE, convert=FALSE)

View File

@ -29,7 +29,7 @@ echo "Extracting data..."
shopt -s nullglob shopt -s nullglob
found=0 found=0
for f in $MOUNTPOINT/*.[0-9] for f in $MOUNTPOINT/*.?
do do
found=1 found=1
echo "Processing $f..." echo "Processing $f..."