Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

now handling even if R source script might have ^M characters (carria…

…ge returns)
  • Loading branch information...
commit 8b9b89f7998d41ea38b03232818b4ae193eb8e7c 1 parent dc22d5b
@rdulepet authored
View
7 job.rb
@@ -55,6 +55,13 @@ def fetch_source_code
@job_id = (@doc/'job'/'id').inner_text
Global.logger.info("JOB_ID = #{@job_id}, LOCAL_DIR = #{Global.results_dir}/#{@curr_uuid}, SCRIPT_NAME = #{@r_script_filename}")
r_script = (@doc/'source-code').inner_text
+
+ # there is possibility that ^M characters are embedded in the R script
+ # these happen when files are edited in Windows and uploaded
+ # so lets remove it before further processing, R will not run with these
+ # ^M characters otherwise
+ r_script.gsub!(/\015/,"")
+
r_script_file_handle = File.open(@r_script_filename, aModeString="w")
# this is done to pass variables
r_script_file_handle.puts "source(\"#{@r_script_inc_filename}\")\n"
View
39 testing/crdatapnt/simpletest/noparam/carriage_return_test.r
@@ -0,0 +1,39 @@
+library("R2HTML")
+crdata_job_log <- file("job.log", open="wt")
+sink(crdata_job_log)
+crdata_target <- HTMLInitFile(getwd(), filename="index")
+tryCatch({
+source("/home/michael/crdatapn/temp/62da7647-5b6f-2ab0-2ad6-eedff9fbe61e/inc_62da7647-5b6f-2ab0-2ad6-eedff9fbe61e.r")
+HTML("Arbitrary Text 00", file=crdata_target)
+
+x = c(0,1,2,3,4,5)
+
+HTML(x, file=crdata_target)
+
+
+png(file.path(getwd(),"d6e2ade9-6aee-e155-8330-9660e7a3c0d3.png"))
+
+plot(x)
+
+dev.off()
+HTMLInsertGraph("d6e2ade9-6aee-e155-8330-9660e7a3c0d3.png", file=crdata_target,caption="")
+
+HTML("Arbitrary Text 01", file=crdata_target)
+
+
+}, interrupt = function(ex) {
+print ("got exception: Failed Job");
+ returnstatus="FAILED JOB, PLEASE CHECK LOG";
+HTML(returnstatus, file=crdata_target);
+print(ex);
+}, error = function(ex) {
+print ("got error: Failed Job");
+ returnstatus="FAILED JOB, PLEASE CHECK LOG";
+HTML(returnstatus, file=crdata_target);
+print(ex);
+}, finally = {
+print("JOB ENDED");
+HTMLEndFile()
+sink()
+close(crdata_job_log)
+
Please sign in to comment.
Something went wrong with that request. Please try again.