Exemple #1
0
    def install(self, mess, args):
        """ install a plugin repository from the given source or a known public repo (see !repos to find those).
        for example from a known repo : !install err-codebot
        for example a git url : [email protected]:gbin/plugin.git
        or an url towards a tar.gz archive : http://www.gootz.net/plugin-latest.tar.gz
        """
        if not args.strip():
            return "You should have an urls/git repo argument"
        if args in KNOWN_PUBLIC_REPOS:
            args = KNOWN_PUBLIC_REPOS[args][0] # replace it by the url
        git_path = which('git')

        if not git_path:
            return 'git command not found: You need to have git installed on your system to by able to install git based plugins.'

        if args.endswith('tar.gz'):
            tar = TarFile(fileobj=urlopen(args))
            tar.extractall(path= PLUGIN_DIR)
            human_name = args.split('/')[-1][:-7]
        else:
            human_name = human_name_for_git_url(args)
            p = subprocess.Popen([git_path, 'clone', args, human_name], cwd = PLUGIN_DIR, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
            feedback = p.stdout.read()
            error_feedback = p.stderr.read()
            if p.wait():
               return "Could not load this plugin : \n%s\n---\n%s" % (feedback, error_feedback)
        self.add_plugin_repo(human_name, args)
        errors = self.update_dynamic_plugins()
        if errors:
            self.send(mess.getFrom(), 'Some plugins are generating errors:\n' + '\n'.join(errors) , message_type=mess.getType())
        else:
            self.send(mess.getFrom(), "A new plugin repository named %s has been installed correctly from %s. Refreshing the plugins commands..." % (human_name, args), message_type=mess.getType())
        self.activate_non_started_plugins()
        return "Plugin reload done."
Exemple #2
0
    def repos_install(self, mess, args):
        """ install a plugin repository from the given source or a known public repo (see !repos to find those).
        for example from a known repo : !install err-codebot
        for example a git url : [email protected]:gbin/plugin.git
        or an url towards a tar.gz archive : http://www.gootz.net/plugin-latest.tar.gz
        """
        if not args.strip():
            return "You should have an urls/git repo argument"
        if args in KNOWN_PUBLIC_REPOS:
            args = KNOWN_PUBLIC_REPOS[args][0]  # replace it by the url
        git_path = which('git')

        if not git_path:
            return 'git command not found: You need to have git installed on your system to by able to install git based plugins.'

        if args.endswith('tar.gz'):
            tar = TarFile(fileobj=urlopen(args))
            tar.extractall(path=self.plugin_dir)
            human_name = args.split('/')[-1][:-7]
        else:
            human_name = human_name_for_git_url(args)
            p = subprocess.Popen([git_path, 'clone', args, human_name], cwd=self.plugin_dir, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
            feedback = p.stdout.read().decode('utf-8')
            error_feedback = p.stderr.read().decode('utf-8')
            if p.wait():
                return "Could not load this plugin : \n%s\n---\n%s" % (feedback, error_feedback)
        self.add_plugin_repo(human_name, args)
        errors = self.update_dynamic_plugins()
        if errors:
            self.send(mess.getFrom(), 'Some plugins are generating errors:\n' + '\n'.join(errors), message_type=mess.getType())
        else:
            self.send(mess.getFrom(), "A new plugin repository named %s has been installed correctly from %s. Refreshing the plugins commands..." % (human_name, args), message_type=mess.getType())
        self.activate_non_started_plugins()
        return "Plugin reload done."
Exemple #3
0
    def _git_follow_url(self, git_url, heads_to_follow):
        human_name = human_name_for_git_url(git_url)
        if self.has_key(human_name):
            fetch_all_heads(human_name)
            current_entry = self[human_name]
        else:
            human_name = clone(git_url)
            current_entry = []

        current_entry_dict = dict(current_entry)
        current_entry = [pair for pair in get_heads_revisions(human_name) if pair[0] in heads_to_follow or pair[0] in current_entry_dict] if heads_to_follow else get_heads_revisions(human_name)
        self[human_name] = current_entry
        return self.git_following(None, None)
Exemple #4
0
    def _git_follow_url(self, git_url, heads_to_follow):
        human_name = human_name_for_git_url(git_url).encode('utf-8')
        if human_name in self:
            self.fetch_all_heads(human_name)
            current_entry = self[human_name]
        else:
            human_name = self.clone(git_url).encode('utf-8')
            current_entry = []

        current_entry_dict = dict(current_entry)
        current_entry = [pair for pair in self.get_heads_revisions(human_name) if pair[0] in heads_to_follow or pair[0] in current_entry_dict] if heads_to_follow else self.get_heads_revisions(human_name)
        self[human_name] = current_entry
        return self.git_following(None, None)
Exemple #5
0
    def _git_follow_url(self, git_url, heads_to_follow):
        human_name = human_name_for_git_url(git_url)
        if human_name in self:
            self.fetch_all_heads(human_name)
            current_entry = self[human_name]
        else:
            human_name = self.clone(git_url)
            current_entry = []

        current_entry_dict = dict(current_entry)
        current_entry = [pair for pair in self.get_heads_revisions(human_name) if pair[0] in heads_to_follow or pair[0] in current_entry_dict] if heads_to_follow else self.get_heads_revisions(human_name)
        self[human_name] = current_entry
        return self.git_following(None, None)
Exemple #6
0
    def _git_follow_url(self, git_url, heads_to_follow):
        human_name = human_name_for_git_url(git_url)
        with self.ggl:
            if self.shelf.has_key(human_name):
                fetch_all_heads(human_name)
                current_entry = self.shelf[human_name]
            else:
                human_name = clone(git_url)
                current_entry = []

            current_entry_dict = dict(current_entry)
            current_entry = [
                pair for pair in get_heads_revisions(human_name)
                if pair[0] in heads_to_follow or pair[0] in current_entry_dict
            ] if heads_to_follow else get_heads_revisions(human_name)
            self.shelf[human_name] = current_entry
            self.shelf.sync()

            return self.following(None, None)
Exemple #7
0
def clone(url):
    human_name = human_name_for_git_url(url)
    g = Git()
    g.clone(url, human_to_path(human_name), bare=True)
    return human_name
Exemple #8
0
 def clone(self, url):
     human_name = human_name_for_git_url(url)
     g = Git()
     g.clone(url, self.human_to_path(human_name), bare=True)
     return human_name