src/modules/gui/cache.py
author Danek Duvall <danek.duvall@oracle.com>
Mon, 29 Aug 2011 14:13:13 -0700
changeset 2535 8dca919216c6
parent 2073 src/gui/modules/cache.py@9fcacc9e5eaa
permissions -rw-r--r--
18768 need to remove CDDL from installed files
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1516
8c950a3b4171 10485 move pkg(5) to Python 2.6
Rich Burridge <rich.burridge@sun.com>
parents: 1414
diff changeset
     1
#!/usr/bin/python
882
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff changeset
     2
#
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff changeset
     3
# CDDL HEADER START
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff changeset
     4
#
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff changeset
     5
# The contents of this file are subject to the terms of the
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff changeset
     6
# Common Development and Distribution License (the "License").
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff changeset
     7
# You may not use this file except in compliance with the License.
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff changeset
     8
#
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff changeset
     9
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff changeset
    10
# or http://www.opensolaris.org/os/licensing.
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff changeset
    11
# See the License for the specific language governing permissions
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff changeset
    12
# and limitations under the License.
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff changeset
    13
#
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff changeset
    14
# When distributing Covered Code, include this CDDL HEADER in each
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff changeset
    15
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff changeset
    16
# If applicable, add the following below this CDDL HEADER, with the
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff changeset
    17
# fields enclosed by brackets "[]" replaced with your own identifying
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff changeset
    18
# information: Portions Copyright [yyyy] [name of copyright owner]
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff changeset
    19
#
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff changeset
    20
# CDDL HEADER END
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff changeset
    21
#
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff changeset
    22
# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff changeset
    23
# Use is subject to license terms.
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff changeset
    24
#
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff changeset
    25
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff changeset
    26
import os
1219
8977dcf4ef8a 816 Provide Search Text completion
John Rice <john.rice@sun.com>
parents: 1217
diff changeset
    27
import sys
8977dcf4ef8a 816 Provide Search Text completion
John Rice <john.rice@sun.com>
parents: 1217
diff changeset
    28
try:
8977dcf4ef8a 816 Provide Search Text completion
John Rice <john.rice@sun.com>
parents: 1217
diff changeset
    29
        import gtk
8977dcf4ef8a 816 Provide Search Text completion
John Rice <john.rice@sun.com>
parents: 1217
diff changeset
    30
except ImportError:
8977dcf4ef8a 816 Provide Search Text completion
John Rice <john.rice@sun.com>
parents: 1217
diff changeset
    31
        sys.exit(1)
8977dcf4ef8a 816 Provide Search Text completion
John Rice <john.rice@sun.com>
parents: 1217
diff changeset
    32
from threading import Thread
1686
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    33
import pkg.gui.misc_non_gui as nongui_misc
882
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff changeset
    34
1554
28cb54b3370e 9519 Package Manager and Update Manager should not call misc.get_inventory_list
Padraig O'Briain <padraig.obriain@sun.com>
parents: 1516
diff changeset
    35
CACHE_VERSION = 11
882
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff changeset
    36
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff changeset
    37
class CacheListStores:
1554
28cb54b3370e 9519 Package Manager and Update Manager should not call misc.get_inventory_list
Padraig O'Briain <padraig.obriain@sun.com>
parents: 1516
diff changeset
    38
        def __init__(self, api_o):
882
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff changeset
    39
                self.api_o = api_o
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff changeset
    40
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff changeset
    41
        def __get_cache_dir(self):
1686
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    42
                return nongui_misc.get_cache_dir(self.api_o)
882
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff changeset
    43
1058
11da4bffbd61 8186 Mixing the pkg(1) and GUI commands causes wrong pkg states in the GUI.
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 1048
diff changeset
    44
        def get_index_timestamp(self):
2073
9fcacc9e5eaa 16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents: 1690
diff changeset
    45
                return self.api_o.last_modified
882
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff changeset
    46
1686
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    47
        def __dump_categories_expanded_dict(self, cat_exp_dict):
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    48
                #CED entry: {('opensolaris.org', (6,)): True}
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    49
                cache_dir = self.__get_cache_dir()
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    50
                if not cache_dir:
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    51
                        return
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    52
                catexs = []
1690
3f3629415885 14157 PM not handling recollapsed categories correctly
John Rice <john.rice@sun.com>
parents: 1686
diff changeset
    53
                for key, val in cat_exp_dict.iteritems():
3f3629415885 14157 PM not handling recollapsed categories correctly
John Rice <john.rice@sun.com>
parents: 1686
diff changeset
    54
                        if not val:
3f3629415885 14157 PM not handling recollapsed categories correctly
John Rice <john.rice@sun.com>
parents: 1686
diff changeset
    55
                                continue
1686
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    56
                        name, path = key
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    57
                        path1 = -1
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    58
                        if len(path) > 0:
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    59
                                path1 = path[0]
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    60
                        catex = {}
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    61
                        catex["name"] = name
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    62
                        catex["path1"] = path1
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    63
                        catexs.append(catex)                
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    64
                
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    65
                nongui_misc.dump_cache_file(
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    66
                    os.path.join(cache_dir, "pm_cat_exp.cpl"),
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    67
                    catexs)
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    68
                    
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    69
        def __load_categories_expanded_dict(self, cat_exp_dict):
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    70
                cache_dir = self.__get_cache_dir()
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    71
                if not cache_dir:
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    72
                        return
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    73
                catexs = nongui_misc.read_cache_file(
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    74
                    os.path.join(cache_dir, "pm_cat_exp.cpl"))
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    75
                for catex in catexs:
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    76
                        name = catex.get("name")
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    77
                        path1 = catex.get("path1")
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    78
                        if path1 != -1:
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    79
                                cat_exp_dict[name, (path1,)] = True
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    80
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    81
        def dump_categories_expanded_dict(self, cat_exp_dict):
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    82
                Thread(target = self.__dump_categories_expanded_dict,
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    83
                    args = (cat_exp_dict, )).start()
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    84
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    85
        def load_categories_expanded_dict(self, cat_exp_dict):
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    86
                Thread(target = self.__load_categories_expanded_dict,
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    87
                    args = (cat_exp_dict, )).start()
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    88
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    89
        def __dump_categories_active_dict(self, cat_ac_dict):
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    90
                cache_dir = self.__get_cache_dir()
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    91
                if not cache_dir:
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    92
                        return
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    93
                catacs = []
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    94
                for name, path in cat_ac_dict.iteritems():
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    95
                        path1 = -1
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    96
                        path2 = -1
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    97
                        if len(path) == 1:
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    98
                                path1 = path[0]
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
    99
                        elif len(path) > 1:
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
   100
                                path1 = path[0]
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
   101
                                path2 = path[1]                        
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
   102
                        catac = {}
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
   103
                        catac["name"] = name
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
   104
                        catac["path1"] = path1
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
   105
                        catac["path2"] = path2
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
   106
                        catacs.append(catac)
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
   107
                
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
   108
                nongui_misc.dump_cache_file(
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
   109
                    os.path.join(cache_dir, "pm_cat_ac.cpl"),
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
   110
                    catacs)
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
   111
                    
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
   112
        def __load_categories_active_dict(self, cat_ac_dict):
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
   113
                cache_dir = self.__get_cache_dir()
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
   114
                if not cache_dir:
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
   115
                        return
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
   116
                catacs = nongui_misc.read_cache_file(
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
   117
                    os.path.join(cache_dir, "pm_cat_ac.cpl"))
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
   118
                for catac in catacs:
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
   119
                        name = catac.get("name")
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
   120
                        path1 = catac.get("path1")
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
   121
                        path2 = catac.get("path2")
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
   122
                        if path1 != -1 and path2 != -1:
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
   123
                                cat_ac_dict[name] = (path1, path2)
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
   124
                        elif path1 != -1:
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
   125
                                cat_ac_dict[name] = (path1,)
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
   126
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
   127
        def dump_categories_active_dict(self, cat_ac_dict):
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
   128
                Thread(target = self.__dump_categories_active_dict,
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
   129
                    args = (cat_ac_dict, )).start()
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
   130
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
   131
        def load_categories_active_dict(self, cat_ac_dict):
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
   132
                Thread(target = self.__load_categories_active_dict,
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
   133
                    args = (cat_ac_dict, )).start()
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
   134
1219
8977dcf4ef8a 816 Provide Search Text completion
John Rice <john.rice@sun.com>
parents: 1217
diff changeset
   135
        def __dump_search_completion_info(self, completion_list):
8977dcf4ef8a 816 Provide Search Text completion
John Rice <john.rice@sun.com>
parents: 1217
diff changeset
   136
                cache_dir = self.__get_cache_dir()
8977dcf4ef8a 816 Provide Search Text completion
John Rice <john.rice@sun.com>
parents: 1217
diff changeset
   137
                if not cache_dir:
8977dcf4ef8a 816 Provide Search Text completion
John Rice <john.rice@sun.com>
parents: 1217
diff changeset
   138
                        return
8977dcf4ef8a 816 Provide Search Text completion
John Rice <john.rice@sun.com>
parents: 1217
diff changeset
   139
                texts = []
8977dcf4ef8a 816 Provide Search Text completion
John Rice <john.rice@sun.com>
parents: 1217
diff changeset
   140
                for text in completion_list:
8977dcf4ef8a 816 Provide Search Text completion
John Rice <john.rice@sun.com>
parents: 1217
diff changeset
   141
                        txt = {}
8977dcf4ef8a 816 Provide Search Text completion
John Rice <john.rice@sun.com>
parents: 1217
diff changeset
   142
                        txt["text"] = text[0]
8977dcf4ef8a 816 Provide Search Text completion
John Rice <john.rice@sun.com>
parents: 1217
diff changeset
   143
                        texts.append(txt)
8977dcf4ef8a 816 Provide Search Text completion
John Rice <john.rice@sun.com>
parents: 1217
diff changeset
   144
                try:
1686
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
   145
                        nongui_misc.dump_cache_file(
1219
8977dcf4ef8a 816 Provide Search Text completion
John Rice <john.rice@sun.com>
parents: 1217
diff changeset
   146
                            os.path.join(cache_dir, ".__search__completion.cpl"), texts)
8977dcf4ef8a 816 Provide Search Text completion
John Rice <john.rice@sun.com>
parents: 1217
diff changeset
   147
                except IOError:
8977dcf4ef8a 816 Provide Search Text completion
John Rice <john.rice@sun.com>
parents: 1217
diff changeset
   148
                        return
882
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff changeset
   149
1219
8977dcf4ef8a 816 Provide Search Text completion
John Rice <john.rice@sun.com>
parents: 1217
diff changeset
   150
        def __load_search_completion_info(self, completion_list):
8977dcf4ef8a 816 Provide Search Text completion
John Rice <john.rice@sun.com>
parents: 1217
diff changeset
   151
                cache_dir = self.__get_cache_dir()
8977dcf4ef8a 816 Provide Search Text completion
John Rice <john.rice@sun.com>
parents: 1217
diff changeset
   152
                if not cache_dir:
8977dcf4ef8a 816 Provide Search Text completion
John Rice <john.rice@sun.com>
parents: 1217
diff changeset
   153
                        return
8977dcf4ef8a 816 Provide Search Text completion
John Rice <john.rice@sun.com>
parents: 1217
diff changeset
   154
                texts = []
8977dcf4ef8a 816 Provide Search Text completion
John Rice <john.rice@sun.com>
parents: 1217
diff changeset
   155
                try:
1686
c3ce86de2702 13036 PM Persist expanded and selected Category state for each Publisher
John Rice <john.rice@sun.com>
parents: 1554
diff changeset
   156
                        texts = nongui_misc.read_cache_file(
1219
8977dcf4ef8a 816 Provide Search Text completion
John Rice <john.rice@sun.com>
parents: 1217
diff changeset
   157
                            os.path.join(cache_dir, ".__search__completion.cpl"))
8977dcf4ef8a 816 Provide Search Text completion
John Rice <john.rice@sun.com>
parents: 1217
diff changeset
   158
                except IOError:
8977dcf4ef8a 816 Provide Search Text completion
John Rice <john.rice@sun.com>
parents: 1217
diff changeset
   159
                        return gtk.ListStore(str)
882
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff changeset
   160
1219
8977dcf4ef8a 816 Provide Search Text completion
John Rice <john.rice@sun.com>
parents: 1217
diff changeset
   161
                txt_count = 0
8977dcf4ef8a 816 Provide Search Text completion
John Rice <john.rice@sun.com>
parents: 1217
diff changeset
   162
                for txt in texts:
8977dcf4ef8a 816 Provide Search Text completion
John Rice <john.rice@sun.com>
parents: 1217
diff changeset
   163
                        txt_val = txt.get("text")
8977dcf4ef8a 816 Provide Search Text completion
John Rice <john.rice@sun.com>
parents: 1217
diff changeset
   164
                        text = [ txt_val ]
8977dcf4ef8a 816 Provide Search Text completion
John Rice <john.rice@sun.com>
parents: 1217
diff changeset
   165
                        completion_list.insert(txt_count, text)
8977dcf4ef8a 816 Provide Search Text completion
John Rice <john.rice@sun.com>
parents: 1217
diff changeset
   166
                        txt_count += 1
8977dcf4ef8a 816 Provide Search Text completion
John Rice <john.rice@sun.com>
parents: 1217
diff changeset
   167
8977dcf4ef8a 816 Provide Search Text completion
John Rice <john.rice@sun.com>
parents: 1217
diff changeset
   168
        def dump_search_completion_info(self, completion_list):
8977dcf4ef8a 816 Provide Search Text completion
John Rice <john.rice@sun.com>
parents: 1217
diff changeset
   169
                Thread(target = self.__dump_search_completion_info,
8977dcf4ef8a 816 Provide Search Text completion
John Rice <john.rice@sun.com>
parents: 1217
diff changeset
   170
                    args = (completion_list, )).start()
8977dcf4ef8a 816 Provide Search Text completion
John Rice <john.rice@sun.com>
parents: 1217
diff changeset
   171
8977dcf4ef8a 816 Provide Search Text completion
John Rice <john.rice@sun.com>
parents: 1217
diff changeset
   172
        def load_search_completion_info(self, completion_list):
8977dcf4ef8a 816 Provide Search Text completion
John Rice <john.rice@sun.com>
parents: 1217
diff changeset
   173
                Thread(target = self.__load_search_completion_info,
8977dcf4ef8a 816 Provide Search Text completion
John Rice <john.rice@sun.com>
parents: 1217
diff changeset
   174
                    args = (completion_list, )).start()