aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcslocum <cslocum@d34015c8-bcbb-4646-8ac8-8ba5febf221d>2014-09-10 14:44:10 -0400
committercslocum <cslocum@d34015c8-bcbb-4646-8ac8-8ba5febf221d>2014-09-10 14:44:10 -0400
commit7eae6c96bdec6ad1a5dadbd4cd0c07231dcca179 (patch)
tree612204f11614676af059e97cdcae4f2c185c9a3f
parentbc68f11a5fc3d4132676068d91eccf0652e715fb (diff)
downloadsteuermann-7eae6c96bdec6ad1a5dadbd4cd0c07231dcca179.tar.gz
some changes to how CONDITIONS block is processed; incrememnt N to 20
git-svn-id: https://svn.stsci.edu/svn/ssb/etal/steuermann/trunk@1318 d34015c8-bcbb-4646-8ac8-8ba5febf221d
-rwxr-xr-xgo2
-rw-r--r--steuermann/nodes.py40
-rw-r--r--steuermann/run_all.py22
3 files changed, 38 insertions, 26 deletions
diff --git a/go b/go
index d9d06c6..c858358 100755
--- a/go
+++ b/go
@@ -1,6 +1,6 @@
#!/bin/sh
-n=19
+n=20
rm -rf build
diff --git a/steuermann/nodes.py b/steuermann/nodes.py
index 871b7c6..17b73ab 100644
--- a/steuermann/nodes.py
+++ b/steuermann/nodes.py
@@ -3,6 +3,8 @@ Stuff related to the tree structure of the command set
'''
import fnmatch
+from run_all import allowed_flags
+import sys
#import exyapps.runtime
@@ -366,6 +368,21 @@ def read_file_list( file_list ) :
saved_conditions = { 'True' : True, 'False' : False }
+# find any unknown arguments like --something=whatever, set as conditions
+arguments = sys.argv[1:]
+for a in arguments:
+ if '--' in a and '=' in a:
+ not_allowed_flag = True
+ for f in allowed_flags.keys():
+ if a.startswith(f):
+ not_allowed_flag = False
+ break
+ if not_allowed_flag:
+ a = a.lstrip('--')
+ k, v = a.split('=')
+ saved_conditions[k] = eval(v)
+
+
def declare_conditions( text, filename ) :
# the parameter "text" is the token that begins "CONDITION\n"
# and ends "\nEND\n", with a block of python code in the middle.
@@ -377,22 +394,13 @@ def declare_conditions( text, filename ) :
text = text.split('\n',1)[1] # tear off "CONDITION\n"
text = text.rsplit('\n',2)[0] # tear off "END\n"
- # if it is indented at all, compensate for the indent so the
- # exec will work
- if text.startswith(' ') or text.startswith('\t') :
- text = 'if 1 :\n' + text
-
- # exec it into cond first, and then move any entries that are unique
- # into saved_conditions; this allows us to specify conditions on the
- # command line and not have them overwritten by the same variable in
- # a CONDITIONS block
- cond = {}
- exec text in cond
- for k, v in cond.items():
- if k not in saved_conditions:
- saved_conditions[k] = v
-
-
+ for ln in text.split('\n'):
+ ln = ln.strip()
+ cond = saved_conditions.copy()
+ exec ln in cond
+ for k, v in cond.items():
+ if k not in saved_conditions:
+ saved_conditions[k] = v
def check_condition( name, filename ) :
diff --git a/steuermann/run_all.py b/steuermann/run_all.py
index 50b415e..425d5e3 100644
--- a/steuermann/run_all.py
+++ b/steuermann/run_all.py
@@ -35,6 +35,15 @@ username=getpass.getuser()
#####
+allowed_flags = {
+ '--all' : '-a' ,
+ '-a' : '' , # run all nodes non-interactively
+ '-r' : '=' , # give run name
+ '-n' : '' , # do not actually execute any processes
+ '-h' : '=' , # give hosts (*.ini) file
+}
+
+
def main() :
global xnodes
@@ -60,20 +69,15 @@ def main() :
# # several times to get a list
# '--verbose' : '-v', # arg is an alias for some other arg
- allowed_flags = {
- '--all' : '-a' ,
- '-a' : '' , # run all nodes non-interactively
- '-r' : '=' , # give run name
- '-n' : '' , # do not actually execute any processes
- '-h' : '=' , # give hosts (*.ini) file
- }
-
opt, args = easyargs.get(allowed_flags, allow_unexpected = True)
all = opt['-a']
no_run = opt['-n']
+ '''
+ NOTE: moving this functionality into nodes.py
+
# find any unknown arguments like --something=whatever, set as conditions
arguments = sys.argv[1:]
for a in arguments:
@@ -88,7 +92,7 @@ def main() :
a = a.lstrip('--')
k, v = a.split('=')
nodes.saved_conditions[k] = eval(v)
-
+ '''
sm_files = [a for a in args if ('--' not in a and '=' not in a)]
di_nodes = nodes.read_file_list( sm_files )