Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/misc/stub-images
blob: 93f0facdf7fc8b6e719bf9eb57ffa16b6c70e34c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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()