aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/setup_pfiles.py
diff options
context:
space:
mode:
authorAaron LI <aaronly.me@outlook.com>2017-02-06 11:13:14 +0800
committerAaron LI <aaronly.me@outlook.com>2017-02-06 11:13:14 +0800
commit8628ab8cbcb185826e97af9148ec7d07861e29e7 (patch)
tree378551bd36d68bfa37713fbdfd90c64c361c2881 /scripts/setup_pfiles.py
parentde622e5e739d68dbf10691c66f65ef08425de8f1 (diff)
downloadchandra-acis-analysis-8628ab8cbcb185826e97af9148ec7d07861e29e7.tar.bz2
Add setup_pfiles.py to setup parameter files for CIAO tools
Diffstat (limited to 'scripts/setup_pfiles.py')
-rw-r--r--scripts/setup_pfiles.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/scripts/setup_pfiles.py b/scripts/setup_pfiles.py
new file mode 100644
index 0000000..d927005
--- /dev/null
+++ b/scripts/setup_pfiles.py
@@ -0,0 +1,35 @@
+# Copyright (c) 2017 Weitian LI <liweitianux@live.com>
+# MIT license
+#
+# Weitian LI
+# 2017-02-06
+
+"""
+Prepare the CIAO parameter files and setup the PFILES environment
+variable to keep the pfiles locally, in order to avoid the conflicts
+between multiple instance of the same CIAO tools.
+"""
+
+import os
+import subprocess
+import shutil
+
+
+def setup_pfiles(tools):
+ """
+ Copy the parameter files of the specified tools to the current
+ working directory, and setup the ``PFILES`` environment variable.
+
+ Parameters
+ ----------
+ tools : list[str]
+ Name list of the tools to be set up
+ """
+ for tool in tools:
+ pfile = subprocess.check_output([
+ "paccess", tool
+ ]).decode("utf-8").strip()
+ subprocess.check_call(["punlearn", tool])
+ shutil.copy(pfile, ".")
+ # Setup the ``PFILES`` environment variable
+ os.environ["PFILES"] = "./:" + os.environ["PFILES"]