~hdlorean-db/hdlorean/db

« back to all changes in this revision

Viewing changes to src/console/hdlorean.py

  • Committer: Mario Arnaldos
  • Date: 2008-03-12 23:48:18 UTC
  • mfrom: (16.13.5 unstable)
  • Revision ID: ender.dragon@gmail.com-20080312234818-slxcw5kd2qakfejp
recovering... now console recovers snapshots

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
        
18
18
 
19
19
        ##@brief Create a Snapshot, adding the path to the config file if not set before.
20
 
        #
 
20
        #TODO still not implemented
21
21
        #@param frontend frontendproxy to use
22
22
        #@param pathList list of paths to backup
23
23
        #@return true if the backup set was succesfully made
24
24
        #@author Fede & Ender
25
25
        def makeSnapshot(self, pathList):
26
26
                #print "entrando en make"
27
 
                self.__frontend.makeSnapshot(pathList, True)
 
27
                #self.__frontend.makeSnapshot(pathList, True)
 
28
                print "Still not implemented"
28
29
        
29
30
        ##@brief #prints the list of snapshots in time order.
30
31
        #
37
38
        
38
39
        
39
40
        ##@brief Lists the content of a path in a date of snapshot.
40
 
        #TODO:hacerlo, básicamente
 
41
        #
41
42
        #@param arguments The arguments passed through the command line, should be the path and the date.
42
43
        #@param storageMngr The StoreManager
43
44
        #@author Fede & Ender
45
46
                #print "entrando en getsnapthos"
46
47
                #print "timestamp"
47
48
                print self.__frontend.getDirList(timestamp,"/")
48
 
        #       for path in contentList:
49
 
        #               #print path
50
49
        
51
50
        
52
51
        ##@brief Recover the previous snapshot of a path.
58
57
        #@author Fede & Ender
59
58
        def recoverBackups(self, destinationPath, timestamp, pathList):
60
59
                #print "entrando en recover"
61
 
                self.__frontend.recoverBackups(timestamp,pathList, destinationPath)
 
60
                #print destinationPath
 
61
                #print pathList
 
62
                #print timestamp
 
63
                if pathList==None:
 
64
                        return self.__frontend.recoverSnapshot(timestamp, destinationPath)
 
65
                else:
 
66
                        return self.__frontend.recoverBackups(timestamp,pathList, destinationPath)
62
67
        
63
68
        
64
69
        ##@brief (Still NOT implemented) Erase a snapshot.
100
105
                assert value is None
101
106
                
102
107
                value=[170,1,1,0,0,0]
103
 
                print value
 
108
                
 
109
                #print value
 
110
                
104
111
                done=0
105
112
                rargs=parser.rargs
106
113
                
117
124
                                del rargs[0]
118
125
                        done=done+1
119
126
                        
120
 
                print "antes de la conversión"
121
 
                print value
 
127
                #print "antes de la conversión"
 
128
                #print value
122
129
                value=calendar.timegm(value)
123
 
                print "después de la conversión"
124
 
                print value
 
130
                #print "después de la conversión"
 
131
                #print value
125
132
                setattr(parser.values, option.dest, value)
126
133
        
127
134
        ##@brief Main loop to catch the command line arguments and do the right things.
144
151
                parser.add_option("-r","--recover", action="store_true", dest="recover", default=False,
145
152
                                                help="Recover files. Default all in snapshot. If not time is given, last snapshot. If not backup path(r) is given, all files in snapshot.")
146
153
                parser.add_option("-b", "--backup=",
147
 
                                                action="callback",callback=self.__pathRecover,dest="pathList",default="/",
 
154
                                                action="callback",callback=self.__pathRecover,dest="pathList",default=None,
148
155
                                                help="Recover just some files. Recover the path(s) you define")
149
156
                parser.add_option("-T","--target", dest="destinationPath",default=os.getcwd(),
150
157
                                                help="Destination path for the recover action. Default, actual path")
162
169
 
163
170
                
164
171
                (options, args) = parser.parse_args()
 
172
                #FIXME: Quitar esto cuando se entregue
165
173
                print parser.parse_args()
166
174
                
 
175
                
 
176
                printpath=""
167
177
                if options.listar:
168
178
                        self.listTimeOfSnapshots()
169
179
                elif options.recover:
170
 
                        self.recoverBackups(options.destinationPath, options.timestamp, options.pathList)
 
180
                         printpath=self.recoverBackups(options.destinationPath, options.timestamp, options.pathList)
 
181
                         print "Recovered files in:"
 
182
                         print printpath
171
183
                elif options.info:
172
184
                        self.getSnapshotInfo(options.timeStamp)
173
185
                elif options.makePathList != False:
180
192
                elif options.stop:
181
193
                        self.stopDaemon()
182
194
                else:
183
 
                        parser.print_help(),
 
195
                        parser.print_help()
 
196
                
184
197
                        
185
198
if __name__ == "__main__":
186
199
        console=hdlorean()