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

from abrt_utils import _, init_logging, log, log1, log2

class DumpList(list):
    """Class to store list of debug dumps"""
    def __init__(self,dbus_manager=None):
        list.__init__(self)
        self.dm = dbus_manager

    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:
                        log2(" Dump.%s='%s'", column, row[column])
                        entry.__setattr__(column, row[column])
                    self.append(entry)
            except Exception:
                # FIXME handle exception better
                # this is just temporary workaround for rhbz#543725
                raise
        else:
            print "db == None!"

    def getDumpByCrashID(self, crashid):
        for dump in self:
            if crashid == dump.getDumpDir():
                return dump

__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