diff --git a/pfb_to_zip/__init__.py b/pfb_to_zip/__init__.py index e69de29..1271c1e 100644 --- a/pfb_to_zip/__init__.py +++ b/pfb_to_zip/__init__.py @@ -0,0 +1 @@ +from .pfb_to_zip import PFBExporter \ No newline at end of file diff --git a/pfb_to_zip/pfb_to_zip.py b/pfb_to_zip/pfb_to_zip.py index 2698f6a..80ac366 100644 --- a/pfb_to_zip/pfb_to_zip.py +++ b/pfb_to_zip/pfb_to_zip.py @@ -122,8 +122,7 @@ def initialize(self): tmp_path = Path(self.analysis_path + "/analysis") if not tmp_path.exists(): tmp_path.mkdir() - - tmp_path = os.path.join("./", "repo") + tmp_path = os.path.join(self.tmp_folder, "repo") if Path(tmp_path).exists(): rmtree(tmp_path, ignore_errors=False, onerror=None) @@ -247,18 +246,22 @@ def setup_and_run_analysis(self, consortium=None): return # TODO check R is installed + #check if R is installed try: - command = 'which RScript' - cmd_output = subprocess.check_output(command, shell=True, text=True).rstrip('\n') + cmd_output = subprocess.check_output('which Rscript', shell=True, text=True).rstrip('\n') except subprocess.CalledProcessError as grepexc: print("error code", grepexc.returncode, grepexc.output) - print("R is not installed / not found!") - return + print("Rscript is not installed or found in Path!") + try: + cmd_output = subprocess.check_output('which RScript', shell=True, text=True).rstrip('\n') + except subprocess.CalledProcessError as grepexc: + print("error code", grepexc.returncode, grepexc.output) + print("R is not installed / not found!") + return current_dir = str(Path( __file__ ).parent.absolute()) # subprocess.call(cmd_output + " --vanilla ./repo/INRG/PCDC_To_INRG_Data_Transformation.R", shell=True) - subprocess.call ([cmd_output, "--vanilla", "./repo/INRG/PCDC_To_INRG_Data_Transformation.R", os.path.join(current_dir, "repo/"), self.analysis_path + "/tsvs/", self.analysis_path + "/analysis/"]) - + subprocess.call ([cmd_output, "--vanilla", f"{self.tmp_folder}/repo/INRG/PCDC_To_INRG_Data_Transformation.R", os.path.join(self.tmp_folder, "repo/"), self.analysis_path + "/tsvs/", self.analysis_path + "/analysis/"]) # TODO cd to consortia subfolder # TODO run the script with the input and output parameters