r5013 - in trunk/cumin/python/cumin: grid inventory
by croberts@fedoraproject.org
Author: croberts
Date: 2011-09-27 18:06:14 +0000 (Tue, 27 Sep 2011)
New Revision: 5013
Modified:
trunk/cumin/python/cumin/grid/tags.py
trunk/cumin/python/cumin/inventory/system.py
Log:
Fixing-up sorting (now done case insensitively) for tags and inventory tables
Modified: trunk/cumin/python/cumin/grid/tags.py
===================================================================
--- trunk/cumin/python/cumin/grid/tags.py 2011-09-27 17:30:15 UTC (rev 5012)
+++ trunk/cumin/python/cumin/grid/tags.py 2011-09-27 18:06:14 UTC (rev 5013)
@@ -1,5 +1,7 @@
import logging
+from operator import itemgetter
+
from wooly import Widget, Attribute
from wooly.util import StringCatalog, Writer, escape_amp, escape_entity, unescape_entity
from wooly.datatable import DataAdapterOptions, DataAdapterField, DataTableColumn, DataTable, DataAdapter
@@ -73,7 +75,20 @@
for row in rows:
if filter_text.lower() in row[self.fields_by_name[filter_field].index].lower():
filtered.append(row)
- return filtered
+ return filtered
+
+ def sort_rows(self, rows, options):
+ if len(rows) > self.max_sortable_records:
+ return rows
+
+ sort_field = options.sort_field
+ rev = options.sort_ascending == False
+
+ try:
+ return sorted(rows, key=lambda k: k[sort_field.index].lower(), reverse=rev)
+ except AttributeError:
+ #since long and float fields will not have lower()
+ return sorted(rows, key=itemgetter(sort_field.index), reverse=rev)
class TagsAdapter(ResponseAdapter):
@@ -88,7 +103,7 @@
wallaby_features = self.app.wallaby.get_data(WBTypes.FEATURES)
for i, tag in enumerate(wallaby_tags):
- data.append({'Tag':str(escape_entity(tag.name)), 'Features':tag.features, 'NumHosts':len(self.app.wallaby.get_node_names(tag)), 'Host':self.app.wallaby.get_node_names(tag)} )
+ 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)
@@ -317,12 +332,7 @@
'''
def render_cell_content(self, session, data):
feature_list = data[2]
- features = ""
- if feature_list:
- for feature in feature_list:
- features = features + "," + str(feature)
- features = features[1:]
- features = truncate_text(features, 50, True)
+ features = truncate_text(feature_list, 50, True)
return features
class HostCountColumn(ObjectTableColumn):
Modified: trunk/cumin/python/cumin/inventory/system.py
===================================================================
--- trunk/cumin/python/cumin/inventory/system.py 2011-09-27 17:30:15 UTC (rev 5012)
+++ trunk/cumin/python/cumin/inventory/system.py 2011-09-27 18:06:14 UTC (rev 5013)
@@ -275,12 +275,12 @@
if len(match_index) > 0:
## merge-in the wallaby data to the matched node entry in sqldata
new_record = list(sqldata[match_index[0]])
- new_record.append(self.app.wallaby.get_tag_names(node))
+ new_record.append(", ".join(self.app.wallaby.get_tag_names(node)))
new_record.append(node.last_checkin)
sqldata[match_index[0]] = tuple(new_record)
else:
# there was no match found, add a wallaby-only row
- data_row = tuple([node.name, node.name, "", "", "", 0, self.app.wallaby.get_tag_names(node), node.last_checkin])
+ data_row = tuple([node.name, node.name, "", "", "", 0, ", ".join(self.app.wallaby.get_tag_names(node)), node.last_checkin])
sqldata.append(data_row)
data = sqldata
elif len(sqldata) > 0: # we only have sesame data
@@ -292,7 +292,7 @@
for node in wallaby_nodes:
# using the node name for the [0] element in this case will allow
#other pages to use the id as the node lookup key against the wallaby data
- data_row = tuple([node.name, node.name, "", "", "", 0, self.app.wallaby.get_tag_names(node), node.last_checkin])
+ data_row = tuple([node.name, node.name, "", "", "", 0, ", ".join(self.app.wallaby.get_tag_names(node)), node.last_checkin])
data.append(data_row)
options.sort_field = requested_sort_field
@@ -318,7 +318,11 @@
sort_field = options.sort_field
rev = options.sort_ascending == False
- return sorted(rows, key=itemgetter(sort_field.index), reverse=rev)
+ try:
+ return sorted(rows, key=lambda k: k[sort_field.index].lower(), reverse=rev)
+ except AttributeError:
+ #since long and float fields will not have lower()
+ return sorted(rows, key=itemgetter(sort_field.index), reverse=rev)
class DerivedTableColumn(ObjectTableColumn):
@@ -342,7 +346,6 @@
value = ""
try:
value = record[self.index]
- value = ", ".join(value)
value = truncate_text(value, 30, True)
except Exception, e:
pass
12 years, 8 months
r5012 - trunk/cumin/python/cumin/inventory
by croberts@fedoraproject.org
Author: croberts
Date: 2011-09-27 17:30:15 +0000 (Tue, 27 Sep 2011)
New Revision: 5012
Modified:
trunk/cumin/python/cumin/inventory/system.py
Log:
Per our UI review, making the display of tags within the inventory table consistent with the rest of the UI.
Modified: trunk/cumin/python/cumin/inventory/system.py
===================================================================
--- trunk/cumin/python/cumin/inventory/system.py 2011-09-26 20:21:11 UTC (rev 5011)
+++ trunk/cumin/python/cumin/inventory/system.py 2011-09-27 17:30:15 UTC (rev 5012)
@@ -342,7 +342,7 @@
value = ""
try:
value = record[self.index]
- value = ",".join(value)
+ value = ", ".join(value)
value = truncate_text(value, 30, True)
except Exception, e:
pass
12 years, 8 months
r5011 - trunk/cumin/python/cumin/inventory
by croberts@fedoraproject.org
Author: croberts
Date: 2011-09-26 20:21:11 +0000 (Mon, 26 Sep 2011)
New Revision: 5011
Modified:
trunk/cumin/python/cumin/inventory/system.py
Log:
Fixing-up hanling of wallaby only nodes when there are also any sesame nodes.
Modified: trunk/cumin/python/cumin/inventory/system.py
===================================================================
--- trunk/cumin/python/cumin/inventory/system.py 2011-09-26 19:16:31 UTC (rev 5010)
+++ trunk/cumin/python/cumin/inventory/system.py 2011-09-26 20:21:11 UTC (rev 5011)
@@ -250,8 +250,15 @@
self.slots.add_where_expr(session, "\"System\" = '%s'", sysimage.nodeName)
class WallabyAndSqlAdapter(ObjectSqlAdapter):
+
+ def get_count(self, values):
+ options = DataAdapterOptions()
+ options.limit = 10000
+ options.offset = 0
+ return len(self.get_data(values, options))
+
def get_data(self, values, options):
- #first, fetch all the sql data, unsorted since we will sort it after merging the wallaby data
+ #first, fetch all the sql data, unsorted since we will sort it after merging the wallaby data
requested_sort_field = options.sort_field
options.sort_field = None
sqldata = super(WallabyAndSqlAdapter, self).get_data(values, options)
@@ -271,6 +278,10 @@
new_record.append(self.app.wallaby.get_tag_names(node))
new_record.append(node.last_checkin)
sqldata[match_index[0]] = tuple(new_record)
+ else:
+ # there was no match found, add a wallaby-only row
+ data_row = tuple([node.name, node.name, "", "", "", 0, self.app.wallaby.get_tag_names(node), node.last_checkin])
+ sqldata.append(data_row)
data = sqldata
elif len(sqldata) > 0: # we only have sesame data
for node in sqldata:
@@ -286,16 +297,27 @@
options.sort_field = requested_sort_field
data = self.sort_rows(data, options)
+ data = self.limit_rows(data, options)
return data
+ def limit_rows(self, rows, options):
+ # return only the current page
+ first_index = options.offset
+ last_index = len(rows)
+ if options.limit:
+ last_index = options.offset + options.limit
+
+ page = rows[first_index:last_index]
+
+ return page
+
def sort_rows(self, rows, options):
- if len(rows) > 10000:
+ if len(rows) > 10000 or options.sort_field is None:
return rows
sort_field = options.sort_field
rev = options.sort_ascending == False
-
return sorted(rows, key=itemgetter(sort_field.index), reverse=rev)
12 years, 8 months
r5010 - trunk/cumin/python/cumin/grid
by croberts@fedoraproject.org
Author: croberts
Date: 2011-09-26 19:16:31 +0000 (Mon, 26 Sep 2011)
New Revision: 5010
Modified:
trunk/cumin/python/cumin/grid/tags.py
Log:
Text changes that came out of our UI review. changing "wallaby" to pool for the activation link, colon removal for fields.
Modified: trunk/cumin/python/cumin/grid/tags.py
===================================================================
--- trunk/cumin/python/cumin/grid/tags.py 2011-09-23 18:33:08 UTC (rev 5009)
+++ trunk/cumin/python/cumin/grid/tags.py 2011-09-26 19:16:31 UTC (rev 5010)
@@ -240,10 +240,10 @@
return retval
def render_hosts_title(self, session):
- return "Hosts:"
+ return "Hosts"
def render_features_title(self, session):
- return "Features:"
+ return "Features"
class TagsFrame(TagObjectFrame):
def __init__(self, app, name):
@@ -331,7 +331,7 @@
return tags
def render_header_content(self, session):
- return "Number of hosts"
+ return "Hosts"
def render_text_align(self, session):
return "right"
@@ -464,7 +464,7 @@
def render_title(self, session):
''' appears in the top "bar" of the form display '''
- return "Activate wallaby configuration"
+ return "Activate pool configuration"
class LabelField(Label):
''' this is just text that appears in place of actual form fields '''
@@ -508,7 +508,7 @@
self.help = "*Comma separated list"
def render_title(self, session):
- return("Tag names: ")
+ return("Tag names ")
class RemoveTags(ObjectSelectorTaskForm):
'''
12 years, 8 months
r5009 - trunk/cumin/python/cumin/grid
by croberts@fedoraproject.org
Author: croberts
Date: 2011-09-23 18:33:08 +0000 (Fri, 23 Sep 2011)
New Revision: 5009
Modified:
trunk/cumin/python/cumin/grid/tags.py
Log:
When editing hosts for a tag, we are now getting the latest and greatest data when loading the form. This prevents any "lag" from affecting functionality.
Modified: trunk/cumin/python/cumin/grid/tags.py
===================================================================
--- trunk/cumin/python/cumin/grid/tags.py 2011-09-23 17:05:03 UTC (rev 5008)
+++ trunk/cumin/python/cumin/grid/tags.py 2011-09-23 18:33:08 UTC (rev 5009)
@@ -828,17 +828,11 @@
self.input = self.DisabledInput(app, "input")
self.replace_child(self.input)
-
- def get(self,session):
- value = self.input.get(session)
-
- if not value or value == "":
- value = "No hosts currently selected"
- return value
-
def render_inputs(self, session, *args):
- value = self.input.get(session)
+ value = ", ".join(self.app.wallaby.get_node_names(self.form.tags.get(session)))
+ if not value or value =="":
+ value = "No hosts currently selected"
value = truncate_text(value, 50, True)
return value
12 years, 8 months
r5008 - trunk/cumin/python/cumin/grid
by croberts@fedoraproject.org
Author: croberts
Date: 2011-09-23 17:05:03 +0000 (Fri, 23 Sep 2011)
New Revision: 5008
Modified:
trunk/cumin/python/cumin/grid/tags.py
Log:
Performing the refresh after tag creation before invoc.end so that the UI doesn't appear to lag while it waits for the refresh.
Modified: trunk/cumin/python/cumin/grid/tags.py
===================================================================
--- trunk/cumin/python/cumin/grid/tags.py 2011-09-23 15:59:44 UTC (rev 5007)
+++ trunk/cumin/python/cumin/grid/tags.py 2011-09-23 17:05:03 UTC (rev 5008)
@@ -1181,9 +1181,10 @@
def callback(self, result):
if result == False:
self.invoc.status = self.invoc.FAILED
+ self.app.wallaby.refresh(WBTypes.GROUPS,WBTypes.TAGS)
self.invoc.end()
- self.app.wallaby.refresh(WBTypes.GROUPS,WBTypes.TAGS)
+
def do_invoke(self, session, object, invoc, tag):
self.invoc = invoc
tags = [x.strip() for x in tag.split(',')]
12 years, 8 months
r5007 - trunk/cumin/python/cumin/grid
by croberts@fedoraproject.org
Author: croberts
Date: 2011-09-23 15:59:44 +0000 (Fri, 23 Sep 2011)
New Revision: 5007
Modified:
trunk/cumin/python/cumin/grid/tags.py
Log:
Now doing a refresh on wallaby information before finishing the invocation for removing tags.
Modified: trunk/cumin/python/cumin/grid/tags.py
===================================================================
--- trunk/cumin/python/cumin/grid/tags.py 2011-09-23 15:41:47 UTC (rev 5006)
+++ trunk/cumin/python/cumin/grid/tags.py 2011-09-23 15:59:44 UTC (rev 5007)
@@ -1223,8 +1223,9 @@
def callback(self, result):
if result == False:
self.invoc.status = self.invoc.FAILED
+ self.app.wallaby.refresh()
self.invoc.end()
- self.app.wallaby.refresh()
+
def do_invoke(self, invoc, tags):
try:
12 years, 8 months
r5006 - trunk/sage/python/sage/wallaby
by croberts@fedoraproject.org
Author: croberts
Date: 2011-09-23 15:41:47 +0000 (Fri, 23 Sep 2011)
New Revision: 5006
Modified:
trunk/sage/python/sage/wallaby/wallabyoperations.py
Log:
Updating dummy method names to match changes to create/remove_tags methods.
Modified: trunk/sage/python/sage/wallaby/wallabyoperations.py
===================================================================
--- trunk/sage/python/sage/wallaby/wallabyoperations.py 2011-09-23 15:31:54 UTC (rev 5005)
+++ trunk/sage/python/sage/wallaby/wallabyoperations.py 2011-09-23 15:41:47 UTC (rev 5006)
@@ -724,10 +724,10 @@
def get_tag_names(self, *args, **kwargs):
return []
- def create_tag(self, *args, **kwargs):
+ def create_tags(self, *args, **kwargs):
return False
- def remove_tag(self, *args, **kwargs):
+ def remove_tags(self, *args, **kwargs):
return False
def edit_tags(self, *args, **kwargs):
12 years, 8 months
r5005 - trunk/cumin/python/cumin/grid
by croberts@fedoraproject.org
Author: croberts
Date: 2011-09-23 15:31:54 +0000 (Fri, 23 Sep 2011)
New Revision: 5005
Modified:
trunk/cumin/python/cumin/grid/tags.py
Log:
Now getting the most up-to-date set of features for a tag while rendering the edit features form.
Modified: trunk/cumin/python/cumin/grid/tags.py
===================================================================
--- trunk/cumin/python/cumin/grid/tags.py 2011-09-23 14:23:10 UTC (rev 5004)
+++ trunk/cumin/python/cumin/grid/tags.py 2011-09-23 15:31:54 UTC (rev 5005)
@@ -951,17 +951,12 @@
self.input = self.DisabledInput(app, "input")
self.replace_child(self.input)
-
- def get(self,session):
- value = self.input.get(session)
-
- if not value or value == "":
- value = "No features currently selected"
- return value
-
def render_inputs(self, session, *args):
- value = self.input.get(session)
+ tag = self.form.tags.get(session)
+ value = ", ".join(self.app.wallaby.get_tag_by_name(tag).features)
+ if not value or value == "":
+ value = "No features currently selected"
value = truncate_text(value, 50, True)
return value
12 years, 8 months
r5004 - in branches/scale_testing: cumin/bin cumin/python/cumin cumin/python/cumin/grid parsley/python/parsley sage/python/sage/wallaby
by tmckay@fedoraproject.org
Author: tmckay
Date: 2011-09-23 14:23:10 +0000 (Fri, 23 Sep 2011)
New Revision: 5004
Modified:
branches/scale_testing/cumin/bin/cumin-data
branches/scale_testing/cumin/bin/cumin-web
branches/scale_testing/cumin/python/cumin/grid/tags.py
branches/scale_testing/cumin/python/cumin/main.py
branches/scale_testing/parsley/python/parsley/loggingex.py
branches/scale_testing/sage/python/sage/wallaby/wallabyoperations.py
Log:
Merge latest, add logging.shutdown()
svn merge -r 4985:HEAD svn+ssh://svn.fedorahosted.org/svn/cumin/trunk .
Modified: branches/scale_testing/cumin/bin/cumin-data
===================================================================
--- branches/scale_testing/cumin/bin/cumin-data 2011-09-23 14:20:51 UTC (rev 5003)
+++ branches/scale_testing/cumin/bin/cumin-data 2011-09-23 14:23:10 UTC (rev 5004)
@@ -240,6 +240,7 @@
mint.stop()
if pipeThread:
pipeThread.stop()
+ logging.shutdown()
sys.exit(return_code)
if __name__ == "__main__":
Modified: branches/scale_testing/cumin/bin/cumin-web
===================================================================
--- branches/scale_testing/cumin/bin/cumin-web 2011-09-23 14:20:51 UTC (rev 5003)
+++ branches/scale_testing/cumin/bin/cumin-web 2011-09-23 14:23:10 UTC (rev 5004)
@@ -156,7 +156,6 @@
cumin.stop()
if pipeThread:
pipeThread.stop()
- print "calling logging shutdown"
logging.shutdown()
sys.exit(return_code)
Modified: branches/scale_testing/cumin/python/cumin/grid/tags.py
===================================================================
--- branches/scale_testing/cumin/python/cumin/grid/tags.py 2011-09-23 14:20:51 UTC (rev 5003)
+++ branches/scale_testing/cumin/python/cumin/grid/tags.py 2011-09-23 14:23:10 UTC (rev 5004)
@@ -1011,6 +1011,7 @@
if result == False:
self.invoc.status = self.invoc.FAILED
self.invoc.end()
+ self.app.wallaby.refresh(WBTypes.GROUPS,WBTypes.TAGS)
def do_invoke(self, invoc, negotiator, node_name, tags):
self.invoc = invoc
@@ -1047,22 +1048,36 @@
self.form.node_name.set(session, nodes)
def callback(self, result):
- self.call_count -= 1
- if result == False:
- self.invoc.status = self.invoc.FAILED
- if(self.call_count <= 0):
- self.invoc.end()
+ if result is not None:
+ self.call_count -= 1
+ if result == False:
+ self.invoc.status = self.invoc.FAILED
+ if(self.call_count <= 0):
+ self.invoc.end()
+ self.app.wallaby.refresh(WBTypes.GROUPS,WBTypes.TAGS)
def do_invoke(self, invoc, negotiator, tag, chosen_nodes):
'''
+ Here we just kick off an async call that does the actual work for us
+ '''
+ self.invoc = invoc
+ try:
+ call_async(self.callback, self.make_calls, invoc, tag, chosen_nodes)
+ except Exception, e:
+ self.call_count = 0
+ invoc.status = invoc.FAILED
+ log.exception(e)
+ invoc.end()
+
+ def make_calls(self, invoc, tag, chosen_nodes):
+ '''
if the node is on the current_nodes list and is on the chosen_nodes passed in, nothing to do
** if the node is NOT on the current_nodes list and is on the chosen_nodes passed in, add this tag to that node
** if the node is on the current_nodes list and is NOT on the chosen_nodes passed in, update that node sans this tag
if the node is NOT on the current_nodes list and is NOT on the chosen_nodes passed in, nothing to do
'''
- self.invoc = invoc
- current_nodes = self.app.wallaby.get_node_names(tag)
try:
+ current_nodes = self.app.wallaby.get_node_names(tag)
for node in chosen_nodes:
if node not in current_nodes:
#we need to add the new tag to the existing tags for each node in the list
@@ -1081,7 +1096,10 @@
invoc.status = invoc.FAILED
log.exception(e)
invoc.end()
+ return False
+ return None
+
class TagsFeatureEditTask(ObjectFrameTask):
'''
This is the task that will take a tag and a set of nodes and make the
@@ -1161,27 +1179,22 @@
cls = app.model.com_redhat_cumin_grid.Node
self.form = CreateTags(app, self.name, self, cls)
self.invoc = None
- self.calls = 0
def get_title(self, session, object):
return "Create tags"
def callback(self, result):
- self.calls -= 1
if result == False:
self.invoc.status = self.invoc.FAILED
- if(self.calls <= 0):
- self.invoc.end()
-
+ self.invoc.end()
+ self.app.wallaby.refresh(WBTypes.GROUPS,WBTypes.TAGS)
+
def do_invoke(self, session, object, invoc, tag):
self.invoc = invoc
tags = [x.strip() for x in tag.split(',')]
- max_retries = 1
try:
- for new_tag in tags:
- self.calls += 1
- call_async(self.callback, self.app.wallaby.create_tag, new_tag)
+ call_async(self.callback, self.app.wallaby.create_tags, tags)
except Exception, e:
invoc.status = invoc.FAILED
log.exception(e)
@@ -1216,17 +1229,15 @@
if result == False:
self.invoc.status = self.invoc.FAILED
self.invoc.end()
+ self.app.wallaby.refresh()
def do_invoke(self, invoc, tags):
try:
- for tag_to_kill in tags:
- call_async(self.callback, self.app.wallaby.remove_tag, tag_to_kill)
+ call_async(self.callback, self.app.wallaby.remove_tags, tags)
except Exception, e:
invoc.status = invoc.FAILED
log.exception(e)
- invoc.end()
-
def get_item_content(self, session, item):
return item
Modified: branches/scale_testing/cumin/python/cumin/main.py
===================================================================
--- branches/scale_testing/cumin/python/cumin/main.py 2011-09-23 14:20:51 UTC (rev 5003)
+++ branches/scale_testing/cumin/python/cumin/main.py 2011-09-23 14:23:10 UTC (rev 5004)
@@ -248,8 +248,12 @@
def stop(self):
log.info("Stopping %s", self)
+ self.wallaby.stop()
self.server.stop()
- self.session.stop()
+ try:
+ self.session.stop()
+ except:
+ pass
def set_form_defaults(self,
request_memory,
Modified: branches/scale_testing/parsley/python/parsley/loggingex.py
===================================================================
--- branches/scale_testing/parsley/python/parsley/loggingex.py 2011-09-23 14:20:51 UTC (rev 5003)
+++ branches/scale_testing/parsley/python/parsley/loggingex.py 2011-09-23 14:23:10 UTC (rev 5004)
@@ -66,8 +66,11 @@
# Never want to crash writing out a log entry
try:
self._emit(record)
- except:
- sys.stderr.write("Warning, logging exception writing " + self.baseFilename + "\n")
+ except (KeyboardInterrupt, SystemExit):
+ # We don't want to swallow these exceptions
+ raise
+ except Exception, e:
+ sys.stderr.write("Warning, logging exception writing " + self.baseFilename + ", %s\n" % e)
def _emit(self, record):
# Following snippett taken from WatchedFileHandler in Python 2.6
Modified: branches/scale_testing/sage/python/sage/wallaby/wallabyoperations.py
===================================================================
--- branches/scale_testing/sage/python/sage/wallaby/wallabyoperations.py 2011-09-23 14:20:51 UTC (rev 5003)
+++ branches/scale_testing/sage/python/sage/wallaby/wallabyoperations.py 2011-09-23 14:23:10 UTC (rev 5004)
@@ -154,6 +154,9 @@
while not self._stop:
start_processing = time.time()
for attr, val in self._cache.iteritems():
+ if self._stop:
+ break
+
# val.remaining is the number of seconds left before
# the next update of this data item. None is "forever".
# Synthetic items are not retreived from the store.
@@ -170,6 +173,9 @@
# Now handle the synthetics. val.synthetic generates
# and stores it's own results.
for attr, val in self._cache.iteritems():
+ if self._stop:
+ break
+
if val.synthetic and \
val.remaining is not None and val.remaining <= 0:
get_values(attr, val.synthetic, *val.args)
@@ -209,6 +215,13 @@
for attr in self._cache:
self._set_cache(attr, [])
self._store = None
+
+ # Have to clean up the broker
+ try:
+ self.session.delBroker(self.broker)
+ except:
+ pass
+
#end maintain_cache
def get_values(attr, call, *args):
@@ -407,27 +420,30 @@
self._lock.release()
return names
- def create_tag(self, name):
+ def create_tags(self, names):
'''
- Create a new tag in the Wallaby store.
+ Create new tags in the Wallaby store.
Refresh the cached lists of groups and tags.
'''
if self._store is None:
log.debug("WallabyOperations: create_tag, store object not yet created")
return False
-
try:
- self._store.addTag(name)
- self.refresh(WBTypes.GROUPS,WBTypes.TAGS)
- except Exception, e:
- log.debug("WallabyOperations: create_tag, exception suppressed, %s" % str(e))
- return False
+ self._lock.acquire()
+ try:
+ for name in names:
+ self._store.addTag(name)
+ except Exception, e:
+ log.debug("WallabyOperations: create_tag, exception suppressed, %s" % str(e))
+ return False
+ finally:
+ self._lock.release()
return True
- def remove_tag(self, name):
+ def remove_tags(self, names):
'''
- Remove a tag from the Wallaby store.
+ Remove a set of tags from the Wallaby store.
Check the cached list of tags for the
tag name first. Refresh cached lists of
@@ -437,13 +453,13 @@
log.debug("WallabyOperations: remove_tag, store object not yet created")
return False
- if self.get_tag_by_name(name) is not None:
- try:
- self._store.removeGroup(name)
- self.refresh()
- except Exception, e:
- log.debug("WallabyOperations: remove_tag, exception suppressed, %s" % str(e))
- return False
+ for name in names:
+ if self.get_tag_by_name(name) is not None:
+ try:
+ self._store.removeGroup(name)
+ except Exception, e:
+ log.debug("WallabyOperations: remove_tag, exception suppressed, %s" % str(e))
+ return False
return True
def edit_tags(self, node, *tags):
@@ -470,19 +486,20 @@
log.debug("WallabyOperations: edit_tags, node not found %s" % str(n))
else:
try:
- # cast to list in case tags is a tuple, list required
- start = time.time()
- n.modifyTags("REPLACE", list(tags), create_missing_tags=True)
- n.update()
- status = True
-
- # refresh the groups and tags so that membership information
- # is up to date.
- self.refresh(WBTypes.GROUPS,WBTypes.TAGS)
- delta = time.time() - start
- log.debug("WallabyOperations: edit_tags %s" % delta)
- except Exception, e:
- log.debug("WallabyOperations: edit_tags, exception suppressed, %s" % str(e))
+ try:
+ # cast to list in case tags is a tuple, list required
+ start = time.time()
+ self._lock.acquire()
+ n.modifyTags("REPLACE", list(tags), create_missing_tags=True)
+ n.update()
+ status = True
+
+ delta = time.time() - start
+ log.debug("WallabyOperations: edit_tags %s" % delta)
+ except Exception, e:
+ log.debug("WallabyOperations: edit_tags, exception suppressed, %s" % str(e))
+ finally:
+ self._lock.release()
return status
def edit_features(self, group, *features):
12 years, 8 months