diff options
Diffstat (limited to 'misc/stub-images')
-rwxr-xr-x | misc/stub-images | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/misc/stub-images b/misc/stub-images new file mode 100755 index 0000000..93f0fac --- /dev/null +++ b/misc/stub-images @@ -0,0 +1,49 @@ +#!/usr/bin/env python +# sugar-lint: disable + +# Copyright (C) 2013 Aleksey Lim +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +from optparse import OptionParser + +from sugar_network import db, model, static +from sugar_network.model.context import Context +from sugar_network.node import data_root +from sugar_network.toolkit import Option + + +Option.seek('node', [data_root]) +Option.parse_args(OptionParser(), config_files=['~/.config/sugar-network/config']) + +db.index_write_queue.value = 1024 * 10 +db.index_flush_threshold.value = 0 +db.index_flush_timeout.value = 0 + +volume = db.Volume(data_root.value, model.RESOURCES) +volume.populate() +directory = volume['context'] +try: + items, __ = directory.find() + for context in items: + if context['artifact_icon'] or not (set(context['type']) & set(['activity', 'book', 'group'])): + continue + for name in ('activity', 'book', 'group'): + if name in context['type']: + with file(static.path('images', name + '.svg')) as f: + Context.populate_images(context, f.read()) + directory.update(context.guid, context) + break +finally: + volume.close() |