~beuno/bzr/automatic_plugins

« back to all changes in this revision

Viewing changes to install_plugin.py

  • Committer: Martin Albisetti
  • Date: 2008-05-25 06:06:31 UTC
  • Revision ID: argentina@gmail.com-20080525060631-euipm62zfepnwemd
 * Update error handeling
 * Temporarily added custom errors

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
    def install_by_plugin_name(self, plugin_name):
25
25
        
26
26
        if(self.check_if_installed(plugin_name) is True):
27
 
            #raise PluginAlreadyInstalled
28
 
            print 'Plugin already installed'
 
27
            # FIXME: Update to use errors in bzrlib
 
28
            raise PluginAlreadyInstalled(plugin_name)
29
29
        else:
30
30
            try:
31
31
                plugin_data = plugin_db.__dict__[plugin_name]
32
32
            except KeyError:
33
 
                print 'Unknown plugin'
34
 
                return
 
33
                # FIXME: Update to user errors in bzrlib
 
34
                raise NoPluginAvailable(plugin_name)
35
35
            plugin_install_path = os.path.join(plugin_path[0], plugin_name)
36
36
            accelerator_tree, source = bzrdir.BzrDir.open_tree_or_branch(plugin_data['url'])
37
37
            source.create_checkout(plugin_install_path, None, True, 
53
53
                return True
54
54
        return False
55
55
 
 
56
 
 
57
class NoPluginAvailable(errors.BzrError):
 
58
 
 
59
    def __init__(self, plugin_name):
 
60
        self.plugin_name = plugin_name
 
61
 
 
62
    _fmt = '"%(plugin_name)s" is not a recognized plugin.'
 
63
 
 
64
 
 
65
class PluginAlreadyInstalled(errors.BzrError):
 
66
 
 
67
    def __init__(self, plugin_name):
 
68
        self.plugin_name = plugin_name
 
69
                                             
 
70
    _fmt = '"%(plugin_name)s" is already installed.'