Back to index

obnam  1.1
Public Member Functions
obnamlib.plugins.force_lock_plugin.ForceLockPlugin Class Reference
Inheritance diagram for obnamlib.plugins.force_lock_plugin.ForceLockPlugin:
Inheritance graph
[legend]
Collaboration diagram for obnamlib.plugins.force_lock_plugin.ForceLockPlugin:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def enable
def force_lock

Detailed Description

Definition at line 23 of file force_lock_plugin.py.


Member Function Documentation

Definition at line 25 of file force_lock_plugin.py.

00025 
00026     def enable(self):
00027         self.app.add_subcommand('force-lock', self.force_lock)

Here is the call graph for this function:

Force a locked repository to be open.

Definition at line 28 of file force_lock_plugin.py.

00028 
00029     def force_lock(self, args):
00030         '''Force a locked repository to be open.'''
00031         self.app.settings.require('repository')
00032         self.app.settings.require('client-name')
00033 
00034         repourl = self.app.settings['repository']
00035         client_name = self.app.settings['client-name']
00036         logging.info('Forcing lock')
00037         logging.info('Repository: %s' % repourl)
00038         logging.info('Client: %s' % client_name)
00039 
00040         try:
00041             repo = self.app.open_repository()
00042         except OSError, e:
00043             raise obnamlib.Error('Repository does not exist ' 
00044                                   'or cannot be accessed.\n' +
00045                                   str(e))
00046 
00047         all_clients = repo.list_clients()
00048         if client_name not in all_clients:
00049             msg = 'Client does not exist in repository.'
00050             logging.warning(msg)
00051             self.app.output.write('Warning: %s\n' % msg)
00052             return
00053 
00054         all_dirs = ['clientlist', 'chunksums', 'chunklist', 'chunks', '.']
00055         for client_name in all_clients:
00056             client_id = repo.clientlist.get_client_id(client_name)
00057             client_dir = repo.client_dir(client_id)
00058             all_dirs.append(client_dir)
00059 
00060         for one_dir in all_dirs:
00061             lockname = os.path.join(one_dir, 'lock')
00062             if repo.fs.exists(lockname):
00063                 logging.info('Removing lockfile %s' % lockname)
00064                 repo.fs.remove(lockname)
00065             else:
00066                 logging.info('%s is not locked' % one_dir)
00067 
00068         repo.fs.close()
00069 
00070         return 0

Here is the caller graph for this function:


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