summaryrefslogtreecommitdiffstats
path: root/src/Gui/CCDumpList.py
blob: 3320af866a7d2c2198dc869ba7e0c910b47ed199 (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
# -*- coding: utf-8 -*-
import CCDBusBackend
from CCDump import Dump

class DumpList(list):
    """Class to store list of debug dumps"""
    def __init__(self,dbus_manager=None):
        self.dm = dbus_manager
        self.ddict = {}
    
    def load(self):
        if self.dm:
            #print "loading DumpList"
            try:
                rows = self.dm.getDumps()
                #print rows
                for row in rows:
                    entry = Dump()
                    for column in row:
                        #print "DumpList adding %s:%s" % (column,row[column])
                        entry.__dict__[column] = row[column]
                    self.append(entry)
                    self.ddict[entry.getUUID()] = entry
            except Exception, e:
                print e
                return
        else:
            print "db == None!"
                

__PFList = None
__PFList_dbmanager = None

def getDumpList(dbmanager,refresh=None):
    global __PFList
    global __PFList_dbmanager

    if __PFList == None or refresh or __PFList_dbmanager != dbmanager:
        __PFList = DumpList(dbus_manager=dbmanager)
        __PFList.load()
        __PFList_dbmanager = dbmanager
    return __PFList

__PFList = None