~hdlorean-core/hdlorean/snapshot-manager

« back to all changes in this revision

Viewing changes to src/hdloreand/snapshotManager/SnapshotManager.py

  • Committer: Salvador de la Puente González
  • Date: 2008-05-15 14:45:11 UTC
  • Revision ID: neo.salvador@gmail.com-20080515144511-na7fkq64gbm9ch2w
Mergeado con snapshotManager a tope

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
import mimetypes
24
24
import os
25
25
import subprocess
 
26
import thread
 
27
import threading
26
28
 
27
29
from db import Journal
28
30
from db import History
81
83
        ##@brief Dictionary with all wrappers associated by their names.
82
84
        #
83
85
        __storageDictionary = {}
 
86
        
 
87
        ##@brief Dictionary with info of processes notifications such as (and
 
88
        # just by now) percentage completed.
 
89
        #
 
90
        __notificationsInfo = {}
 
91
        
 
92
        ##@brief Lock to control acess of __notoificationsInfo dictionary
 
93
        #
 
94
        __lockNI = None
84
95
 
85
96
        ##@brief Default constructor.
86
97
        #
96
107
                        # To get and set HD Lorean settings
97
108
                        self.__configFile = ConfigFileManager.ConfigFileManager()
98
109
                        self.__backupsPath = self.__configFile.getBackupDirectory()
 
110
                        
 
111
                        # Set notificationInfo dictionary
 
112
                        self.__lockNI = threading.Lock()
 
113
                        #TODO: Inicializar DBUS para el envio de señales
99
114
                
100
 
                        self.__done = True              
 
115
                        self.__done = True
101
116
 
102
117
        ##@brief Reload configfile manager settings.
103
118
        #
131
146
                        self.__storageManager = XDelta3Wrapper.XDelta3Wrapper(self)
132
147
 
133
148
                self.__storageDictionary[manager] = self.__storageManager
 
149
                
 
150
        ##@brief Lets a process to update (or create if it does not exist) its
 
151
        # completation log.
 
152
        #
 
153
        #@param pid process id, key of the event
 
154
        #@param percentage actual percentage of the process
 
155
        #@param toSent by default is False. If its setted to True, a signal is sent
 
156
        # to DBUS in order to notificate something to the frontend. Usefull for
 
157
        # progression bars.
 
158
        def updateCompletationInfo(self, pid, percentage, toSent = False):
 
159
                """
 
160
                Lets a process to update (or create if it does not exist) its
 
161
                completation log.
 
162
                """
 
163
                self.__lockNI.acquire()
 
164
                try:
 
165
                        self.__notificationsInfo[pid] = percentage
 
166
                        if toSent:
 
167
                                pass # TODO: Send to DBUS
 
168
                finally:
 
169
                        self.__lockNI.release()
 
170
                        
 
171
        ##@brief Delete a completation log.
 
172
        #
 
173
        #@param pid process identifier key of the log
 
174
        #@param toSent by default is False. If its setted to True, a signal is sent
 
175
        # to DBUS in order to notificate something to the frontend. It happens just
 
176
        # before delete the log. Usefull for progression bars.
 
177
        def releaseCompletationInfo(self, pid, toSent = False):
 
178
                self.__lockNI.acquire()
 
179
                try:
 
180
                        if toSent:
 
181
                                pass # TODO: Send to DBUS
 
182
                        if pid in self.__notificationsInfo:
 
183
                                del self.__notificationsInfo[pid]
 
184
                finally:
 
185
                        self.__lockNI.release()
 
186
                
134
187
 
135
188
        ##@brief Gets a storage manager by its name.
136
189
        #