r4886 - trunk/cumin/python/cumin
by tmckay@fedoraproject.org
Author: tmckay
Date: 2011-07-22 19:10:33 +0000 (Fri, 22 Jul 2011)
New Revision: 4886
Modified:
trunk/cumin/python/cumin/task.py
Log:
Escape XML special characters in status values on banner notices for tasks.
BZ725038
Modified: trunk/cumin/python/cumin/task.py
===================================================================
--- trunk/cumin/python/cumin/task.py 2011-07-22 14:55:26 UTC (rev 4885)
+++ trunk/cumin/python/cumin/task.py 2011-07-22 19:10:33 UTC (rev 4886)
@@ -258,7 +258,7 @@
if not description:
description = ""
- status = item.get_status(session)
+ status = xml_escape(str(item.get_status(session)))
return "%s: %s" % (description, status)
12 years, 9 months
r4885 - trunk/cumin/instance
by tmckay@fedoraproject.org
Author: tmckay
Date: 2011-07-22 14:55:26 +0000 (Fri, 22 Jul 2011)
New Revision: 4885
Added:
trunk/cumin/instance/rpc-defs
Log:
Missing symlink under instance for rpc-defs directory
Added: trunk/cumin/instance/rpc-defs
===================================================================
--- trunk/cumin/instance/rpc-defs (rev 0)
+++ trunk/cumin/instance/rpc-defs 2011-07-22 14:55:26 UTC (rev 4885)
@@ -0,0 +1 @@
+link ../../sage/rpc-defs
\ No newline at end of file
Property changes on: trunk/cumin/instance/rpc-defs
___________________________________________________________________
Added: svn:special
+ *
12 years, 9 months
r4884 - trunk/cumin/python/cumin/grid
by tmckay@fedoraproject.org
Author: tmckay
Date: 2011-07-22 13:32:02 +0000 (Fri, 22 Jul 2011)
New Revision: 4884
Modified:
trunk/cumin/python/cumin/grid/job.py
Log:
Provide tutorial comments on how field data is processed for the job
ads editor form, as a guide and salve for future adventurers...
Modified: trunk/cumin/python/cumin/grid/job.py
===================================================================
--- trunk/cumin/python/cumin/grid/job.py 2011-07-22 13:06:36 UTC (rev 4883)
+++ trunk/cumin/python/cumin/grid/job.py 2011-07-22 13:32:02 UTC (rev 4884)
@@ -708,7 +708,31 @@
def __init__(self, app, name):
super(JobAdsEditor, self).__init__(app, name)
- # the parameter that will hold all the field values
+ # self.ads will hold all the field values when the edit form
+ # is submitted. How self.ads is created and used is not
+ # immediately apparent, so here is a brief overview
+ # (with lots of details left out).
+
+ # Because this class is derived from JobAdsViewer, it has a
+ # JobAdsGroup as a child. During rendering of the JobAdsGroup,
+ # do_get_items() below is called and each element of the result is
+ # passed to EditablePropertyRenderer.render_value().
+ # (look to JobAdsGroup.render_properties() for these calls)
+
+ # In do_get_items(), item["path"] is set to self.ads.path for each
+ # item. This allows EditablePropertyRenderer to create html elements
+ # with names based on self.ads.path and other elements of each item.
+ # When the form is submitted, the POST request contains name/value pairs
+ # for all the html elements marshaled into a URL.
+
+ # The unmarshaling process results in a dictionary of all the job
+ # attributes on the edit page stored in the session under self.ads.path.
+ # This dictionary is what is processed in process_submit() below.
+
+ # Note that EditablePropertyRenderer creates hidden html elements
+ # for each item which contain original value and type information in
+ # addition to an input element. These extra fields are important
+ # in process_submit().
self.ads = DictParameter(app, "params")
self.add_parameter(self.ads)
@@ -721,6 +745,9 @@
if len(ads):
# we just returned from a submit
+ # Don't think this code is ever called, since process_cancel
+ # below clears self.ads and is called at the end of process_submit.
+ # Never saw the debugger hit a breakpoint here... tmckay 7/22/2011
cls = self.app.model.job_meta_data
return [self.gen_item(x, ads[x]["value"], cls, path=self.ads.path,
dtype=ads[x]["type"], error=ads[x],
12 years, 9 months
r4883 - trunk/cumin/python/cumin
by croberts@fedoraproject.org
Author: croberts
Date: 2011-07-22 13:06:36 +0000 (Fri, 22 Jul 2011)
New Revision: 4883
Modified:
trunk/cumin/python/cumin/stat.py
Log:
Fix for https://bugzilla.redhat.com/show_bug.cgi?id=709477 . Bringing the time-series chart back for host info by fixing the get_max_min signature for StackedAreaChart.
Modified: trunk/cumin/python/cumin/stat.py
===================================================================
--- trunk/cumin/python/cumin/stat.py 2011-07-22 12:44:12 UTC (rev 4882)
+++ trunk/cumin/python/cumin/stat.py 2011-07-22 13:06:36 UTC (rev 4883)
@@ -1183,7 +1183,7 @@
self.alpha = 1
- def get_max_min(self, session, stats, samples):
+ def get_max_min(self, session, stats, samples, time_span, end_seconds_ago):
max_value = 0
min_value = 0
points = dict()
12 years, 9 months
r4882 - trunk/cumin/python/cumin
by croberts@fedoraproject.org
Author: croberts
Date: 2011-07-22 12:44:12 +0000 (Fri, 22 Jul 2011)
New Revision: 4882
Modified:
trunk/cumin/python/cumin/stat.py
Log:
Correcting the PercentAreaChart (for free memory). The get_max_min method was using the wrong signature. This addresses BZ: https://bugzilla.redhat.com/show_bug.cgi?id=724946
Modified: trunk/cumin/python/cumin/stat.py
===================================================================
--- trunk/cumin/python/cumin/stat.py 2011-07-21 21:10:03 UTC (rev 4881)
+++ trunk/cumin/python/cumin/stat.py 2011-07-22 12:44:12 UTC (rev 4882)
@@ -1321,8 +1321,8 @@
return chart_obj
class PercentAreaChart(AreaChart):
- def get_max_min(self, session, stats, samples):
- max_val, min_val = super(PercentAreaChart, self).get_max_min(session, stats, samples)
+ def get_max_min(self, session, stats, samples, time_span, end_seconds_ago):
+ max_val, min_val = super(PercentAreaChart, self).get_max_min(session, stats, samples, time_span, end_seconds_ago)
percent = self.page.percent_property.get(session)
total = self.page.get_object_property(session, percent)
12 years, 9 months
r4881 - trunk/cumin/python/cumin/grid
by tmckay@fedoraproject.org
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)
12 years, 9 months
r4880 - trunk/cumin/python/cumin/grid
by tmckay@fedoraproject.org
Author: tmckay
Date: 2011-07-21 19:42:21 +0000 (Thu, 21 Jul 2011)
New Revision: 4880
Modified:
trunk/cumin/python/cumin/grid/job.py
Log:
Don't allow expressions to be double-quoted on edit by a user.
BZ723848
Modified: trunk/cumin/python/cumin/grid/job.py
===================================================================
--- trunk/cumin/python/cumin/grid/job.py 2011-07-21 19:30:36 UTC (rev 4879)
+++ trunk/cumin/python/cumin/grid/job.py 2011-07-21 19:42:21 UTC (rev 4880)
@@ -784,6 +784,11 @@
fval = "\"%s\"" % strip_string_quotes(fval)
orig = "\"%s\"" % strip_string_quotes(orig)
+ elif ftype == "expression":
+ # Might as well prevent user from inadvertently changing
+ # an expression into a string by adding double quotes
+ fval = strip_string_quotes(fval)
+
if fval != orig:
just_ads[unicode(field)] = fval
12 years, 9 months
r4879 - in trunk/cumin/python/cumin: . grid
by tmckay@fedoraproject.org
Author: tmckay
Date: 2011-07-21 19:30:36 +0000 (Thu, 21 Jul 2011)
New Revision: 4879
Modified:
trunk/cumin/python/cumin/grid/job.py
trunk/cumin/python/cumin/widgets.py
Log:
Use descriptor information from condor on GetJobAd to mark expressions
as distinct from strings. On submit of job ad edit, insure that string
values are enclosed in double quotes (but leave expressions alone).
BZ723848
Modified: trunk/cumin/python/cumin/grid/job.py
===================================================================
--- trunk/cumin/python/cumin/grid/job.py 2011-07-20 19:16:08 UTC (rev 4878)
+++ trunk/cumin/python/cumin/grid/job.py 2011-07-21 19:30:36 UTC (rev 4879)
@@ -435,14 +435,19 @@
self.qmf_error.set(session, error)
ads = results.data['JobAd']
cls = self.app.model.job_meta_data
- ad_list = [self.gen_item(x, ads[x], cls, dtype=self.get_type(ads[x])) \
+ ad_list = [self.gen_item(x, ads[x], cls, dtype=self.get_type(ads, x)) \
for x in ads if not x.startswith("!!")]
-
self.items.set(session, ad_list)
return ad_list, error
- def get_type(self, value):
+ def get_desc(self, descriptors, x):
+ if x in descriptors:
+ return descriptors[x]
+ return ""
+
+ def get_type(self, ads, x):
+ value = ads[x]
if isinstance(value, (int, long)):
type = "integer"
elif isinstance(value, float):
@@ -451,6 +456,16 @@
type = "dict"
else:
type = "string"
+ # This will have to change to support queries from
+ # aviary. The !!descriptors convention is from qmf
+ # Probably, a common form for job ads should be defined
+ # and data from aviary and qmf coerced in sage to fit
+ # the definition. Side note, aviary data natively is
+ # closer to what could be/is a canonical form...
+ if "!!descriptors" in ads:
+ desc = self.get_desc(ads["!!descriptors"], x)
+ if desc == "com.redhat.grid.Expression":
+ type = "expression"
return type
def gen_item(self, name, value, cls, path=None, dtype=None,
@@ -506,9 +521,8 @@
self.qmf_error.set(session, error)
ads = results.data['JobAd']
cls = self.app.model.job_meta_data
- ad_list = [self.gen_item(x, ads[x], cls, dtype=self.get_type(ads[x])) \
+ ad_list = [self.gen_item(x, ads[x], cls, dtype=self.get_type(ads, x)) \
for x in ads if not x.startswith("!!") and x in self.app.fast_view_attributes]
-
self.items.set(session, ad_list)
return ad_list, error
@@ -757,10 +771,20 @@
orig = int(orig)
elif ftype == "float":
orig = float(orig)
+ elif ftype == "string":
+ # For ftype == "string", we want to insure double quotes.
+ # This is due to the convention in the condor plugins which
+ # treats strings with double quotes as string literals and
+ # all other strings as expressions. And quotes were stripped
+ # on the way in.
+ # Expressions should be marked with ftype == "expression"
+ # although the value is still a string.
+
+ # make sure we have quotes on new val and original...
+ fval = "\"%s\"" % strip_string_quotes(fval)
+ orig = "\"%s\"" % strip_string_quotes(orig)
+
if fval != orig:
- if ftype == "string" and \
- strip_string_quotes(fval) == strip_string_quotes(orig):
- continue
just_ads[unicode(field)] = fval
# Process all cases, including errors, becase we
Modified: trunk/cumin/python/cumin/widgets.py
===================================================================
--- trunk/cumin/python/cumin/widgets.py 2011-07-20 19:16:08 UTC (rev 4878)
+++ trunk/cumin/python/cumin/widgets.py 2011-07-21 19:30:36 UTC (rev 4879)
@@ -242,11 +242,6 @@
def render_help_href(self, session, *args):
return "resource?name=help.html#%s" % self.path
-class CuminEditableProperties(PropertySet):
- def __init__(self, app, name):
- self.item_renderer=EditablePropertyRenderer(self, "property_html")
- super(CuminEditableProperties, self).__init__(app, name, item_renderer=self.item_renderer)
-
class EditablePropertyRenderer(TemplateRenderer, Widget):
"""Display input fields for editing properties
@@ -292,14 +287,14 @@
elif type == "float" or type == "integer":
self.__number_template.render(writer, session, item)
else:
- uvalue = value.upper()
- if uvalue == "FALSE" or uvalue == "TRUE":
- self.__bool_template.render(writer, session, item)
+ # It's either a string or an expression, and the type value
+ # will be recorded in the "type" hidden input for the element.
+ # On processing, the type can be checked to deal with string
+ # vs expression.
+ if len(value) > 40:
+ self.__bigstring_template.render(writer, session, item)
else:
- if len(value) > 40:
- self.__bigstring_template.render(writer, session, item)
- else:
- self.__string_template.render(writer, session, item)
+ self.__string_template.render(writer, session, item)
return writer.to_string()
12 years, 9 months
r4878 - branches/clarity/cumin/python/cumin/grid
by tmckay@fedoraproject.org
Author: tmckay
Date: 2011-07-20 19:16:08 +0000 (Wed, 20 Jul 2011)
New Revision: 4878
Modified:
branches/clarity/cumin/python/cumin/grid/job.py
Log:
Merge 4877 from trunk.
BZ723613
BZ703196 (backout autoquoting of string values)
Modified: branches/clarity/cumin/python/cumin/grid/job.py
===================================================================
--- branches/clarity/cumin/python/cumin/grid/job.py 2011-07-20 17:30:59 UTC (rev 4877)
+++ branches/clarity/cumin/python/cumin/grid/job.py 2011-07-20 19:16:08 UTC (rev 4878)
@@ -735,6 +735,7 @@
just_ads = dict()
for field in ads:
+ ads[field]["error"] = None
try:
fval = ads[field]["value"]
except KeyError:
@@ -763,23 +764,21 @@
elif ftype == "float":
orig = float(orig)
if fval != orig:
- if ftype == "string":
- quoted = "\"%s\"" % strip_string_quotes(fval)
- if quoted == orig:
- continue
- just_ads[unicode(field)] = quoted #string
- else:
- just_ads[unicode(field)] = fval
+ if ftype == "string" and \
+ strip_string_quotes(fval) == strip_string_quotes(orig):
+ continue
+ just_ads[unicode(field)] = fval
- if not errors:
- id = self.frame.id.get(session)
- scheduler = self.frame.get_scheduler(session, id)
- job_id = self.frame.job_id.get(session)
+ # Process all cases, including errors, becase we
+ # want to see a banner for errors we detect.
+ id = self.frame.id.get(session)
+ scheduler = self.frame.get_scheduler(session, id)
+ job_id = self.frame.job_id.get(session)
- task = self.frame.set_ad_task
- for field in just_ads:
- task.invoke(session, scheduler, job_id, field, str(just_ads[field]))
- self.process_cancel(session)
+ task = self.frame.set_ad_task
+ for field in just_ads:
+ task.invoke(session, scheduler, job_id, field, str(just_ads[field]), ads[field]["error"])
+ self.process_cancel(session)
class OutputFile(Widget):
err_msg = "Output, Error, and UserLog file names are invalid."
@@ -1070,6 +1069,13 @@
def get_description(self, session):
return "Edit Ad"
- def do_invoke(self, invoc, scheduler, job_id, name, value):
- self.qmf_call(invoc, scheduler, "SetJobAttribute", job_id, name, value)
+ def do_invoke(self, invoc, scheduler, job_id, name, value, error):
+ # Don't make the call, but we want to see the banner
+ # so invoke the callback directly with the error as status
+ if error:
+ invoc.status_code = name + ": " + str(error)
+ invoc.output_args = None
+ invoc.end()
+ else:
+ self.qmf_call(invoc, scheduler, "SetJobAttribute", job_id, name, value)
12 years, 9 months
r4877 - trunk/cumin/python/cumin/grid
by tmckay@fedoraproject.org
Author: tmckay
Date: 2011-07-20 17:30:59 +0000 (Wed, 20 Jul 2011)
New Revision: 4877
Modified:
trunk/cumin/python/cumin/grid/job.py
Log:
* Report errors for type mismatches on attribute edits. These errors were
previously generated but not reported, and actually the occurrence of an
error would leave the page in "Loading..." after submit
* Do not automatically add quotes to string attribute values. Adding quotes
allowed users to edit Args without providing explicit quotes, but it broke
attributes with expression values like Requirements.
BZ703196 (backout automatic quoting)
BZ723613
Modified: trunk/cumin/python/cumin/grid/job.py
===================================================================
--- trunk/cumin/python/cumin/grid/job.py 2011-07-18 16:29:58 UTC (rev 4876)
+++ trunk/cumin/python/cumin/grid/job.py 2011-07-20 17:30:59 UTC (rev 4877)
@@ -729,6 +729,7 @@
just_ads = dict()
for field in ads:
+ ads[field]["error"] = None
try:
fval = ads[field]["value"]
except KeyError:
@@ -757,23 +758,21 @@
elif ftype == "float":
orig = float(orig)
if fval != orig:
- if ftype == "string":
- quoted = "\"%s\"" % strip_string_quotes(fval)
- if quoted == orig:
- continue
- just_ads[unicode(field)] = quoted #string
- else:
- just_ads[unicode(field)] = fval
+ if ftype == "string" and \
+ strip_string_quotes(fval) == strip_string_quotes(orig):
+ continue
+ just_ads[unicode(field)] = fval
- if not errors:
- id = self.frame.id.get(session)
- scheduler = self.frame.get_scheduler(session, id)
- job_id = self.frame.job_id.get(session)
+ # Process all cases, including errors, becase we
+ # want to see a banner for errors we detect.
+ id = self.frame.id.get(session)
+ scheduler = self.frame.get_scheduler(session, id)
+ job_id = self.frame.job_id.get(session)
- task = self.frame.set_ad_task
- for field in just_ads:
- task.invoke(session, scheduler, job_id, field, str(just_ads[field]))
- self.process_cancel(session)
+ task = self.frame.set_ad_task
+ for field in just_ads:
+ task.invoke(session, scheduler, job_id, field, str(just_ads[field]), ads[field]["error"])
+ self.process_cancel(session)
class OutputFile(Widget):
err_msg = "Output, Error, and UserLog file names are invalid."
@@ -1063,7 +1062,12 @@
def get_description(self, session):
return "Edit Ad"
- def do_invoke(self, invoc, scheduler, job_id, name, value):
- self.app.remote.set_job_attribute(scheduler, job_id, name, value,
- invoc.make_callback())
+ def do_invoke(self, invoc, scheduler, job_id, name, value, error):
+ # Don't make the call, but we want to see the banner
+ # so invoke the callback directly with the error as status
+ if error:
+ invoc.make_callback()(name + ": " + str(error), None)
+ else:
+ self.app.remote.set_job_attribute(scheduler, job_id, name, value,
+ invoc.make_callback())
12 years, 9 months