Back to index

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

List of all members.

Public Member Functions

def enable
def convert
def convert_files
def find_files
def get_symmetric_key
def decrypt
def gunzip
def convert_format

Public Attributes

 rawfs
 repo
 symmetric_keys

Detailed Description

Convert a version 5 repository to version 6, in place.

Definition at line 27 of file convert5to6_plugin.py.


Member Function Documentation

Definition at line 34 of file convert5to6_plugin.py.

00034 
00035     def convert(self, args):
00036         self.app.settings.require('repository')
00037 
00038         self.rawfs = self.app.fsf.new(self.app.settings['repository'])
00039         self.convert_format()
00040         self.repo = self.app.open_repository()
00041         self.convert_files()

Here is the caller graph for this function:

Definition at line 42 of file convert5to6_plugin.py.

00042 
00043     def convert_files(self):
00044         funcs = []
00045         if self.app.settings['compress-with'] == 'gzip':
00046             funcs.append(self.gunzip)
00047         if self.app.settings['encrypt-with']:
00048             self.symmetric_keys = {}
00049             funcs.append(self.decrypt)
00050         tracing.trace('funcs=%s' % repr(funcs))
00051 
00052         for filename in self.find_files():
00053             logging.debug('converting file %s' % filename)
00054             data = self.rawfs.cat(filename)
00055             tracing.trace('old data is %d bytes' % len(data))
00056             for func in funcs:
00057                 data = func(filename, data)
00058             tracing.trace('new data is %d bytes' % len(data))
00059             self.repo.fs.overwrite_file(filename, data)

Here is the call graph for this function:

Definition at line 85 of file convert5to6_plugin.py.

00085 
00086     def convert_format(self):
00087         self.rawfs.overwrite_file('metadata/format', '6\n')
00088 
def obnamlib.plugins.convert5to6_plugin.Convert5to6Plugin.decrypt (   self,
  filename,
  data 
)

Definition at line 78 of file convert5to6_plugin.py.

00078 
00079     def decrypt(self, filename, data):
00080         symmetric_key = self.get_symmetric_key(filename)
00081         return obnamlib.decrypt_symmetric(data, symmetric_key)

Here is the call graph for this function:

Definition at line 31 of file convert5to6_plugin.py.

00031 
00032     def enable(self):
00033         self.app.add_subcommand('convert5to6', self.convert, arg_synopsis='')

Here is the call graph for this function:

Definition at line 60 of file convert5to6_plugin.py.

00060 
00061     def find_files(self):
00062         ignored_pat = re.compile(r'^(tmp.*|lock|format|userkeys|key)$')
00063         for filename, st in self.rawfs.scan_tree('.'):
00064             ignored = ignored_pat.match(os.path.basename(filename))
00065             if stat.S_ISREG(st.st_mode) and not ignored:
00066                 assert filename.startswith('./')
00067                 yield filename[2:]

Definition at line 68 of file convert5to6_plugin.py.

00068 
00069     def get_symmetric_key(self, filename):
00070         toplevel = filename.split('/')[0]
00071         tracing.trace('toplevel=%s' % toplevel)
00072 
00073         if toplevel not in self.symmetric_keys:
00074             encoded = self.rawfs.cat(os.path.join(toplevel, 'key'))
00075             key = obnamlib.decrypt_with_secret_keys(encoded)
00076             self.symmetric_keys[toplevel] = key
00077         return self.symmetric_keys[toplevel]

Here is the caller graph for this function:

def obnamlib.plugins.convert5to6_plugin.Convert5to6Plugin.gunzip (   self,
  filename,
  data 
)

Definition at line 82 of file convert5to6_plugin.py.

00082 
00083     def gunzip(self, filename, data):
00084         return zlib.decompress(data)
        

Here is the caller graph for this function:


Member Data Documentation

Definition at line 37 of file convert5to6_plugin.py.

Definition at line 39 of file convert5to6_plugin.py.

Definition at line 47 of file convert5to6_plugin.py.


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