From 450aefe9d2a5ec849e57447e045d01278c52389a Mon Sep 17 00:00:00 2001 From: hollorol Date: Mon, 17 Jul 2017 18:24:28 +0200 Subject: [PATCH] Now deep clean is realy deep :) --- RBBGCMuso/R/cleanup.R | 42 ++++++++++++++++++++++++---------------- RBBGCMuso/R/rungetMuso.R | 28 +++++++++++++-------------- 2 files changed, 39 insertions(+), 31 deletions(-) diff --git a/RBBGCMuso/R/cleanup.R b/RBBGCMuso/R/cleanup.R index bb0c223..8cc3d77 100644 --- a/RBBGCMuso/R/cleanup.R +++ b/RBBGCMuso/R/cleanup.R @@ -1,5 +1,5 @@ cleanupMuso <- function(location=NULL, simplicity=TRUE,deep=FALSE){ - + areThereAnyFolders <- FALSE whereAmI <- getwd() if(!is.null(location)){ setwd(location) @@ -10,40 +10,48 @@ cleanupMuso <- function(location=NULL, simplicity=TRUE,deep=FALSE){ setwd("LOG") file.remove( grep("(out$)|(endpoint$)|(log$)", - list.files(), value = T) - )} + list.files(), value = T)) + areThereAnyFolders <- TRUE + } if(dir.exists("../ERROR")){ setwd("../ERROR") file.remove( grep("(out$)|(endpoint$)|(log$)", - list.files(), value = T) - )} + list.files(), value = T)) + areThereAnyFolders <- TRUE + } + if(dir.exists("../EPCS")){ setwd("../EPCS") file.remove( grep("(out$)|(endpoint$)|(log$)|(epc$)", - list.files(), value = T) - )} + list.files(), value = T)) + areThereAnyFolder <- TRUE + } if(dir.exists("../WRONGEPC")){ setwd("../WRONGEPC") - file.remove( grep("(out$)|(endpoint$)|(log$)|(epc$)", - list.files(), value = T) - )} - - setwd("..") - file.remove( - grep("(out$)|(endpoint$)|(log$)", - list.files(), value = T) - ) - + list.files(), value = T)) + areThereAnyFolders <- TRUE + } + + if(areThereAnyFolders){ + setwd("..") + file.remove( + grep("(out$)|(endpoint$)|(log$)", + list.files(), value = T)) + } else { + file.remove( + grep("(out$)|(endpoint$)|(log$)", + list.files(), value = T))} } + if(!simplicity){ file.remove( grep("(out$)|(endpoint$)|(log$)", diff --git a/RBBGCMuso/R/rungetMuso.R b/RBBGCMuso/R/rungetMuso.R index ebfc701..9d59a0c 100644 --- a/RBBGCMuso/R/rungetMuso.R +++ b/RBBGCMuso/R/rungetMuso.R @@ -10,7 +10,7 @@ rungetMuso <- function(settings, timee="d", debugging=FALSE, logfilename=NULL, k ############################################################# ############################spinup run############################ - ########################################################## +########################################################## ##Copy the variables from settings inputloc <- settings$inputloc @@ -29,7 +29,7 @@ rungetMuso <- function(settings, timee="d", debugging=FALSE, logfilename=NULL, k cat(" \n \n WARMING: there is a log or dayout file nearby the ini files, that may cause problemes. \n \n If you want to avoid that possible problemes, please copy the log or dayout files into a save place, and after do a cleanupMuso(), or delete these manually, or run the rungetMuso(), with the agressive=TRUE parameter \n \n") } - + } if(aggressive==TRUE){ @@ -47,10 +47,10 @@ rungetMuso <- function(settings, timee="d", debugging=FALSE, logfilename=NULL, k if(silent){#silenc mode if(Linuxp){ - #In this case, in linux machines + #In this case, in linux machines system(paste(executable,ininput[1],"> /dev/null",sep=" ")) } else { - #In windows machines there is a show.output.on.console option + #In windows machines there is a show.output.on.console option system(paste(executable,ininput[1],sep=" "),show.output.on.console = FALSE) } @@ -69,9 +69,9 @@ rungetMuso <- function(settings, timee="d", debugging=FALSE, logfilename=NULL, k if(!spincrash){##If spinup did not crashed, run the normal run. - ##################################################################### - ###########################normal run######################### - ################################################################# +##################################################################### +###########################normal run######################### +################################################################# ##for the sake of safe we set the location again setwd(inputloc) @@ -107,7 +107,7 @@ rungetMuso <- function(settings, timee="d", debugging=FALSE, logfilename=NULL, k perror<-as.numeric(as.vector(lapply(paste(outputloc,logfiles,sep="/"),function(x) tail(readLines(x,-1),1)))) #vector of spinup and normalrun error if((debugging=="stamplog")|(debugging==TRUE)){#If debugging option turned on - #If log or ERROR directory does not exists create it! + #If log or ERROR directory does not exists create it! dirName<-paste(inputloc,"LOG",sep="") dirERROR<-paste(inputloc,"ERROR",sep="") @@ -120,7 +120,7 @@ rungetMuso <- function(settings, timee="d", debugging=FALSE, logfilename=NULL, k } } -##if errorsign is 1 there is error, if it is 0 everything ok + ##if errorsign is 1 there is error, if it is 0 everything ok if(length(perror)>sum(perror)){ errorsign <- 1 } else { @@ -196,9 +196,9 @@ rungetMuso <- function(settings, timee="d", debugging=FALSE, logfilename=NULL, k if(leapYear){ Reva <- corrigMuso(settings,Reva) - rownames(Reva) <- musoDate(settings) - } else { - rownames(Reva) <- musoDate(settings, corrigated=FALSE) + rownames(Reva) <- musoDate(settings) + } else { + rownames(Reva) <- musoDate(settings, corrigated=FALSE) } if(export!=FALSE){ @@ -208,8 +208,8 @@ rungetMuso <- function(settings, timee="d", debugging=FALSE, logfilename=NULL, k ## "csv"=(write.csv(Reva,export)), ## "xlsx"=(), ## "odt"= - - + + ## ) write.csv(Reva,export)