aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTinWoodman92 <chrhodgden@gmail.com>2023-05-30 18:37:33 -0500
committerTinWoodman92 <chrhodgden@gmail.com>2023-05-30 18:37:33 -0500
commit5f1696719ec36979005f5792a4049b30e5a7d9b2 (patch)
treea68afab96eecb0122104e4974a35740b71c998e6
parent69a427749a4b7c58b3a58ea43aadee985dc2e069 (diff)
consolidated launchers for multithread.
-rw-r--r--launcher.py25
-rw-r--r--launcher_R.py19
-rw-r--r--launcher_py.py17
3 files changed, 25 insertions, 36 deletions
diff --git a/launcher.py b/launcher.py
new file mode 100644
index 0000000..4798429
--- /dev/null
+++ b/launcher.py
@@ -0,0 +1,25 @@
+import os
+from subprocess import *
+import threading
+
+def execute_source_file(file_name):
+ ext = file_name.split('.')
+ if ext[1] == 'py': cmd = 'Python'
+ elif ext[1] == 'r': cmd = 'RScript'
+ run(
+ f'{cmd} {file_name}',
+ cwd = os.getcwd(),
+ start_new_session = True
+ )
+
+src_fil_py = threading.Thread(target=execute_source_file, args=['source_file.py'])
+src_fil_r = threading.Thread(target=execute_source_file, args=['source_file.r'])
+
+src_fil_r.start()
+src_fil_py.start()
+
+src_fil_r.join()
+src_fil_py.join()
+
+print("end launcher")
+
diff --git a/launcher_R.py b/launcher_R.py
deleted file mode 100644
index 415430a..0000000
--- a/launcher_R.py
+++ /dev/null
@@ -1,19 +0,0 @@
-import os
-from subprocess import *
-
-print(os.getcwd())
-
-tar_fil = os.path.join(os.getcwd(),'source_file.r')
-print(tar_fil)
-if os.path.exists(tar_fil):
- rscript_path = 'C:/Program Files/R/R-4.2.2/bin/Rscript.exe'
- print(os.path.exists(rscript_path))
- rscript_cmd = 'Rscript'
- run(
- f'{rscript_cmd} "{tar_fil}"',
- cwd = os.getcwd(),
- start_new_session = True
- )
-
-print("end launcher")
-
diff --git a/launcher_py.py b/launcher_py.py
deleted file mode 100644
index ae85727..0000000
--- a/launcher_py.py
+++ /dev/null
@@ -1,17 +0,0 @@
-import os
-from subprocess import *
-
-print(os.getcwd())
-
-tar_fil = os.path.join(os.getcwd(),'source_file.py')
-print(tar_fil)
-if os.path.exists(tar_fil):
- python_cmd = 'Python'
- run(
- f'{python_cmd} {tar_fil}',
- cwd = os.getcwd(),
- start_new_session = True
- )
-
-print("end launcher")
-