Author: tmckay
Date: 2011-07-21 21:10:03 +0000 (Thu, 21 Jul 2011)
New Revision: 4881
Modified:
trunk/cumin/python/cumin/grid/job.py
Log:
Loosen type checks in job ad editing. Allow floats and ints
to be set to non-quoted strings (ie, expressions) and let condor
sort it out. Still restrict int from becoming float...
Modified: trunk/cumin/python/cumin/grid/job.py
===================================================================
--- trunk/cumin/python/cumin/grid/job.py 2011-07-21 19:42:21 UTC (rev 4880)
+++ trunk/cumin/python/cumin/grid/job.py 2011-07-21 21:10:03 UTC (rev 4881)
@@ -738,8 +738,18 @@
self.page.redirect.set(session, branch.marshal())
def process_submit(self, session):
+
+ def can_be_float(val):
+ try:
+ f = float(val)
+ return True
+ except:
+ return False
+
+ def has_double_quotes(value):
+ return value[:1] == "\"" and value[-1:] ==
"\""
+
ads = self.ads.get(session)
- errors = False
just_ads = dict()
for field in ads:
@@ -754,14 +764,24 @@
try:
fval = int(fval)
except:
- ads[field]["error"] = "Integer value expected"
- errors = True
+ # okay, if there are no double quotes and it's not
+ # a float, go ahead and let condor try to accept this
+ # as an expression
+ if has_double_quotes(fval) or can_be_float(fval):
+ ads[field]["error"] = "Integer value
expected"
+ else:
+ ftype = "expression"
+
elif ftype == "float":
try:
fval = float(fval)
except:
- ads[field]["error"] = "Floating point value
expected"
- errors = True
+ # okay, if there are no double quotes then let
+ # condor try to accept this as an expression
+ if has_double_quotes(fval):
+ ads[field]["error"] = "Floating point value
expected"
+ else:
+ ftype = "expression"
else:
fval = unicode(fval)
Show replies by date