r5220 - trunk/cumin/python/cumin
by croberts@fedoraproject.org
Author: croberts
Date: 2012-02-14 20:13:05 +0000 (Tue, 14 Feb 2012)
New Revision: 5220
Modified:
trunk/cumin/python/cumin/task.py
trunk/cumin/python/cumin/widgets.strings
Log:
Adding timestamp to the display of yellow notification banner items. This satisfies BZ 787138.
Modified: trunk/cumin/python/cumin/task.py
===================================================================
--- trunk/cumin/python/cumin/task.py 2012-02-14 18:34:26 UTC (rev 5219)
+++ trunk/cumin/python/cumin/task.py 2012-02-14 20:13:05 UTC (rev 5220)
@@ -122,9 +122,11 @@
self.task = task
session.add_notice(self)
-
+
self.user = session.get_user()
+ self.timestamp = datetime.now()
+
self.start_time = None
self.end_time = None
self.update_time = None
@@ -137,7 +139,16 @@
self.output_args = None
self.dismissed = False
+
+ def __setattr__(self, name, value):
+ if name in ("status"):
+ self.timestamp = datetime.now()
+ super(TaskInvocation, self).__setattr__(name, value)
+ def get_timestamp(self, session):
+ if self.timestamp:
+ return self.timestamp
+
def get_description(self, session):
if self.description:
return self.description
@@ -156,11 +167,12 @@
return self.status
def get_message(self, session):
+ timestamp = self.get_timestamp(session)
description = xml_escape(self.get_description(session))
if not description:
description = ""
status = xml_escape(str(self.get_status(session)))
- return "%s: %s" % (description, status)
+ return "<span class='notification_time'>%s</span> %s: %s" % ("%s-%02d-%02d %02d:%02d:%02d" % (timestamp.year, timestamp.month, timestamp.day, timestamp.hour, timestamp.minute, timestamp.second), description, status)
def end(self):
log.debug("Ending %s", self.task)
Modified: trunk/cumin/python/cumin/widgets.strings
===================================================================
--- trunk/cumin/python/cumin/widgets.strings 2012-02-14 18:34:26 UTC (rev 5219)
+++ trunk/cumin/python/cumin/widgets.strings 2012-02-14 20:13:05 UTC (rev 5220)
@@ -906,6 +906,11 @@
font-size: 0.9em;
}
+div.NotificationSet .notification_time {
+ font-style: italic;
+ color: #707070;
+}
+
[NotificationSet.html]
<div id="{id}" class="{class}">
<a class="dismiss" href="{dismiss_all_href}">Dismiss all notifications</a><br/>
12 years, 2 months
r5219 - trunk/cumin/etc
by tmckay@fedoraproject.org
Author: tmckay
Date: 2012-02-14 18:34:26 +0000 (Tue, 14 Feb 2012)
New Revision: 5219
Modified:
trunk/cumin/etc/sysvinit-cumin
Log:
Movement of cumin-admin and cumin-database to /usr/sbin requires change to init script.
BZ767232
Modified: trunk/cumin/etc/sysvinit-cumin
===================================================================
--- trunk/cumin/etc/sysvinit-cumin 2012-02-13 21:32:10 UTC (rev 5218)
+++ trunk/cumin/etc/sysvinit-cumin 2012-02-14 18:34:26 UTC (rev 5219)
@@ -35,15 +35,15 @@
exit 1
}
- test -x /usr/bin/cumin-database || {
+ test -x /usr/sbin/cumin-database || {
echo_failure; echo
- echo "/usr/bin/cumin-database has been removed"
+ echo "/usr/sbin/cumin-database has been removed"
exit 1
}
- test -x /usr/bin/cumin-admin || {
+ test -x /usr/sbin/cumin-admin || {
echo_failure; echo
- echo "/usr/bin/cumin-admin has been removed"
+ echo "/usr/sbin/cumin-admin has been removed"
exit 1
}
12 years, 2 months
r5218 - in trunk: cumin/python/cumin cumin/python/cumin/grid cumin/python/cumin/messaging mint/python/mint rosemary/python/rosemary sage/python/sage/qmf
by tmckay@fedoraproject.org
Author: tmckay
Date: 2012-02-13 21:32:10 +0000 (Mon, 13 Feb 2012)
New Revision: 5218
Modified:
trunk/cumin/python/cumin/grid/negotiator.py
trunk/cumin/python/cumin/grid/slot.py
trunk/cumin/python/cumin/grid/tags.py
trunk/cumin/python/cumin/main.py
trunk/cumin/python/cumin/messaging/binding.py
trunk/cumin/python/cumin/model.py
trunk/cumin/python/cumin/objecttask.py
trunk/cumin/python/cumin/qmfadapter.py
trunk/cumin/python/cumin/task.py
trunk/mint/python/mint/update.py
trunk/mint/python/mint/util.py
trunk/rosemary/python/rosemary/sqloperation.py
trunk/sage/python/sage/qmf/qmfoperations.py
Log:
Remove all log.exception calls and replace with log.debug(msg, exc_info=True)
This allows exception traces at the debug level but keeps exception traces
out of INFO level logging.
BZ782839
Modified: trunk/cumin/python/cumin/grid/negotiator.py
===================================================================
--- trunk/cumin/python/cumin/grid/negotiator.py 2012-02-13 16:26:26 UTC (rev 5217)
+++ trunk/cumin/python/cumin/grid/negotiator.py 2012-02-13 21:32:10 UTC (rev 5218)
@@ -81,8 +81,7 @@
if not results.exception:
try:
groups = self.split_group_names(groups)
- except Exception, e:
- #log.exception(e)
+ except:
groups = []
if groups:
@@ -171,8 +170,8 @@
info[group][config] = "" ##raw_configs[config][group].error
elif raw_configs[config][group].got_data:
info[group][config] = raw_configs[config][group].data['Value']
- except Exception, e:
- log.exception(e)
+ except:
+ log.debug("Problem getting group config info", exc_info=True)
self.info.set(session, info)
return info
Modified: trunk/cumin/python/cumin/grid/slot.py
===================================================================
--- trunk/cumin/python/cumin/grid/slot.py 2012-02-13 16:26:26 UTC (rev 5217)
+++ trunk/cumin/python/cumin/grid/slot.py 2012-02-13 21:32:10 UTC (rev 5218)
@@ -284,8 +284,8 @@
act = None
try:
cat, cat_group = cls.categories[(state, act)]
- except Exception, e:
- log.exception(e)
+ except:
+ log.debug("Problem finding state and activity", exc_info=True)
cat, cat_group = ("%s:%s" % (state, activity), "Unknown")
return cat, cat_group
Modified: trunk/cumin/python/cumin/grid/tags.py
===================================================================
--- trunk/cumin/python/cumin/grid/tags.py 2012-02-13 16:26:26 UTC (rev 5217)
+++ trunk/cumin/python/cumin/grid/tags.py 2012-02-13 21:32:10 UTC (rev 5218)
@@ -105,8 +105,8 @@
for i, tag in enumerate(wallaby_tags):
data.append({'Tag':str(escape_entity(tag.name)), 'Features':", ".join(tag.features), 'NumHosts':len(self.app.wallaby.get_node_names(tag)), 'Host':self.app.wallaby.get_node_names(tag)} )
- except Exception, e:
- log.exception(e)
+ except:
+ log.debug("Problem adapting wallaby response", exc_info=True)
return data
@@ -1038,9 +1038,9 @@
self.invoc = invoc
try:
call_async(self.callback, self.app.wallaby.edit_tags, node_name, *tags)
- except Exception, e:
+ except:
invoc.status = invoc.FAILED
- log.exception(e)
+ log.debug("Edit node failed", exc_info=True)
invoc.end()
class TagsTagEditTask(ObjectFrameTask):
@@ -1084,10 +1084,10 @@
self.invoc = invoc
try:
call_async(self.callback, self.make_calls, invoc, tag, chosen_nodes)
- except Exception, e:
+ except:
self.call_count = 0
invoc.status = invoc.FAILED
- log.exception(e)
+ log.debug("Edit tag failed", exc_info=True)
invoc.end()
def make_calls(self, invoc, tag, chosen_nodes):
@@ -1112,10 +1112,10 @@
current_tags.remove(tag)
self.call_count += 1
call_async(self.callback, self.app.wallaby.edit_tags, node, *current_tags)
- except Exception, e:
+ except:
self.call_count = 0
invoc.status = invoc.FAILED
- log.exception(e)
+ log.debug("Edit tag failed", exc_info=True)
invoc.end()
return False
return None
@@ -1162,9 +1162,9 @@
self.invoc = invoc
try:
call_async(self.callback, self.app.wallaby.edit_features, tag, *chosen_features)
- except Exception, e:
+ except:
invoc.status = invoc.FAILED
- log.exception(e)
+ log.debug("Edit feature failed", exc_info=True)
invoc.end()
class ActivateConfigTask(Task):
@@ -1189,9 +1189,9 @@
self.invoc = invoc
try:
call_async(self.callback, self.app.wallaby.activate_configuration)
- except Exception, e:
+ except:
invoc.status = invoc.FAILED
- log.exception(e)
+ log.debug("Activate config failed", exc_info=True)
invoc.end()
class AddTags(Task):
@@ -1220,9 +1220,9 @@
try:
call_async(self.callback, self.app.wallaby.create_tags, tags)
- except Exception, e:
+ except:
invoc.status = invoc.FAILED
- log.exception(e)
+ log.debug("Adding tags failed", exc_info=True)
invoc.end()
class RemoveNodeTags(ObjectSelectorTask):
@@ -1260,9 +1260,9 @@
def do_invoke(self, invoc, tags):
try:
call_async(self.callback, self.app.wallaby.remove_tags, tags)
- except Exception, e:
+ except:
invoc.status = invoc.FAILED
- log.exception(e)
+ log.debug("Remove node tags failed", exc_info=True)
def get_item_content(self, session, item):
return item
@@ -1278,4 +1278,4 @@
item_list.append(str(item.name))
item_list.sort()
- return item_list
\ No newline at end of file
+ return item_list
Modified: trunk/cumin/python/cumin/main.py
===================================================================
--- trunk/cumin/python/cumin/main.py 2012-02-13 16:26:26 UTC (rev 5217)
+++ trunk/cumin/python/cumin/main.py 2012-02-13 21:32:10 UTC (rev 5218)
@@ -645,8 +645,8 @@
submission = self.cls.get_object_by_id(session.cursor, submission_id)
cls = self.app.model.com_redhat_grid.JobServer
return cls.get_object_by_id(session.cursor, submission._jobserverRef_id)
- except Exception, e:
- log.exception(e)
+ except:
+ log.debug("Getting job server failed", exc_info=True)
class NameColumn(ObjectLinkColumn):
def render_cell_href(self, session, record):
Modified: trunk/cumin/python/cumin/messaging/binding.py
===================================================================
--- trunk/cumin/python/cumin/messaging/binding.py 2012-02-13 16:26:26 UTC (rev 5217)
+++ trunk/cumin/python/cumin/messaging/binding.py 2012-02-13 21:32:10 UTC (rev 5218)
@@ -40,7 +40,7 @@
except Exception, e:
invoc.status = "failed"
invoc.exception = e
- log.exception(e)
+ log.debug("Binding removal failed", exc_info=True)
if queue and exchange:
session = self.app.model.get_session_by_object(binding)
@@ -110,7 +110,7 @@
except Exception, e:
invoc.status = "failed"
invoc.exception = e
- log.exception(e)
+ log.debug("Binding removal failed", exc_info=True)
if queue and exchange:
session = self.app.model.get_session_by_object(binding)
Modified: trunk/cumin/python/cumin/model.py
===================================================================
--- trunk/cumin/python/cumin/model.py 2012-02-13 16:26:26 UTC (rev 5217)
+++ trunk/cumin/python/cumin/model.py 2012-02-13 21:32:10 UTC (rev 5218)
@@ -668,7 +668,7 @@
remote.get_raw_config(negotiator, prepend+group, sync.get_completion())
except Exception, e:
sync.error = e
- log.exception(e)
+ log.debug("Fetch raw config failed", exc_info=True)
return self.syncs.do_wait()
class Pool(object):
@@ -728,7 +728,7 @@
self.store.update(cursor)
self.store.exception = None
except Exception, e:
- log.exception(e)
+ log.debug("Object store update failed", exc_info=True)
self.store.exception = e
self.ticks += 1
Modified: trunk/cumin/python/cumin/objecttask.py
===================================================================
--- trunk/cumin/python/cumin/objecttask.py 2012-02-13 16:26:26 UTC (rev 5217)
+++ trunk/cumin/python/cumin/objecttask.py 2012-02-13 21:32:10 UTC (rev 5218)
@@ -99,7 +99,7 @@
invoc.update_time = now
invoc.exception = e
- log.exception(e)
+ log.debug("Exception during task invocation", exc_info=True)
def __str__(self):
return "%s.%s" % (self.__module__, self.__class__.__name__)
Modified: trunk/cumin/python/cumin/qmfadapter.py
===================================================================
--- trunk/cumin/python/cumin/qmfadapter.py 2012-02-13 16:26:26 UTC (rev 5217)
+++ trunk/cumin/python/cumin/qmfadapter.py 2012-02-13 21:32:10 UTC (rev 5218)
@@ -88,8 +88,8 @@
filtered = [x for x in rows
if compare in x[index]]
rows = filtered
- except Exception, e:
- log.exception(e)
+ except:
+ log.debug("Filtering rows failed", exc_info=True)
return rows
Modified: trunk/cumin/python/cumin/task.py
===================================================================
--- trunk/cumin/python/cumin/task.py 2012-02-13 16:26:26 UTC (rev 5217)
+++ trunk/cumin/python/cumin/task.py 2012-02-13 21:32:10 UTC (rev 5218)
@@ -108,7 +108,7 @@
invoc.update_time = now
invoc.exception = e
- log.exception(e)
+ log.debug("Exception during task invocation", exc_info=True)
def __str__(self):
return "%s.%s" % (self.__module__, self.__class__.__name__)
Modified: trunk/mint/python/mint/update.py
===================================================================
--- trunk/mint/python/mint/update.py 2012-02-13 16:26:26 UTC (rev 5217)
+++ trunk/mint/python/mint/update.py 2012-02-13 21:32:10 UTC (rev 5218)
@@ -217,7 +217,7 @@
thread.stats.dropped += 1
except:
- log.exception("Update failed")
+ log.debug("Update failed", exc_info=True)
thread.conn.rollback()
@@ -551,8 +551,8 @@
try:
cursor.execute(text, args)
except:
- log.exception("%s failed", self)
-
+ log.debug("%s failed sql execute", self, exc_info=True)
+ log.error("Sql execute failed")
log.error("Sql text: %s", text)
log.error("Sql values:")
Modified: trunk/mint/python/mint/util.py
===================================================================
--- trunk/mint/python/mint/util.py 2012-02-13 16:26:26 UTC (rev 5217)
+++ trunk/mint/python/mint/util.py 2012-02-13 21:32:10 UTC (rev 5218)
@@ -50,11 +50,11 @@
def run(self):
while True:
start = time.time()
-
try:
self.process()
except:
- log.exception("Periodic process failed")
+ log.info("Periodic process failed.")
+ log.debug("Periodic process failed", exc_info=True)
elapsed = time.time() - start
delta = self.interval - elapsed
Modified: trunk/rosemary/python/rosemary/sqloperation.py
===================================================================
--- trunk/rosemary/python/rosemary/sqloperation.py 2012-02-13 16:26:26 UTC (rev 5217)
+++ trunk/rosemary/python/rosemary/sqloperation.py 2012-02-13 21:32:10 UTC (rev 5218)
@@ -27,7 +27,7 @@
try:
cursor.execute(text, values)
except:
- log.exception("%s failed", self)
+ log.debug("%s failed", self, exc_info=True)
self.log_sql(cursor, text, values)
Modified: trunk/sage/python/sage/qmf/qmfoperations.py
===================================================================
--- trunk/sage/python/sage/qmf/qmfoperations.py 2012-02-13 16:26:26 UTC (rev 5217)
+++ trunk/sage/python/sage/qmf/qmfoperations.py 2012-02-13 21:32:10 UTC (rev 5218)
@@ -241,7 +241,7 @@
obj, meth, args)
except Exception, e:
sync.error = e
- log.exception(e)
+ log.debug("QMF method call exception", exc_info=True)
wait(sync.done, timeout=tout)
if not sync.got_data and not sync.error:
12 years, 2 months
r5217 - in trunk/cumin/bin: . test
by tmckay@fedoraproject.org
Author: tmckay
Date: 2012-02-13 16:26:26 +0000 (Mon, 13 Feb 2012)
New Revision: 5217
Added:
trunk/cumin/bin/test/
trunk/cumin/bin/test/cumin-admin-test
trunk/cumin/bin/test/cumin-bench
trunk/cumin/bin/test/cumin-command-test
trunk/cumin/bin/test/cumin-data-test
trunk/cumin/bin/test/cumin-smoke-test
trunk/cumin/bin/test/cumin-test
trunk/cumin/bin/test/cumin-web-test
Removed:
trunk/cumin/bin/cumin-admin-test
trunk/cumin/bin/cumin-bench
trunk/cumin/bin/cumin-command-test
trunk/cumin/bin/cumin-data-test
trunk/cumin/bin/cumin-smoke-test
trunk/cumin/bin/cumin-test
trunk/cumin/bin/cumin-web-test
Log:
Move test programs into subdirectory to facility removing them from install.
BZ767232
Deleted: trunk/cumin/bin/cumin-admin-test
===================================================================
--- trunk/cumin/bin/cumin-admin-test 2012-02-10 18:52:28 UTC (rev 5216)
+++ trunk/cumin/bin/cumin-admin-test 2012-02-13 16:26:26 UTC (rev 5217)
@@ -1,14 +0,0 @@
-#!/bin/bash -e
-
-id="test_${RANDOM}"
-opts="--debug"
-
-cumin-command-test <<EOF
-cumin-admin $opts --help
-cumin-admin $opts add-user "$id" changeme
-cumin-admin $opts add-assignment "$id" admin
-cumin-admin $opts list-users
-cumin-admin $opts list-roles
-cumin-admin $opts remove-assignment "$id" admin
-cumin-admin $opts remove-user "$id"
-EOF
Deleted: trunk/cumin/bin/cumin-bench
===================================================================
--- trunk/cumin/bin/cumin-bench 2012-02-10 18:52:28 UTC (rev 5216)
+++ trunk/cumin/bin/cumin-bench 2012-02-13 16:26:26 UTC (rev 5217)
@@ -1,116 +0,0 @@
-#!/usr/bin/python
-
-import sys
-
-from wooly.bench import BenchmarkHarness
-
-from cumin import Cumin
-from cumin.config import *
-
-def do_main():
- setup_initial_logging()
-
- parser = CuminOptionParser()
-
- # Add additional parameters
- # We need --profile here to keep optparse from crashing in
- # a profile case
- parser.add_option("--profile", action="store_true")
- parser.add_option("--host", type=str)
- parser.add_option("--port", type=int)
- parser.add_option("--section", default="web")
-
- # Get options
- opts, args = parser.parse_args()
-
- # --section controls which section is read from the config file
- # If a section other than "web" is specified, require it to exist
- config = CuminWebConfig(opts.section, strict_section = opts.section != "web")
-
- # There might be other sections returned from config.parse() but
- # currently we don't care about them...
- values = getattr(config.parse(), opts.section)
-
- # Use the config values as defaults for unspecified options
- apply_defaults(values, opts)
-
- setup_operational_logging(opts,
- values.log_max_mb,
- values.log_max_archives)
-
- broker_uris = [x.strip() for x in opts.brokers.split(",")]
-
- cumin = Cumin(config.get_home(), broker_uris,
- opts.database, opts.host, opts.port)
-
- cumin.debug = True
- cumin.user = values.user
- cumin.update_interval = values.update_interval
-
- cumin.check()
- cumin.init()
-
- cumin.session.start()
-
- harness = BenchmarkHarness(cumin)
- harness.continue_on_error = True
- harness.check_output = False
- harness.print_output = False
-
- try:
- harness.run(1000)
- finally:
- cumin.stop()
-
-def main():
- if "--profile" in sys.argv:
- from profile import Profile
- from pstats import Stats
-
- prof = Profile()
-
- print "Calibrating"
-
- biases = list()
-
- for i in range(5):
- bias = prof.calibrate(100000)
- biases.append(bias)
- print i, bias
-
- prof.bias = sum(biases) / float(5)
-
- print "Using bias %f" % prof.bias
-
- try:
- statement = "do_main()"
- prof.run(statement)
-
- raise KeyboardInterrupt()
- except KeyboardInterrupt:
- file = "/tmp/cumin-test-stats"
-
- prof.dump_stats(file)
-
- stats = Stats(file)
-
- stats.sort_stats("cumulative").print_stats(15)
- stats.sort_stats("time").print_stats(15)
-
- stats.print_callees("wooly/__init__.*\\(marshal_url_vars\\)")
- stats.print_callees("wooly/__init__.*\\(path\\)")
- stats.print_callees("wooly/__init__.*\\(get\\)")
- stats.print_callees("wooly/__init__.*\\(render\\)")
-
- stats.strip_dirs()
- else:
- do_main()
-
-if __name__ == "__main__":
- try:
- main()
- except KeyboardInterrupt:
- pass
-
- #from parsley import threadingex
- #threadingex.print_threads()
Deleted: trunk/cumin/bin/cumin-command-test
===================================================================
--- trunk/cumin/bin/cumin-command-test 2012-02-10 18:52:28 UTC (rev 5216)
+++ trunk/cumin/bin/cumin-command-test 2012-02-13 16:26:26 UTC (rev 5217)
@@ -1,31 +0,0 @@
-#!/bin/bash -e
-
-code=0
-tmpdir=$(mktemp -d)
-
-trap "rm -rf ${tmpdir}" EXIT
-
-while read command; do
- notice="Testing '$command' "
-
- echo -n "$notice"
-
- len=$((76 - ${#notice}))
-
- for ((i = 0; i < $len; i += 1)); do
- echo -n "."
- done
-
- if $command &> "${tmpdir}/output"; then
- echo " OK"
- else
- echo
- echo "Command failed:"
-
- cat "${tmpdir}/output"
-
- code=1
- fi
-done
-
-exit "$code"
\ No newline at end of file
Deleted: trunk/cumin/bin/cumin-data-test
===================================================================
--- trunk/cumin/bin/cumin-data-test 2012-02-10 18:52:28 UTC (rev 5216)
+++ trunk/cumin/bin/cumin-data-test 2012-02-13 16:26:26 UTC (rev 5217)
@@ -1,8 +0,0 @@
-#!/bin/bash -e
-
-opts="--debug --init-only"
-
-cumin-command-test <<EOF
-cumin-data $opts --help
-cumin-data $opts
-EOF
Deleted: trunk/cumin/bin/cumin-smoke-test
===================================================================
--- trunk/cumin/bin/cumin-smoke-test 2012-02-10 18:52:28 UTC (rev 5216)
+++ trunk/cumin/bin/cumin-smoke-test 2012-02-13 16:26:26 UTC (rev 5217)
@@ -1,140 +0,0 @@
-#!/usr/bin/python
-
-import os
-import sys
-
-from threading import Event
-
-home = os.environ.get("CUMIN_HOME", os.path.normpath("/usr/share/cumin"))
-sys.path.append(os.path.join(home, "python"))
-
-from cumin import *
-from cumin.config import *
-from cumin.util import *
-
-def main():
- setup_initial_logging()
-
- parser = CuminOptionParser()
-
- # Add additional parameters for web
- parser.add_option("--host")
- parser.add_option("--port", type=int)
- parser.add_option("--section", default="web")
-
- # Get options
- opts, args = parser.parse_args()
-
- # --section controls which section is read from the config file
- # If a section other than "web" is specified, require it to exist
- config = CuminWebConfig(opts.section, strict_section = opts.section != "web")
-
- # There might be other sections returned from config.parse() but
- # currently we don't care about them...
- values = getattr(config.parse(), opts.section)
-
- # Use the config values as defaults for unspecified options
- apply_defaults(values, opts)
-
- setup_operational_logging(opts,
- values.log_max_mb,
- values.log_max_archives)
-
- broker_uris = [x.strip() for x in opts.brokers.split(",")]
-
- cumin = Cumin(config.get_home(), broker_uris, opts.database,
- opts.host, opts.port)
-
- cumin.user = values.user
-
- cumin.check()
- cumin.init()
-
- if opts.init_only:
- return
-
- cumin.start()
-
- sleep(2)
-
- try:
- conn = cumin.database.get_connection()
- cursor = conn.cursor()
-
- def invoke_test(test):
- print "[%s]" % name[6:]
-
- try:
- test(cumin, cursor)
- except:
- print_exc()
-
- print "FAILES!"
-
- try:
- chosen = sys.argv[1]
- except IndexError:
- chosen = None
-
- attrs = globals()
-
- if chosen:
- name = "_test_%s" % chosen
-
- assert name in attrs
-
- invoke_test(attrs[name])
- else:
- for name in [x for x in attrs if x.startswith("_test")]:
- invoke_test(attrs[name])
- finally:
- cumin.stop()
-
-def _test_submit(cumin, cursor):
- cls = cumin.model.com_redhat_grid.Scheduler
- obj = cls.get_object(cursor)
-
- assert obj
-
- print "Submitting to", obj.Name,
-
- ad = {"Cmd": "/bin/sleep",
- "Args": "5m",
- "JobUniverse": 5,
- "Requirements": "TRUE",
- "Iwd": "/tmp",
- "Owner": "gridmonkey",
- "!!descriptors": {"Requirements": "com.redhat.grid.Expression"}}
-
- completed = Event()
-
- def completion(x, y):
- print "-> [%s, %s]" % (x, y)
-
- completed.set()
-
- cumin.session.call_method(completion, obj, "SubmitJob", (ad,))
-
- completed.wait(30)
-
-def _test_job_summaries(cumin, cursor):
- cls = cumin.model.com_redhat_grid.Submission
- obj = cls.get_object(cursor)
-
- print "Getting job summaries for", obj,
-
- assert obj
-
- summs = cumin.model.get_submission_job_summaries(obj)
-
- assert summs is not None
-
- print "-> [%i job summaries]" % len(summs)
-
- #pprint(summs)
-
-if __name__ == "__main__":
- try:
- main()
- except KeyboardInterrupt:
- pass
Deleted: trunk/cumin/bin/cumin-test
===================================================================
--- trunk/cumin/bin/cumin-test 2012-02-10 18:52:28 UTC (rev 5216)
+++ trunk/cumin/bin/cumin-test 2012-02-13 16:26:26 UTC (rev 5217)
@@ -1,27 +0,0 @@
-#!/usr/bin/python
-
-import os
-import sys
-
-home = os.environ.get("CUMIN_HOME", os.path.normpath("/usr/share/cumin"))
-sys.path.append(os.path.join(home, "python"))
-
-from cumin.config import *
-
-def main():
- setup_initial_logging()
-
- config = CuminConfig()
- values = config.parse()
-
- parser = CuminOptionParser(values.test)
-
- opts, args = parser.parse_args()
-
- setup_operational_logging(opts)
-
-if __name__ == "__main__":
- try:
- main()
- except KeyboardInterrupt:
- pass
Deleted: trunk/cumin/bin/cumin-web-test
===================================================================
--- trunk/cumin/bin/cumin-web-test 2012-02-10 18:52:28 UTC (rev 5216)
+++ trunk/cumin/bin/cumin-web-test 2012-02-13 16:26:26 UTC (rev 5217)
@@ -1,9 +0,0 @@
-#!/bin/bash -e
-
-opts="--debug --init-only"
-
-cumin-command-test <<EOF
-cumin-web $opts --help
-cumin-web $opts --host example.com
-cumin-web $opts --port 27654
-EOF
Copied: trunk/cumin/bin/test/cumin-admin-test (from rev 5216, trunk/cumin/bin/cumin-admin-test)
===================================================================
--- trunk/cumin/bin/test/cumin-admin-test (rev 0)
+++ trunk/cumin/bin/test/cumin-admin-test 2012-02-13 16:26:26 UTC (rev 5217)
@@ -0,0 +1,14 @@
+#!/bin/bash -e
+
+id="test_${RANDOM}"
+opts="--debug"
+
+cumin-command-test <<EOF
+cumin-admin $opts --help
+cumin-admin $opts add-user "$id" changeme
+cumin-admin $opts add-assignment "$id" admin
+cumin-admin $opts list-users
+cumin-admin $opts list-roles
+cumin-admin $opts remove-assignment "$id" admin
+cumin-admin $opts remove-user "$id"
+EOF
Copied: trunk/cumin/bin/test/cumin-bench (from rev 5216, trunk/cumin/bin/cumin-bench)
===================================================================
--- trunk/cumin/bin/test/cumin-bench (rev 0)
+++ trunk/cumin/bin/test/cumin-bench 2012-02-13 16:26:26 UTC (rev 5217)
@@ -0,0 +1,116 @@
+#!/usr/bin/python
+
+import sys
+
+from wooly.bench import BenchmarkHarness
+
+from cumin import Cumin
+from cumin.config import *
+
+def do_main():
+ setup_initial_logging()
+
+ parser = CuminOptionParser()
+
+ # Add additional parameters
+ # We need --profile here to keep optparse from crashing in
+ # a profile case
+ parser.add_option("--profile", action="store_true")
+ parser.add_option("--host", type=str)
+ parser.add_option("--port", type=int)
+ parser.add_option("--section", default="web")
+
+ # Get options
+ opts, args = parser.parse_args()
+
+ # --section controls which section is read from the config file
+ # If a section other than "web" is specified, require it to exist
+ config = CuminWebConfig(opts.section, strict_section = opts.section != "web")
+
+ # There might be other sections returned from config.parse() but
+ # currently we don't care about them...
+ values = getattr(config.parse(), opts.section)
+
+ # Use the config values as defaults for unspecified options
+ apply_defaults(values, opts)
+
+ setup_operational_logging(opts,
+ values.log_max_mb,
+ values.log_max_archives)
+
+ broker_uris = [x.strip() for x in opts.brokers.split(",")]
+
+ cumin = Cumin(config.get_home(), broker_uris,
+ opts.database, opts.host, opts.port)
+
+ cumin.debug = True
+ cumin.user = values.user
+ cumin.update_interval = values.update_interval
+
+ cumin.check()
+ cumin.init()
+
+ cumin.session.start()
+
+ harness = BenchmarkHarness(cumin)
+ harness.continue_on_error = True
+ harness.check_output = False
+ harness.print_output = False
+
+ try:
+ harness.run(1000)
+ finally:
+ cumin.stop()
+
+def main():
+ if "--profile" in sys.argv:
+ from profile import Profile
+ from pstats import Stats
+
+ prof = Profile()
+
+ print "Calibrating"
+
+ biases = list()
+
+ for i in range(5):
+ bias = prof.calibrate(100000)
+ biases.append(bias)
+ print i, bias
+
+ prof.bias = sum(biases) / float(5)
+
+ print "Using bias %f" % prof.bias
+
+ try:
+ statement = "do_main()"
+ prof.run(statement)
+
+ raise KeyboardInterrupt()
+ except KeyboardInterrupt:
+ file = "/tmp/cumin-test-stats"
+
+ prof.dump_stats(file)
+
+ stats = Stats(file)
+
+ stats.sort_stats("cumulative").print_stats(15)
+ stats.sort_stats("time").print_stats(15)
+
+ stats.print_callees("wooly/__init__.*\\(marshal_url_vars\\)")
+ stats.print_callees("wooly/__init__.*\\(path\\)")
+ stats.print_callees("wooly/__init__.*\\(get\\)")
+ stats.print_callees("wooly/__init__.*\\(render\\)")
+
+ stats.strip_dirs()
+ else:
+ do_main()
+
+if __name__ == "__main__":
+ try:
+ main()
+ except KeyboardInterrupt:
+ pass
+
+ #from parsley import threadingex
+ #threadingex.print_threads()
Copied: trunk/cumin/bin/test/cumin-command-test (from rev 5216, trunk/cumin/bin/cumin-command-test)
===================================================================
--- trunk/cumin/bin/test/cumin-command-test (rev 0)
+++ trunk/cumin/bin/test/cumin-command-test 2012-02-13 16:26:26 UTC (rev 5217)
@@ -0,0 +1,31 @@
+#!/bin/bash -e
+
+code=0
+tmpdir=$(mktemp -d)
+
+trap "rm -rf ${tmpdir}" EXIT
+
+while read command; do
+ notice="Testing '$command' "
+
+ echo -n "$notice"
+
+ len=$((76 - ${#notice}))
+
+ for ((i = 0; i < $len; i += 1)); do
+ echo -n "."
+ done
+
+ if $command &> "${tmpdir}/output"; then
+ echo " OK"
+ else
+ echo
+ echo "Command failed:"
+
+ cat "${tmpdir}/output"
+
+ code=1
+ fi
+done
+
+exit "$code"
\ No newline at end of file
Copied: trunk/cumin/bin/test/cumin-data-test (from rev 5216, trunk/cumin/bin/cumin-data-test)
===================================================================
--- trunk/cumin/bin/test/cumin-data-test (rev 0)
+++ trunk/cumin/bin/test/cumin-data-test 2012-02-13 16:26:26 UTC (rev 5217)
@@ -0,0 +1,8 @@
+#!/bin/bash -e
+
+opts="--debug --init-only"
+
+cumin-command-test <<EOF
+cumin-data $opts --help
+cumin-data $opts
+EOF
Copied: trunk/cumin/bin/test/cumin-smoke-test (from rev 5216, trunk/cumin/bin/cumin-smoke-test)
===================================================================
--- trunk/cumin/bin/test/cumin-smoke-test (rev 0)
+++ trunk/cumin/bin/test/cumin-smoke-test 2012-02-13 16:26:26 UTC (rev 5217)
@@ -0,0 +1,140 @@
+#!/usr/bin/python
+
+import os
+import sys
+
+from threading import Event
+
+home = os.environ.get("CUMIN_HOME", os.path.normpath("/usr/share/cumin"))
+sys.path.append(os.path.join(home, "python"))
+
+from cumin import *
+from cumin.config import *
+from cumin.util import *
+
+def main():
+ setup_initial_logging()
+
+ parser = CuminOptionParser()
+
+ # Add additional parameters for web
+ parser.add_option("--host")
+ parser.add_option("--port", type=int)
+ parser.add_option("--section", default="web")
+
+ # Get options
+ opts, args = parser.parse_args()
+
+ # --section controls which section is read from the config file
+ # If a section other than "web" is specified, require it to exist
+ config = CuminWebConfig(opts.section, strict_section = opts.section != "web")
+
+ # There might be other sections returned from config.parse() but
+ # currently we don't care about them...
+ values = getattr(config.parse(), opts.section)
+
+ # Use the config values as defaults for unspecified options
+ apply_defaults(values, opts)
+
+ setup_operational_logging(opts,
+ values.log_max_mb,
+ values.log_max_archives)
+
+ broker_uris = [x.strip() for x in opts.brokers.split(",")]
+
+ cumin = Cumin(config.get_home(), broker_uris, opts.database,
+ opts.host, opts.port)
+
+ cumin.user = values.user
+
+ cumin.check()
+ cumin.init()
+
+ if opts.init_only:
+ return
+
+ cumin.start()
+
+ sleep(2)
+
+ try:
+ conn = cumin.database.get_connection()
+ cursor = conn.cursor()
+
+ def invoke_test(test):
+ print "[%s]" % name[6:]
+
+ try:
+ test(cumin, cursor)
+ except:
+ print_exc()
+
+ print "FAILES!"
+
+ try:
+ chosen = sys.argv[1]
+ except IndexError:
+ chosen = None
+
+ attrs = globals()
+
+ if chosen:
+ name = "_test_%s" % chosen
+
+ assert name in attrs
+
+ invoke_test(attrs[name])
+ else:
+ for name in [x for x in attrs if x.startswith("_test")]:
+ invoke_test(attrs[name])
+ finally:
+ cumin.stop()
+
+def _test_submit(cumin, cursor):
+ cls = cumin.model.com_redhat_grid.Scheduler
+ obj = cls.get_object(cursor)
+
+ assert obj
+
+ print "Submitting to", obj.Name,
+
+ ad = {"Cmd": "/bin/sleep",
+ "Args": "5m",
+ "JobUniverse": 5,
+ "Requirements": "TRUE",
+ "Iwd": "/tmp",
+ "Owner": "gridmonkey",
+ "!!descriptors": {"Requirements": "com.redhat.grid.Expression"}}
+
+ completed = Event()
+
+ def completion(x, y):
+ print "-> [%s, %s]" % (x, y)
+
+ completed.set()
+
+ cumin.session.call_method(completion, obj, "SubmitJob", (ad,))
+
+ completed.wait(30)
+
+def _test_job_summaries(cumin, cursor):
+ cls = cumin.model.com_redhat_grid.Submission
+ obj = cls.get_object(cursor)
+
+ print "Getting job summaries for", obj,
+
+ assert obj
+
+ summs = cumin.model.get_submission_job_summaries(obj)
+
+ assert summs is not None
+
+ print "-> [%i job summaries]" % len(summs)
+
+ #pprint(summs)
+
+if __name__ == "__main__":
+ try:
+ main()
+ except KeyboardInterrupt:
+ pass
Copied: trunk/cumin/bin/test/cumin-test (from rev 5216, trunk/cumin/bin/cumin-test)
===================================================================
--- trunk/cumin/bin/test/cumin-test (rev 0)
+++ trunk/cumin/bin/test/cumin-test 2012-02-13 16:26:26 UTC (rev 5217)
@@ -0,0 +1,27 @@
+#!/usr/bin/python
+
+import os
+import sys
+
+home = os.environ.get("CUMIN_HOME", os.path.normpath("/usr/share/cumin"))
+sys.path.append(os.path.join(home, "python"))
+
+from cumin.config import *
+
+def main():
+ setup_initial_logging()
+
+ config = CuminConfig()
+ values = config.parse()
+
+ parser = CuminOptionParser(values.test)
+
+ opts, args = parser.parse_args()
+
+ setup_operational_logging(opts)
+
+if __name__ == "__main__":
+ try:
+ main()
+ except KeyboardInterrupt:
+ pass
Copied: trunk/cumin/bin/test/cumin-web-test (from rev 5216, trunk/cumin/bin/cumin-web-test)
===================================================================
--- trunk/cumin/bin/test/cumin-web-test (rev 0)
+++ trunk/cumin/bin/test/cumin-web-test 2012-02-13 16:26:26 UTC (rev 5217)
@@ -0,0 +1,9 @@
+#!/bin/bash -e
+
+opts="--debug --init-only"
+
+cumin-command-test <<EOF
+cumin-web $opts --help
+cumin-web $opts --host example.com
+cumin-web $opts --port 27654
+EOF
12 years, 2 months
r5216 - in trunk: cumin/python/cumin wooly/python/wooly
by tmckay@fedoraproject.org
Author: tmckay
Date: 2012-02-10 18:52:28 +0000 (Fri, 10 Feb 2012)
New Revision: 5216
Modified:
trunk/cumin/python/cumin/widgets.py
trunk/wooly/python/wooly/__init__.py
trunk/wooly/python/wooly/server.py
Log:
Exception handling for redirect must be compatible with Python 2.4
Modified: trunk/cumin/python/cumin/widgets.py
===================================================================
--- trunk/cumin/python/cumin/widgets.py 2012-02-10 17:50:38 UTC (rev 5215)
+++ trunk/cumin/python/cumin/widgets.py 2012-02-10 18:52:28 UTC (rev 5216)
@@ -1328,12 +1328,13 @@
return False
- def redirect_on_exception(self, session, e):
+ def redirect_on_exception(self, session):
# If we have an exception from a missing object, redirect to the
# main page with a notice instead of using the not_found_tmpl below.
# Test for presence on the index.html page already to avoid any possibility
# of an infinite redirect loop.
- if type(e) is RosemaryNotFound and \
+ cls, value, traceback = sys.exc_info()
+ if cls is RosemaryNotFound and \
session.request_environment["REQUEST_URI"] != "/index.html":
session.add_notice(Notice("An object being displayed became unavailable"))
Modified: trunk/wooly/python/wooly/__init__.py
===================================================================
--- trunk/wooly/python/wooly/__init__.py 2012-02-10 17:50:38 UTC (rev 5215)
+++ trunk/wooly/python/wooly/__init__.py 2012-02-10 18:52:28 UTC (rev 5216)
@@ -482,7 +482,7 @@
return self.render(session)
- def redirect_on_exception(self, session, e):
+ def redirect_on_exception(self, session):
return None
def service_error(self, session):
Modified: trunk/wooly/python/wooly/server.py
===================================================================
--- trunk/wooly/python/wooly/server.py 2012-02-10 17:50:38 UTC (rev 5215)
+++ trunk/wooly/python/wooly/server.py 2012-02-10 18:52:28 UTC (rev 5216)
@@ -126,14 +126,14 @@
except PageRedirect:
status = "303 See Other"
headers.append(("Location", page.redirect.get(session)))
- except UpdateRedirect as e:
+ except UpdateRedirect, e:
# This will optionally allow a failed ajax update to
# process a location change. Javascript code in the
# update handler will look for the header.
status = "200 OK"
headers.append(("Location", e.url))
- except Exception as e:
- url = page.redirect_on_exception(session, e)
+ except:
+ url = page.redirect_on_exception(session)
if url:
status = "303 See Other"
headers.append(("Location", url))
12 years, 2 months
r5214 - trunk/cumin/python/cumin
by tmckay@fedoraproject.org
Author: tmckay
Date: 2012-02-10 17:16:46 +0000 (Fri, 10 Feb 2012)
New Revision: 5214
Modified:
trunk/cumin/python/cumin/widgets.py
Log:
Add a check for "/index.html" on redirect to front page to avoid
any possibility of an infinite redirect loop
Modified: trunk/cumin/python/cumin/widgets.py
===================================================================
--- trunk/cumin/python/cumin/widgets.py 2012-02-10 16:24:34 UTC (rev 5213)
+++ trunk/cumin/python/cumin/widgets.py 2012-02-10 17:16:46 UTC (rev 5214)
@@ -1331,10 +1331,14 @@
def redirect_on_exception(self, session, e):
# If we have an exception from a missing object, redirect to the
- # main page with a notice instead of using the not_found_tmpl below
- if type(e) is RosemaryNotFound:
+ # main page with a notice instead of using the not_found_tmpl below.
+ # Test for presence on the index.html page already to avoid any possibility
+ # of an infinite redirect loop.
+ if type(e) is RosemaryNotFound and \
+ session.request_environment["REQUEST_URI"] != "/index.html":
+
session.add_notice(Notice("An object being displayed became unavailable"))
- return "index.html"
+ return "/index.html"
def render_error(self, session):
cls, value, traceback = sys.exc_info()
12 years, 2 months
r5213 - trunk/cumin/python/cumin
by tmckay@fedoraproject.org
Author: tmckay
Date: 2012-02-10 16:24:34 +0000 (Fri, 10 Feb 2012)
New Revision: 5213
Modified:
trunk/cumin/python/cumin/widgets.strings
Log:
Remove dead templates found during refactoring.
CuminSummary and SummaryProperties are not referenced currently.
Modified: trunk/cumin/python/cumin/widgets.strings
===================================================================
--- trunk/cumin/python/cumin/widgets.strings 2012-02-10 16:17:35 UTC (rev 5212)
+++ trunk/cumin/python/cumin/widgets.strings 2012-02-10 16:24:34 UTC (rev 5213)
@@ -373,74 +373,6 @@
{title}
</h1>
-[CuminSummary.css]
-div.CuminSummary {
- width: 50em;
- margin: 0 0 2em 0;
- min-height: 6em;
-}
-
-div.CuminSummary h1 {
- font-size: 1.1em;
- margin: 0;
-}
-
-div.CuminSummary h1 img {
- vertical-align: -60%;
- margin: 0 0.25em 0 0;
-}
-
-div.CuminSummary hr {
- margin: 0.65em 0;
- border: 0;
- border-top: 1px dotted #ccc;
- padding: 0;
-}
-
-div.CuminSummary div.tasks {
- font-size: 0.9em;
- width: 20em;
- float: right;
-}
-
-div.CuminSummary div.properties {
- font-size: 0.9em;
-}
-
-[CuminSummary.html]
-<div class="CuminSummary">
- <h1>
- <img src="{icon_href}" alt="summary" />
- {title}
- </h1>
-
- <hr/>
-
- <div class="tasks">
- {tasks}
- </div>
-
- <div class="properties">
- {properties}
- </div>
-</div>
-
-[SummaryProperties.css]
-table.SummaryProperties th {
- color: #444;
- font-weight: normal;
- padding: 0 0.5em 0 0;
- text-align: left;
-}
-
-[SummaryProperties.html]
-<table class="SummaryProperties">
- <tbody>{items}</tbody>
-</table>
-
-[SummaryProperties.property_html]
-<tr><th>{title}</th><td>{value}</td></tr>
-
[StateSwitch.html]
<ul class="radiotabs">
{items}
12 years, 2 months
r5212 - in trunk: cumin/python/cumin cumin/python/cumin/account cumin/python/cumin/grid wooly/python/wooly
by tmckay@fedoraproject.org
Author: tmckay
Date: 2012-02-10 16:17:35 +0000 (Fri, 10 Feb 2012)
New Revision: 5212
Modified:
trunk/cumin/python/cumin/account/widgets.py
trunk/cumin/python/cumin/grid/job.py
trunk/cumin/python/cumin/grid/job.strings
trunk/cumin/python/cumin/grid/pool.strings
trunk/cumin/python/cumin/objectselector.strings
trunk/cumin/python/cumin/task.py
trunk/cumin/python/cumin/task.strings
trunk/cumin/python/cumin/widgets.py
trunk/cumin/python/cumin/widgets.strings
trunk/wooly/python/wooly/__init__.py
trunk/wooly/python/wooly/__init__.strings
Log:
Refactoring after the extension of the TaskInvocationSet mechanism to
allow general notices.
* Change names "TaskInvocationXXX" to "NotificationXXX" to reflect generality
* Change related method names
* Move classes out of task.py into cumin/widgets.py.
Modified: trunk/cumin/python/cumin/account/widgets.py
===================================================================
--- trunk/cumin/python/cumin/account/widgets.py 2012-02-09 21:04:31 UTC (rev 5211)
+++ trunk/cumin/python/cumin/account/widgets.py 2012-02-10 16:17:35 UTC (rev 5212)
@@ -216,8 +216,9 @@
if not self.errors.get(session):
# Just use a notice here to spoof a task completion.
- session.add_notice(preamble="Password changed", message="OK",
- capitalize=False)
+ session.add_notice(Notice(preamble="Password changed",
+ message="OK",
+ capitalize=False))
url = self.return_url.get(session)
self.page.redirect.set(session, url)
Modified: trunk/cumin/python/cumin/grid/job.py
===================================================================
--- trunk/cumin/python/cumin/grid/job.py 2012-02-09 21:04:31 UTC (rev 5211)
+++ trunk/cumin/python/cumin/grid/job.py 2012-02-10 16:17:35 UTC (rev 5212)
@@ -16,7 +16,7 @@
from wooly import Widget, Parameter, Attribute
from wooly.util import StringCatalog, Writer, escape_amp, escape_entity
from wooly.forms import Form, FormButton, StringField
-from wooly.widgets import ModeSet, PropertySet, TemplateRenderer
+from wooly.widgets import ModeSet, PropertySet, TemplateRenderer, Notice
from wooly.template import WidgetTemplate
from wooly.parameters import ListParameter, IntegerParameter, DictParameter
@@ -304,7 +304,7 @@
frame.view.show(nsession)
submission_list_url = nsession.marshal()
self.page.redirect.set(session, submission_list_url)
- session.add_notice("The submission being displayed became unavailable")
+ session.add_notice(Notice("The submission being displayed became unavailable"))
else:
return super(JobSelectorTable, self).do_render(session)
@@ -647,7 +647,7 @@
frame.view.show(nsession)
submission_list_url = nsession.marshal()
self.page.redirect.set(session, submission_list_url)
- session.add_notice("The submission being displayed became unavailable")
+ session.add_notice(Notice("The submission being displayed became unavailable"))
else:
return super(JobAdsViewer, self).do_render(session)
Modified: trunk/cumin/python/cumin/grid/job.strings
===================================================================
--- trunk/cumin/python/cumin/grid/job.strings 2012-02-09 21:04:31 UTC (rev 5211)
+++ trunk/cumin/python/cumin/grid/job.strings 2012-02-10 16:17:35 UTC (rev 5212)
@@ -55,7 +55,7 @@
</table>
[JobAdsGroups.error_html]
-<div class="TaskInvocationSet">
+<div class="NotificationSet">
<ul>
<li>{error_msg}</li>
</ul>
@@ -171,7 +171,7 @@
[JobSelectorTable.error_html]
<div id="{id}">
- <div class="TaskInvocationSet">
+ <div class="NotificationSet">
<ul>
<li>{error_msg}</li>
</ul>
Modified: trunk/cumin/python/cumin/grid/pool.strings
===================================================================
--- trunk/cumin/python/cumin/grid/pool.strings 2012-02-09 21:04:31 UTC (rev 5211)
+++ trunk/cumin/python/cumin/grid/pool.strings 2012-02-10 16:17:35 UTC (rev 5212)
@@ -1,7 +1,7 @@
[PoolView.error_html]
<div id="{id}" class="{class}">
{heading}
- <div class="TaskInvocationSet">
+ <div class="NotificationSet">
<ul>
<li>
<b>Collector not found.</b>
Modified: trunk/cumin/python/cumin/objectselector.strings
===================================================================
--- trunk/cumin/python/cumin/objectselector.strings 2012-02-09 21:04:31 UTC (rev 5211)
+++ trunk/cumin/python/cumin/objectselector.strings 2012-02-10 16:17:35 UTC (rev 5212)
@@ -151,7 +151,7 @@
<div class="{class}"><span>Save to CSV file</span> <a href="{href}"><img src="resource?name=save.png" alt="save as csv" title="Save table as CSV file" valign="middle" border="0"/></a></div>
[ObjectQmfSelector.css]
-div.TaskInvocationSet ul {
+div.NotificationSet ul {
list-style-type: none;
}
@@ -178,7 +178,7 @@
[ObjectQmfSelector.error_html]
<div id="{id}">
- <div class="TaskInvocationSet">
+ <div class="NotificationSet">
<ul>
<li>{error_msg} {details}</li>
</ul>
Modified: trunk/cumin/python/cumin/task.py
===================================================================
--- trunk/cumin/python/cumin/task.py 2012-02-09 21:04:31 UTC (rev 5211)
+++ trunk/cumin/python/cumin/task.py 2012-02-10 16:17:35 UTC (rev 5212)
@@ -121,7 +121,7 @@
def __init__(self, task, session):
self.task = task
- session.add_task(self)
+ session.add_notice(self)
self.user = session.get_user()
@@ -226,81 +226,6 @@
self.end()
return completion
-class TaskInvocationSet(Widget):
- def __init__(self, app, name):
- super(TaskInvocationSet, self).__init__(app, name)
-
- self.update_enabled = True
-
- self.dismiss = IntegerParameter(app, "dismiss")
- self.add_parameter(self.dismiss)
-
- self.dismiss_all = BooleanParameter(app, "dismiss_all")
- self.add_parameter(self.dismiss_all)
-
- self.item_widget = TaskInvocationItem(app, "item")
- self.add_child(self.item_widget)
-
- def get_items(self, session):
- items = [x for x in session.get_task_invocations() if not x.dismissed]
- return items
-
- def do_process(self, session):
- super(TaskInvocationSet, self).do_process(session)
-
- dismiss = self.dismiss.get(session)
- dismiss_all = self.dismiss_all.get(session)
-
- if dismiss_all:
- for invoc in self.get_items(session):
- invoc.dismissed = True
-# We're leaking task invocations during the login session.
-# Replace the loop with the following at a later date
-# items[:] = []
- self.dismiss_all.set(session, self.dismiss_all.default)
-
- if dismiss:
- for invoc in self.get_items(session):
- if id(invoc) == dismiss:
- invoc.dismissed = True
- break
-# We're leaking task invocations during the login session.
-# Replace the loop with the following at a later date
-# items[:] = [x for x in items if id(x) != dismiss]
- self.dismiss.set(session, self.dismiss.default)
-
-
- def do_render(self, session):
- items = self.get_items(session)
-
- if items:
- return super(TaskInvocationSet, self).do_render(session)
-
- def render_items(self, session):
- writer = Writer()
-
- for item in self.get_items(session):
- writer.write(self.item_widget.render(session, item))
-
- return writer.to_string()
-
- def render_dismiss_all_href(self, session):
- branch = session.branch()
- self.dismiss_all.set(branch, True)
- return branch.marshal()
-
-class TaskInvocationItem(Widget):
- def render_icon_href(self, session, item):
- return "resource?name=add-20.png"
-
- def render_message(self, session, item):
- return item.get_message(session)
-
- def render_dismiss_href(self, session, item):
- branch = session.branch()
- self.parent.dismiss.set(branch, id(item))
- return branch.marshal()
-
class TaskLink(Link):
def __init__(self, app, name, task, object=None):
super(TaskLink, self).__init__(app, name)
Modified: trunk/cumin/python/cumin/task.strings
===================================================================
--- trunk/cumin/python/cumin/task.strings 2012-02-09 21:04:31 UTC (rev 5211)
+++ trunk/cumin/python/cumin/task.strings 2012-02-10 16:17:35 UTC (rev 5212)
@@ -1,35 +1,3 @@
-[TaskInvocationSet.css]
-div.TaskInvocationSet {
- background-color: #fe0;
- padding: 1em 2em;
- -moz-border-radius: 0.5em;
- -webkit-border-radius: 0.5em;
- margin: 0.5em auto 1em auto;
- width: 80%;
-}
-
-div.TaskInvocationSet ul {
- margin: 0;
- padding: 0 0 0 1em;
-}
-
-div.TaskInvocationSet a.dismiss {
- float: right;
- font-size: 0.9em;
-}
-
-[TaskInvocationSet.html]
-<div id="{id}" class="{class}">
- <a class="dismiss" href="{dismiss_all_href}">Dismiss all notifications</a><br/>
- <ul>{items}</ul>
-</div>
-
-[TaskInvocationItem.html]
-<li>
- <a class="dismiss" href="{dismiss_href}">Dismiss</a>
- {message}
-</li>
-
[SelectionList.css]
ul.SelectionList {
list-style: none;
Modified: trunk/cumin/python/cumin/widgets.py
===================================================================
--- trunk/cumin/python/cumin/widgets.py 2012-02-09 21:04:31 UTC (rev 5211)
+++ trunk/cumin/python/cumin/widgets.py 2012-02-10 16:17:35 UTC (rev 5212)
@@ -37,8 +37,8 @@
def __init__(self, app, name):
super(CuminMainView, self).__init__(app, name)
- self.tasks = TaskInvocationSet(app, "tasks")
- self.add_child(self.tasks)
+ self.notifications = NotificationSet(app, "notifications")
+ self.add_child(self.notifications)
self.heartbeat = CuminHeartBeat(app, "heartbeat")
self.add_child(self.heartbeat)
@@ -47,7 +47,7 @@
self.add_child(self.links)
def do_process(self, session, *args):
- self.tasks.process(session)
+ self.notifications.process(session)
self.heartbeat.process(session)
self.links.process(session)
@@ -1200,8 +1200,83 @@
self.created = datetime.now()
- self.task_invocations = list()
+ self.notifications = list()
+class NotificationSet(Widget):
+ def __init__(self, app, name):
+ super(NotificationSet, self).__init__(app, name)
+
+ self.update_enabled = True
+
+ self.dismiss = IntegerParameter(app, "dismiss")
+ self.add_parameter(self.dismiss)
+
+ self.dismiss_all = BooleanParameter(app, "dismiss_all")
+ self.add_parameter(self.dismiss_all)
+
+ self.item_widget = NotificationItem(app, "item")
+ self.add_child(self.item_widget)
+
+ def get_items(self, session):
+ items = [x for x in session.get_notifications() if not x.dismissed]
+ return items
+
+ def do_process(self, session):
+ super(NotificationSet, self).do_process(session)
+
+ dismiss = self.dismiss.get(session)
+ dismiss_all = self.dismiss_all.get(session)
+
+ if dismiss_all:
+ for invoc in self.get_items(session):
+ invoc.dismissed = True
+# We're leaking task invocations during the login session.
+# Replace the loop with the following at a later date
+# items[:] = []
+ self.dismiss_all.set(session, self.dismiss_all.default)
+
+ if dismiss:
+ for invoc in self.get_items(session):
+ if id(invoc) == dismiss:
+ invoc.dismissed = True
+ break
+# We're leaking task invocations during the login session.
+# Replace the loop with the following at a later date
+# items[:] = [x for x in items if id(x) != dismiss]
+ self.dismiss.set(session, self.dismiss.default)
+
+
+ def do_render(self, session):
+ items = self.get_items(session)
+
+ if items:
+ return super(NotificationSet, self).do_render(session)
+
+ def render_items(self, session):
+ writer = Writer()
+
+ for item in self.get_items(session):
+ writer.write(self.item_widget.render(session, item))
+
+ return writer.to_string()
+
+ def render_dismiss_all_href(self, session):
+ branch = session.branch()
+ self.dismiss_all.set(branch, True)
+ return branch.marshal()
+
+class NotificationItem(Widget):
+ def render_icon_href(self, session, item):
+ return "resource?name=add-20.png"
+
+ def render_message(self, session, item):
+ return item.get_message(session)
+
+ def render_dismiss_href(self, session, item):
+ branch = session.branch()
+ self.parent.dismiss.set(branch, id(item))
+ return branch.marshal()
+
class CuminPage(HtmlPage):
def __init__(self, app, name):
super(CuminPage, self).__init__(app, name)
@@ -1258,7 +1333,7 @@
# If we have an exception from a missing object, redirect to the
# main page with a notice instead of using the not_found_tmpl below
if type(e) is RosemaryNotFound:
- session.add_notice("An object being displayed became unavailable")
+ session.add_notice(Notice("An object being displayed became unavailable"))
return "index.html"
def render_error(self, session):
Modified: trunk/cumin/python/cumin/widgets.strings
===================================================================
--- trunk/cumin/python/cumin/widgets.strings 2012-02-09 21:04:31 UTC (rev 5211)
+++ trunk/cumin/python/cumin/widgets.strings 2012-02-10 16:17:35 UTC (rev 5212)
@@ -180,7 +180,7 @@
</div>
<div id="body">
- {tasks}
+ {notifications}
{heartbeat}
@@ -329,7 +329,7 @@
width: 100%;
border-collapse: collapse;
}
-
+
table.CuminDetails > tbody > tr > td {
width: 50%;
padding: 0.5em;
@@ -953,3 +953,34 @@
</td>
</tr>
+[NotificationSet.css]
+div.NotificationSet {
+ background-color: #fe0;
+ padding: 1em 2em;
+ -moz-border-radius: 0.5em;
+ -webkit-border-radius: 0.5em;
+ margin: 0.5em auto 1em auto;
+ width: 80%;
+}
+
+div.NotificationSet ul {
+ margin: 0;
+ padding: 0 0 0 1em;
+}
+
+div.NotificationSet a.dismiss {
+ float: right;
+ font-size: 0.9em;
+}
+
+[NotificationSet.html]
+<div id="{id}" class="{class}">
+ <a class="dismiss" href="{dismiss_all_href}">Dismiss all notifications</a><br/>
+ <ul>{items}</ul>
+</div>
+
+[NotificationItem.html]
+<li>
+ <a class="dismiss" href="{dismiss_href}">Dismiss</a>
+ {message}
+</li>
\ No newline at end of file
Modified: trunk/wooly/python/wooly/__init__.py
===================================================================
--- trunk/wooly/python/wooly/__init__.py 2012-02-09 21:04:31 UTC (rev 5211)
+++ trunk/wooly/python/wooly/__init__.py 2012-02-10 16:17:35 UTC (rev 5212)
@@ -825,24 +825,17 @@
name, value = crumb.split("=", 1)
self.cookies_by_name[name.strip()] = (False, value.strip(), None)
- def add_notice(self, message, preamble="Notice", capitalize=True):
+ def add_notice(self, notice):
try:
- t = self.client_session.attributes["login_session"].task_invocations
- t.append(Notice(preamble, message, capitalize))
+ n = self.client_session.attributes["login_session"].notifications
+ n.append(notice)
except:
pass
- def add_task(self, task):
+ def get_notifications(self):
try:
- t = self.client_session.attributes["login_session"].task_invocations
- t.append(task)
+ return self.client_session.attributes["login_session"].notifications
except:
- pass
-
- def get_task_invocations(self):
- try:
- return self.client_session.attributes["login_session"].task_invocations
- except:
return []
def get_user(self):
@@ -853,7 +846,7 @@
(self.__class__.__name__, self.trunk, self.app, id(self))
class Notice(object):
- def __init__(self, preamble, message, capitalize):
+ def __init__(self, message, preamble="Notice", capitalize=True):
self.dismissed = False
if capitalize:
message = message.capitalize()
Modified: trunk/wooly/python/wooly/__init__.strings
===================================================================
--- trunk/wooly/python/wooly/__init__.strings 2012-02-09 21:04:31 UTC (rev 5211)
+++ trunk/wooly/python/wooly/__init__.strings 2012-02-10 16:17:35 UTC (rev 5212)
@@ -6,7 +6,7 @@
[Widget.nocontent]
<div id="{id}">
- <div class="TaskInvocationSet">
+ <div class="NotificationSet">
<ul>
<li>{error_msg}</li>
</ul>
12 years, 2 months
r5211 - in trunk: cumin/python/cumin wooly/python/wooly
by tmckay@fedoraproject.org
Author: tmckay
Date: 2012-02-09 21:04:31 +0000 (Thu, 09 Feb 2012)
New Revision: 5211
Modified:
trunk/cumin/python/cumin/widgets.py
trunk/wooly/python/wooly/__init__.py
trunk/wooly/python/wooly/server.py
Log:
On page exceptions from missing objects, redirect to the main page with
a notice instead of using the not_found_tmpl
Modified: trunk/cumin/python/cumin/widgets.py
===================================================================
--- trunk/cumin/python/cumin/widgets.py 2012-02-09 19:53:24 UTC (rev 5210)
+++ trunk/cumin/python/cumin/widgets.py 2012-02-09 21:04:31 UTC (rev 5211)
@@ -1254,6 +1254,13 @@
return False
+ def redirect_on_exception(self, session, e):
+ # If we have an exception from a missing object, redirect to the
+ # main page with a notice instead of using the not_found_tmpl below
+ if type(e) is RosemaryNotFound:
+ session.add_notice("An object being displayed became unavailable")
+ return "index.html"
+
def render_error(self, session):
cls, value, traceback = sys.exc_info()
@@ -1621,4 +1628,4 @@
def render_listcontainer_height(self, session):
return "%dpx" % self.listcontainer_height
-
\ No newline at end of file
+
Modified: trunk/wooly/python/wooly/__init__.py
===================================================================
--- trunk/wooly/python/wooly/__init__.py 2012-02-09 19:53:24 UTC (rev 5210)
+++ trunk/wooly/python/wooly/__init__.py 2012-02-09 21:04:31 UTC (rev 5211)
@@ -482,6 +482,9 @@
return self.render(session)
+ def redirect_on_exception(self, session, e):
+ return None
+
def service_error(self, session):
self.error.set(session, PageError(self, session))
Modified: trunk/wooly/python/wooly/server.py
===================================================================
--- trunk/wooly/python/wooly/server.py 2012-02-09 19:53:24 UTC (rev 5210)
+++ trunk/wooly/python/wooly/server.py 2012-02-09 21:04:31 UTC (rev 5211)
@@ -132,9 +132,14 @@
# update handler will look for the header.
status = "200 OK"
headers.append(("Location", e.url))
- except:
- content = page.service_error(session)
- status = "500 Internal Error"
+ except Exception as e:
+ url = page.redirect_on_exception(session, e)
+ if url:
+ status = "303 See Other"
+ headers.append(("Location", url))
+ else:
+ content = page.service_error(session)
+ status = "500 Internal Error"
else:
status = "304 Not Modified"
12 years, 2 months
r5210 - in trunk: cumin/python/cumin cumin/python/cumin/account cumin/python/cumin/grid wooly/python/wooly
by tmckay@fedoraproject.org
Author: tmckay
Date: 2012-02-09 19:53:24 +0000 (Thu, 09 Feb 2012)
New Revision: 5210
Modified:
trunk/cumin/python/cumin/account/widgets.py
trunk/cumin/python/cumin/grid/job.py
trunk/cumin/python/cumin/model.py
trunk/cumin/python/cumin/objecttask.py
trunk/cumin/python/cumin/task.py
trunk/wooly/python/wooly/__init__.py
Log:
Extend the "task_invocations" mechanism to allow general notices.
This provides the ability to send a "Notice:" to the user from anywhere
in the application where the "session" object is available.
Changes involved some refactoring of existing methods/objects.
Add a notice on redirect for missing submissions.
Modified: trunk/cumin/python/cumin/account/widgets.py
===================================================================
--- trunk/cumin/python/cumin/account/widgets.py 2012-02-09 16:30:40 UTC (rev 5209)
+++ trunk/cumin/python/cumin/account/widgets.py 2012-02-09 19:53:24 UTC (rev 5210)
@@ -214,11 +214,10 @@
error = FormError("Password change error. Please contact your site administrator.")
self.errors.add(session,error)
- if not self.errors.get(session):
- task = ObjectTask(self.app)
- invoc = task.start(session, None)
- invoc.description = "Password changed"
- invoc.end()
+ if not self.errors.get(session):
+ # Just use a notice here to spoof a task completion.
+ session.add_notice(preamble="Password changed", message="OK",
+ capitalize=False)
url = self.return_url.get(session)
self.page.redirect.set(session, url)
Modified: trunk/cumin/python/cumin/grid/job.py
===================================================================
--- trunk/cumin/python/cumin/grid/job.py 2012-02-09 16:30:40 UTC (rev 5209)
+++ trunk/cumin/python/cumin/grid/job.py 2012-02-09 19:53:24 UTC (rev 5210)
@@ -304,6 +304,7 @@
frame.view.show(nsession)
submission_list_url = nsession.marshal()
self.page.redirect.set(session, submission_list_url)
+ session.add_notice("The submission being displayed became unavailable")
else:
return super(JobSelectorTable, self).do_render(session)
@@ -646,6 +647,7 @@
frame.view.show(nsession)
submission_list_url = nsession.marshal()
self.page.redirect.set(session, submission_list_url)
+ session.add_notice("The submission being displayed became unavailable")
else:
return super(JobAdsViewer, self).do_render(session)
Modified: trunk/cumin/python/cumin/model.py
===================================================================
--- trunk/cumin/python/cumin/model.py 2012-02-09 16:30:40 UTC (rev 5209)
+++ trunk/cumin/python/cumin/model.py 2012-02-09 19:53:24 UTC (rev 5210)
@@ -25,7 +25,6 @@
self.model_dir = model_dir
self.tasks = list()
- self.task_invocations = list()
self.limits_by_negotiator = dict()
self.job_summaries_by_submission = dict()
Modified: trunk/cumin/python/cumin/objecttask.py
===================================================================
--- trunk/cumin/python/cumin/objecttask.py 2012-02-09 16:30:40 UTC (rev 5209)
+++ trunk/cumin/python/cumin/objecttask.py 2012-02-09 19:53:24 UTC (rev 5210)
@@ -65,10 +65,8 @@
def start(self, session, obj):
log.debug("Starting %s", self)
- login = session.client_session.attributes["login_session"]
+ invoc = TaskInvocation(self, session)
- invoc = TaskInvocation(self, login)
-
now = datetime.now()
invoc.start_time = now
Modified: trunk/cumin/python/cumin/task.py
===================================================================
--- trunk/cumin/python/cumin/task.py 2012-02-09 16:30:40 UTC (rev 5209)
+++ trunk/cumin/python/cumin/task.py 2012-02-09 19:53:24 UTC (rev 5210)
@@ -74,10 +74,8 @@
def start(self, session, obj):
log.debug("Starting %s", self)
- login = session.client_session.attributes["login_session"]
+ invoc = TaskInvocation(self, session)
- invoc = TaskInvocation(self, login)
-
now = datetime.now()
invoc.start_time = now
@@ -120,13 +118,12 @@
FAILED = "Failed"
OK = "OK"
- def __init__(self, task, login_session):
+ def __init__(self, task, session):
self.task = task
- login_session = login_session
- login_session.task_invocations.append(self)
+ session.add_task(self)
- self.user = login_session.user
+ self.user = session.get_user()
self.start_time = None
self.end_time = None
@@ -158,6 +155,13 @@
return self.status
+ def get_message(self, session):
+ description = xml_escape(self.get_description(session))
+ if not description:
+ description = ""
+ status = xml_escape(str(self.get_status(session)))
+ return "%s: %s" % (description, status)
+
def end(self):
log.debug("Ending %s", self.task)
@@ -238,10 +242,7 @@
self.add_child(self.item_widget)
def get_items(self, session):
- items = []
- if("login_session" in session.client_session.attributes.keys() ):
- login = session.client_session.attributes["login_session"]
- items = [x for x in login.task_invocations if not x.dismissed]
+ items = [x for x in session.get_task_invocations() if not x.dismissed]
return items
def do_process(self, session):
@@ -250,9 +251,12 @@
dismiss = self.dismiss.get(session)
dismiss_all = self.dismiss_all.get(session)
- if(dismiss_all):
+ if dismiss_all:
for invoc in self.get_items(session):
invoc.dismissed = True
+# We're leaking task invocations during the login session.
+# Replace the loop with the following at a later date
+# items[:] = []
self.dismiss_all.set(session, self.dismiss_all.default)
if dismiss:
@@ -260,6 +264,9 @@
if id(invoc) == dismiss:
invoc.dismissed = True
break
+# We're leaking task invocations during the login session.
+# Replace the loop with the following at a later date
+# items[:] = [x for x in items if id(x) != dismiss]
self.dismiss.set(session, self.dismiss.default)
@@ -287,16 +294,8 @@
return "resource?name=add-20.png"
def render_message(self, session, item):
- description = item.get_description(session)
- description = xml_escape(description)
+ return item.get_message(session)
- if not description:
- description = ""
-
- status = xml_escape(str(item.get_status(session)))
-
- return "%s: %s" % (description, status)
-
def render_dismiss_href(self, session, item):
branch = session.branch()
self.parent.dismiss.set(branch, id(item))
Modified: trunk/wooly/python/wooly/__init__.py
===================================================================
--- trunk/wooly/python/wooly/__init__.py 2012-02-09 16:30:40 UTC (rev 5209)
+++ trunk/wooly/python/wooly/__init__.py 2012-02-09 19:53:24 UTC (rev 5210)
@@ -822,10 +822,44 @@
name, value = crumb.split("=", 1)
self.cookies_by_name[name.strip()] = (False, value.strip(), None)
+ def add_notice(self, message, preamble="Notice", capitalize=True):
+ try:
+ t = self.client_session.attributes["login_session"].task_invocations
+ t.append(Notice(preamble, message, capitalize))
+ except:
+ pass
+
+ def add_task(self, task):
+ try:
+ t = self.client_session.attributes["login_session"].task_invocations
+ t.append(task)
+ except:
+ pass
+
+ def get_task_invocations(self):
+ try:
+ return self.client_session.attributes["login_session"].task_invocations
+ except:
+ return []
+
+ def get_user(self):
+ return self.client_session.attributes["login_session"].user
+
def __repr__(self):
return "%s(trunk=%s,app=%s,id=%i)" % \
(self.__class__.__name__, self.trunk, self.app, id(self))
+class Notice(object):
+ def __init__(self, preamble, message, capitalize):
+ self.dismissed = False
+ if capitalize:
+ message = message.capitalize()
+ self.message = message
+ self.preamble = preamble
+
+ def get_message(self, session):
+ return "%s: %s" % (self.preamble, self.message)
+
class SessionAttribute(object):
def __init__(self, widget, name):
assert hasattr(widget, "app"), widget
12 years, 2 months