def restart(self, mess, args): """ restart the bot """ self.send(mess.getFrom(), "Deactivating all the plugins...") deactivate_all_plugins() self.send(mess.getFrom(), "Restarting") global_restart() return "I'm restarting..."
def restart(self, mess, args): """ Restart the bot. """ self.send(mess.frm, "Deactivating all the plugins...") self._bot.deactivate_all_plugins() self.send(mess.frm, "Restarting") self._bot.shutdown() global_restart() return "I'm restarting..."
def restart(self, msg, args): """ Restart the bot. """ self.send(msg.frm, "Deactivating all the plugins...") self._bot.plugin_manager.deactivate_all_plugins() self.send(msg.frm, "Restarting") self._bot.shutdown() global_restart() return "I'm restarting..."
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."
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."
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."