Back to index

obnam  1.1
Public Member Functions | Public Attributes
obnamlib.plugins.forget_plugin.ForgetPlugin Class Reference
Inheritance diagram for obnamlib.plugins.forget_plugin.ForgetPlugin:
Inheritance graph
[legend]
Collaboration diagram for obnamlib.plugins.forget_plugin.ForgetPlugin:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def enable
def forget
def remove

Public Attributes

 repo

Detailed Description

Forget generations.

Definition at line 22 of file forget_plugin.py.


Member Function Documentation

Definition at line 26 of file forget_plugin.py.

00026 
00027     def enable(self):
00028         self.app.add_subcommand('forget', self.forget,
00029                                 arg_synopsis='[GENERATION]...')
00030         self.app.settings.string(['keep'],
00031                                   'policy for what generations to keep '
00032                                   'when forgetting')

Here is the call graph for this function:

Forget (remove) specified backup generations.

Definition at line 33 of file forget_plugin.py.

00033 
00034     def forget(self, args):
00035         '''Forget (remove) specified backup generations.'''
00036         self.app.settings.require('repository')
00037         self.app.settings.require('client-name')
00038         
00039         self.app.ts['gen'] = None
00040         self.app.ts['gens'] = []
00041         self.app.ts.format('forgetting generations: %Index(gen,gens) done')
00042 
00043         self.repo = self.app.open_repository()
00044         self.repo.lock_client(self.app.settings['client-name'])
00045         self.repo.lock_shared()
00046 
00047         self.app.dump_memory_profile('at beginning')
00048         if args:
00049             self.app.ts['gens'] = args
00050             for genspec in args:
00051                 self.app.ts['gen'] = genspec
00052                 genid = self.repo.genspec(genspec)
00053                 self.app.ts.notify('Forgetting generation %s' % genid)
00054                 self.remove(genid)
00055                 self.app.dump_memory_profile('after removing %s' % genid)
00056         elif self.app.settings['keep']:
00057             genlist = []
00058             dt = datetime.datetime(1970, 1, 1, 0, 0, 0)
00059             for genid in self.repo.list_generations():
00060                 start, end = self.repo.get_generation_times(genid)
00061                 genlist.append((genid, dt.fromtimestamp(end)))
00062 
00063             fp = obnamlib.ForgetPolicy()
00064             rules = fp.parse(self.app.settings['keep'])
00065             keeplist = fp.match(rules, genlist)
00066             keepids = set(genid for genid, dt in keeplist)
00067             removeids = [genid 
00068                          for genid, dt in genlist 
00069                          if genid not in keepids]
00070 
00071             self.app.ts['gens'] = removeids
00072             for genid in removeids:
00073                 self.app.ts['gen'] = genid
00074                 self.remove(genid)
00075                 self.app.dump_memory_profile('after removing %s' % genid)
00076 
00077         self.repo.commit_client()
00078         self.repo.commit_shared()
00079         self.app.dump_memory_profile('after committing')
00080         self.repo.fs.close()
00081         self.app.ts.finish()

Here is the caller graph for this function:

Definition at line 82 of file forget_plugin.py.

00082 
00083     def remove(self, genid):
00084         if self.app.settings['pretend']:
00085             self.app.ts.notify('Pretending to remove generation %s' % genid)
00086         else:
00087             self.repo.remove_generation(genid)
00088 

Here is the caller graph for this function:


Member Data Documentation

Definition at line 42 of file forget_plugin.py.


The documentation for this class was generated from the following file: