コード例 #1
0
def test_check_dependencies():
    response, deps = plugin_manager.check_dependencies(
        os.path.join(os.path.dirname(__file__), 'assets',
                     'requirements_never_there.txt'))
    assert 'You need these dependencies for' in response
    assert 'impossible_requirement' in response
    assert ['impossible_requirement'] == deps
コード例 #2
0
ファイル: repo_manager.py プロジェクト: Synforge/err
    def update_repos(self, repos):
        """
        This git pulls the specified repos on disk.
        Yields tuples like (name, success, reason)
        """
        git_path = which('git')
        if not git_path:
            yield ('everything', False,
                   'git command not found: You need to have git installed on '
                   'your system to be able to install git based plugins.')

        # protects for update outside of what we know is installed
        names = set(self.get_installed_plugin_repos().keys()).intersection(
            set(repos))

        for d in (path.join(self.plugin_dir, name) for name in names):
            p = subprocess.Popen([git_path, 'pull'],
                                 cwd=d,
                                 stdout=subprocess.PIPE,
                                 stderr=subprocess.PIPE)
            feedback = p.stdout.read().decode('utf-8') + '\n' + '-' * 50 + '\n'
            err = p.stderr.read().strip().decode('utf-8')
            if err:
                feedback += err + '\n' + '-' * 50 + '\n'
            dep_err = check_dependencies(d)
            if dep_err:
                feedback += dep_err + '\n'
            yield d, not p.wait(), feedback
コード例 #3
0
ファイル: repo_manager.py プロジェクト: errbotio/errbot
    def update_repos(self, repos):
        """
        This git pulls the specified repos on disk.
        Yields tuples like (name, success, reason)
        """
        git_path = which("git")
        if not git_path:
            yield (
                "everything",
                False,
                "git command not found: You need to have git installed on "
                "your system to be able to install git based plugins.",
            )

        # protects for update outside of what we know is installed
        names = set(self.get_installed_plugin_repos().keys()).intersection(set(repos))

        for d in (path.join(self.plugin_dir, name) for name in names):
            p = subprocess.Popen([git_path, "pull"], cwd=d, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
            feedback = p.stdout.read().decode("utf-8") + "\n" + "-" * 50 + "\n"
            err = p.stderr.read().strip().decode("utf-8")
            if err:
                feedback += err + "\n" + "-" * 50 + "\n"
            dep_err, missing_pkgs = check_dependencies(d)
            if dep_err:
                feedback += dep_err + "\n"
            yield d, not p.wait(), feedback
コード例 #4
0
    def update_repos(self, repos):
        """
        This git pulls the specified repos on disk.
        Yields tuples like (name, success, reason)
        """
        git_path = which('git')
        if not git_path:
            yield ('everything', False,
                   'git command not found: You need to have git installed on '
                   'your system to be able to install git based plugins.')

        # protects for update outside of what we know is installed
        names = set(self.get_installed_plugin_repos().keys()).intersection(
            set(repos))

        for d in (path.join(self.plugin_dir, name) for name in names):
            subprocess.check_call([git_path, 'fetch', 'origin', '--no-tags'],
                                  cwd=d,
                                  stderr=subprocess.STDOUT)
            subprocess.check_call([git_path, 'reset', '--hard', '@{upstream}'],
                                  cwd=d,
                                  stderr=subprocess.STDOUT)
            feedback = ''
            dep_err, missing_pkgs = check_dependencies(d)
            if dep_err:
                feedback += dep_err + '\n'
            yield d, True, feedback
コード例 #5
0
ファイル: plugin_management_test.py プロジェクト: zoni/errbot
def test_check_dependencies():
    response, deps = plugin_manager.check_dependencies(os.path.join(os.path.dirname(__file__),
                                                                    'assets',
                                                                    'requirements_never_there.txt'))
    assert 'You need these dependencies for' in response
    assert 'impossible_requirement' in response
    assert ['impossible_requirement'] == deps
コード例 #6
0
ファイル: errBot.py プロジェクト: sanketsudake/err
    def repos_update(self, mess, args):
        """ update the bot and/or plugins
        use : !repos update all
        to update everything
        or : !repos update core
        to update only the core
        or : !repos update repo_name repo_name ...
        to update selectively some repos
        """
        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 update git based plugins.'

        directories = set()
        repos = self.get(REPOS, {})
        core_to_update = 'all' in args or 'core' in args
        if core_to_update:
            directories.add(os.path.dirname(__file__))

        if 'all' in args:
            directories.update([self.plugin_dir + os.sep + name for name in repos])
        else:
            directories.update([self.plugin_dir + os.sep + name for name in set(args).intersection(set(repos))])

        for d in directories:
            self.send(mess.getFrom(), "I am updating %s ..." % d, message_type=mess.getType())
            p = subprocess.Popen([git_path, 'pull'], cwd=d, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
            feedback = p.stdout.read().decode('utf-8') + '\n' + '-' * 50 + '\n'
            err = p.stderr.read().strip().decode('utf-8')
            if err:
                feedback += err + '\n' + '-' * 50 + '\n'
            dep_err = check_dependencies(d)
            if dep_err:
                feedback += dep_err + '\n'
            if p.wait():
                self.send(mess.getFrom(), "Update of %s failed...\n\n%s\n\n resuming..." % (d, feedback), message_type=mess.getType())
            else:
                self.send(mess.getFrom(), "Update of %s succeeded...\n\n%s\n\n" % (d, feedback), message_type=mess.getType())
                if not core_to_update:
                    for plugin in get_all_plugins():
                        if plugin.path.startswith(d) and hasattr(plugin, 'is_activated') and plugin.is_activated:
                            name = plugin.name
                            self.send(mess.getFrom(), '/me is reloading plugin %s' % name)
                            self.deactivate_plugin(plugin.name)                 # calm the plugin down
                            module = __import__(plugin.path.split(os.sep)[-1])  # find back the main module of the plugin
                            reload(module)                                      # reload it
                            class_name = type(plugin.plugin_object).__name__    # find the original name of the class
                            newclass = getattr(module, class_name)              # retreive the corresponding new class
                            plugin.plugin_object.__class__ = newclass           # BAM, declare the instance of the new type
                            self.activate_plugin(plugin.name)                   # wake the plugin up
        if core_to_update:
            self.restart(mess, '')
            return "You have updated the core, I need to restart."
        return "Done."
コード例 #7
0
ファイル: plugins.py プロジェクト: nanorepublica/err
    def repos_update(self, mess, args):
        """ update the bot and/or plugins
        use : !repos update all
        to update everything
        or : !repos update core
        to update only the core
        or : !repos update repo_name repo_name ...
        to update selectively some repos
        """
        git_path = which("git")
        if not git_path:
            return (
                "git command not found: You need to have git installed on "
                "your system to be able to install git based plugins."
            )

        directories = set()
        repos = self._bot.get(self._bot.REPOS, {})
        core_to_update = "all" in args or "core" in args
        if core_to_update:
            directories.add(path.dirname(__file__))

        if "all" in args:
            directories.update([path.join(self._bot.plugin_dir, name) for name in repos])
        else:
            directories.update([path.join(self._bot.plugin_dir, name) for name in set(args).intersection(set(repos))])

        for d in directories:
            self.send(mess.frm, "I am updating %s ..." % d, message_type=mess.type)
            p = subprocess.Popen([git_path, "pull"], cwd=d, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
            feedback = p.stdout.read().decode("utf-8") + "\n" + "-" * 50 + "\n"
            err = p.stderr.read().strip().decode("utf-8")
            if err:
                feedback += err + "\n" + "-" * 50 + "\n"
            dep_err = check_dependencies(d)
            if dep_err:
                feedback += dep_err + "\n"
            if p.wait():
                self.send(
                    mess.frm, "Update of %s failed...\n\n%s\n\n resuming..." % (d, feedback), message_type=mess.type
                )
            else:
                self.send(mess.frm, "Update of %s succeeded...\n\n%s\n\n" % (d, feedback), message_type=mess.type)
                if not core_to_update:
                    for plugin in self._bot.getAllPlugins():
                        if plugin.path.startswith(d) and hasattr(plugin, "is_activated") and plugin.is_activated:
                            name = plugin.name
                            self.send(mess.frm, "/me is reloading plugin %s" % name)
                            self._bot.reload_plugin_by_name(plugin.name)
                            self.send(mess.frm, "%s reloaded and reactivated" % name)
        if core_to_update:
            self.send(mess.frm, "You have updated the core, I need to restart.", message_type=mess.type)
            global_restart()
        return "Done."
コード例 #8
0
ファイル: errBot.py プロジェクト: zoglesby/err
    def repos_update(self, mess, args):
        """ update the bot and/or plugins
        use : !repos update all
        to update everything
        or : !repos update core
        to update only the core
        or : !repos update repo_name repo_name ...
        to update selectively some repos
        """
        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 update git based plugins.'

        directories = set()
        repos = self.get('repos', {})
        core_to_update = 'all' in args or 'core' in args
        if core_to_update:
            directories.add(os.path.dirname(__file__))

        if 'all' in args:
            directories.update([PLUGIN_DIR+os.sep+name for name in repos])
        else:
            directories.update([PLUGIN_DIR+os.sep+name for name in set(args).intersection(set(repos))])

        for d in directories:
            self.send(mess.getFrom(), "I am updating %s ..." % d , message_type=mess.getType())
            p = subprocess.Popen([git_path, 'pull'], cwd=d, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
            feedback = p.stdout.read() + '\n' + '-'*50 + '\n'
            err = p.stderr.read().strip()
            if err:
                feedback += err + '\n' + '-'*50 + '\n'
            dep_err = check_dependencies(d)
            if dep_err:
                feedback += dep_err + '\n'
            if p.wait():
                self.send(mess.getFrom(), "Update of %s failed...\n\n%s\n\n resuming..." % (d,feedback) , message_type=mess.getType())
            else:
                self.send(mess.getFrom(), "Update of %s succeeded...\n\n%s\n\n" % (d,feedback) , message_type=mess.getType())
                if not core_to_update:
                    for plugin in get_all_plugins():
                        if plugin.path.startswith(d) and hasattr(plugin,'is_activated') and plugin.is_activated:
                            name = plugin.name
                            self.send(mess.getFrom(), '/me is reloading plugin %s' % name)
                            self.deactivate_plugin(plugin.name)                     # calm the plugin down
                            module = __import__(plugin.path.split(os.sep)[-1]) # find back the main module of the plugin
                            reload(module)                                     # reload it
                            class_name = type(plugin.plugin_object).__name__   # find the original name of the class
                            newclass = getattr(module, class_name)             # retreive the corresponding new class
                            plugin.plugin_object.__class__ = newclass          # BAM, declare the instance of the new type
                            self.activate_plugin(plugin.name)                  # wake the plugin up
        if core_to_update:
            self.restart(mess, '')
            return "You have updated the core, I need to restart."
        return "Done."
コード例 #9
0
ファイル: errBot.py プロジェクト: J4LP/rooster
    def repos_update(self, mess, args):
        """ update the bot and/or plugins
        use : !repos update all
        to update everything
        or : !repos update core
        to update only the core
        or : !repos update repo_name repo_name ...
        to update selectively some repos
        """
        git_path = which('git')
        if not git_path:
            return ('git command not found: You need to have git installed on '
                    'your system to be able to install git based plugins.')

        directories = set()
        repos = self.get(REPOS, {})
        core_to_update = 'all' in args or 'core' in args
        if core_to_update:
            directories.add(os.path.dirname(__file__))

        if 'all' in args:
            directories.update([self.plugin_dir + os.sep + name for name in repos])
        else:
            directories.update([self.plugin_dir + os.sep + name for name in set(args).intersection(set(repos))])

        for d in directories:
            self.send(mess.getFrom(), "I am updating %s ..." % d, message_type=mess.getType())
            p = subprocess.Popen([git_path, 'pull'], cwd=d, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
            feedback = p.stdout.read().decode('utf-8') + '\n' + '-' * 50 + '\n'
            err = p.stderr.read().strip().decode('utf-8')
            if err:
                feedback += err + '\n' + '-' * 50 + '\n'
            dep_err = check_dependencies(d)
            if dep_err:
                feedback += dep_err + '\n'
            if p.wait():
                self.send(mess.getFrom(), "Update of %s failed...\n\n%s\n\n resuming..." % (d, feedback),
                          message_type=mess.getType())
            else:
                self.send(mess.getFrom(), "Update of %s succeeded...\n\n%s\n\n" % (d, feedback),
                          message_type=mess.getType())
                if not core_to_update:
                    for plugin in get_all_plugins():
                        if plugin.path.startswith(d) and hasattr(plugin, 'is_activated') and plugin.is_activated:
                            name = plugin.name
                            self.send(mess.getFrom(), '/me is reloading plugin %s' % name)
                            reload_plugin_by_name(plugin.name)
                            self.activate_plugin(plugin.name)
                            self.send(mess.getFrom(), '%s reloaded and reactivated' % name)
        if core_to_update:
            self.restart(mess, '')
            return "You have updated the core, I need to restart."
        return "Done."
コード例 #10
0
ファイル: plugins.py プロジェクト: preoctopus/err
    def repos_update(self, mess, args):
        """ update the bot and/or plugins
        use : !repos update all
        to update everything
        or : !repos update core
        to update only the core
        or : !repos update repo_name repo_name ...
        to update selectively some repos
        """
        git_path = which('git')
        if not git_path:
            return ('git command not found: You need to have git installed on '
                    'your system to be able to install git based plugins.')

        directories = set()
        repos = self._bot.get(self._bot.REPOS, {})
        core_to_update = 'all' in args or 'core' in args
        if core_to_update:
            directories.add(path.dirname(__file__))

        if 'all' in args:
            directories.update([path.join(self._bot.plugin_dir, name) for name in repos])
        else:
            directories.update([path.join(self._bot.plugin_dir, name) for name in set(args).intersection(set(repos))])

        for d in directories:
            self.send(mess.frm, "I am updating %s ..." % d, message_type=mess.type)
            p = subprocess.Popen([git_path, 'pull'], cwd=d, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
            feedback = p.stdout.read().decode('utf-8') + '\n' + '-' * 50 + '\n'
            err = p.stderr.read().strip().decode('utf-8')
            if err:
                feedback += err + '\n' + '-' * 50 + '\n'
            dep_err = check_dependencies(d)
            if dep_err:
                feedback += dep_err + '\n'
            if p.wait():
                self.send(mess.frm, "Update of %s failed...\n\n%s\n\n resuming..." % (d, feedback),
                          message_type=mess.type)
            else:
                self.send(mess.frm, "Update of %s succeeded...\n\n%s\n\n" % (d, feedback),
                          message_type=mess.type)
                if not core_to_update:
                    for plugin in self._bot.getAllPlugins():
                        if plugin.path.startswith(d) and hasattr(plugin, 'is_activated') and plugin.is_activated:
                            name = plugin.name
                            self.send(mess.frm, '/me is reloading plugin %s' % name)
                            self._bot.reload_plugin_by_name(plugin.name)
                            self.send(mess.frm, '%s reloaded and reactivated' % name)
        if core_to_update:
            self.send(mess.frm, "You have updated the core, I need to restart.", message_type=mess.type)
            global_restart()
        return "Done."
コード例 #11
0
ファイル: repo_manager.py プロジェクト: Adman/errbot
    def update_repos(self, repos):
        """
        This git pulls the specified repos on disk.
        Yields tuples like (name, success, reason)
        """
        git_path = which('git')
        if not git_path:
            yield ('everything', False, 'git command not found: You need to have git installed on '
                                        'your system to be able to install git based plugins.')

        # protects for update outside of what we know is installed
        names = set(self.get_installed_plugin_repos().keys()).intersection(set(repos))

        for d in (path.join(self.plugin_dir, name) for name in names):
            p = subprocess.Popen([git_path, 'pull'], cwd=d, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
            feedback = p.stdout.read().decode('utf-8') + '\n' + '-' * 50 + '\n'
            err = p.stderr.read().strip().decode('utf-8')
            if err:
                feedback += err + '\n' + '-' * 50 + '\n'
            dep_err = check_dependencies(d)
            if dep_err:
                feedback += dep_err + '\n'
            yield d, not p.wait(), feedback
コード例 #12
0
 def test_check_dependencies(self):
     response = check_dependencies(os.path.dirname(__file__) + os.path.sep + 'assets')
     self.assertIn('impossible_requirement', response)
コード例 #13
0
ファイル: plugin_management_test.py プロジェクト: zoni/errbot
def test_check_dependencies_requirements_file_all_installed():
    response, deps = plugin_manager.check_dependencies(os.path.join(os.path.dirname(__file__),
                                                                    'assets',
                                                                    'requirements_already_there.txt'))
    assert response is None
コード例 #14
0
 def test_check_dependencies(self):
     response = check_dependencies(str(os.path.dirname(__file__)) + os.path.sep + "assets")
     self.assertIn("impossible_requirement", response)
コード例 #15
0
ファイル: plugin_management_test.py プロジェクト: zoni/errbot
def test_check_dependencies_no_requirements_file():
    response, deps = plugin_manager.check_dependencies(os.path.join(os.path.dirname(__file__),
                                                                    'assets',
                                                                    'requirements_non_existent.txt'))
    assert response is None
コード例 #16
0
def test_check_dependencies_no_requirements_file():
    response, deps = plugin_manager.check_dependencies(
        os.path.join(os.path.dirname(__file__), 'assets',
                     'requirements_non_existent.txt'))
    assert response is None
コード例 #17
0
ファイル: plugin_management_tests.py プロジェクト: dafvid/err
 def test_check_dependencies(self):
     response, deps = check_dependencies(
         str(os.path.dirname(__file__)) + os.path.sep + 'assets')
     self.assertIn('impossible_requirement', response)
     self.assertEqual(['impossible_requirement'], deps)
コード例 #18
0
ファイル: plugins.py プロジェクト: s905060/errbot
    def repos_update(self, mess, args):
        """ update the bot and/or plugins
        use : !repos update all
        to update everything
        or : !repos update core
        to update only the core
        or : !repos update repo_name repo_name ...
        to update selectively some repos
        """
        git_path = which('git')
        if not git_path:
            return ('git command not found: You need to have git installed on '
                    'your system to be able to install git based plugins.')

        directories = set()
        repos = {}
        _installed = self._bot.get_installed_plugin_repos()

        # Fix to migrate exiting plugins into new format
        for short_name, url in _installed.items():
            name = ('/'.join(url.split('/')[-2:])).replace('.git', '')

            t_installed = {name: {
                'path': url,
                'documentation': 'Unavilable',
                'python': None,
                'avatar_url': None,
                }
            }
            repos.update(t_installed)

        core_to_update = 'all' in args or 'core' in args
        if core_to_update:
            directories.add(path.dirname(__file__))

        if 'all' in args:
            directories.update([path.join(self._bot.plugin_dir, name) for name in repos])
        else:
            directories.update([path.join(self._bot.plugin_dir, name) for name in set(args).intersection(set(repos))])

        for d in directories:
            self.send(mess.frm, "I am updating %s ..." % d, message_type=mess.type)
            p = subprocess.Popen([git_path, 'pull'], cwd=d, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
            feedback = p.stdout.read().decode('utf-8') + '\n' + '-' * 50 + '\n'
            err = p.stderr.read().strip().decode('utf-8')
            if err:
                feedback += err + '\n' + '-' * 50 + '\n'
            dep_err = check_dependencies(d)
            if dep_err:
                feedback += dep_err + '\n'
            if p.wait():
                self.send(mess.frm, "Update of %s failed...\n\n%s\n\n resuming..." % (d, feedback),
                          message_type=mess.type)
            else:
                self.send(mess.frm, "Update of %s succeeded...\n\n%s\n\n" % (d, feedback),
                          message_type=mess.type)
                if not core_to_update:
                    for plugin in self._bot.getAllPlugins():
                        if plugin.path.startswith(d) and hasattr(plugin, 'is_activated') and plugin.is_activated:
                            name = plugin.name
                            self.send(mess.frm, '/me is reloading plugin %s' % name)
                            self._bot.reload_plugin_by_name(plugin.name)
                            self.send(mess.frm, '%s reloaded and reactivated' % name)
        if core_to_update:
            self.send(mess.frm, "You have updated the core, I need to restart.", message_type=mess.type)
            global_restart()
        return "Done."
コード例 #19
0
def test_check_dependencies_requirements_file_all_installed():
    response, deps = plugin_manager.check_dependencies(
        os.path.join(os.path.dirname(__file__), 'assets',
                     'requirements_already_there.txt'))
    assert response is None
コード例 #20
0
 def test_check_dependencies(self):
     response, deps = plugin_manager.check_dependencies(str(os.path.dirname(__file__)) + os.path.sep + 'assets')
     self.assertIn('impossible_requirement', response)
     self.assertEqual(['impossible_requirement'], deps)
コード例 #21
0
def test_check_dependencies():
    response, deps = plugin_manager.check_dependencies(str(os.path.dirname(__file__)) + os.path.sep + 'assets')
    assert 'impossible_requirement' in response
    assert ['impossible_requirement'] == deps