Beispiel #1
0
    def parse(config: ConfigParser) -> 'PluginInfo':
        """
        Throws ConfigParserError with a meaningful message if the ConfigParser doesn't contain the minimal
         information required.
        """
        name = config.get('Core', 'Name')
        module = config.get('Core', 'Module')
        core = config.get('Core', 'Core', fallback='false').lower() == 'true'
        doc = config.get('Documentation', 'Description', fallback=None)

        python_version = config.get('Python', 'Version', fallback=None)
        # Old format backward compatibility
        if python_version:
            if python_version in ('2+', '3'):
                python_version = (3, 0, 0)
            elif python_version == '2':
                python_version = (2, 0, 0)
            else:
                try:
                    python_version = tuple(
                        version2tuple(python_version)
                        [0:3])  # We can ignore the alpha/beta part.
                except ValueError as ve:
                    raise ConfigParserError(
                        f'Invalid Python Version format: {python_version} ({ve})'
                    )

        min_version = config.get('Errbot', 'Min', fallback=None)
        max_version = config.get('Errbot', 'Max', fallback=None)
        try:
            if min_version:
                min_version = version2tuple(min_version)
        except ValueError as ve:
            raise ConfigParserError(
                f'Invalid Errbot min version format: {min_version} ({ve})')

        try:
            if max_version:
                max_version = version2tuple(max_version)
        except ValueError as ve:
            raise ConfigParserError(
                f'Invalid Errbot max version format: {max_version} ({ve})')
        depends_on = config.get('Core', 'DependsOn', fallback=None)
        deps = [name.strip()
                for name in depends_on.split(',')] if depends_on else []

        return PluginInfo(name, module, doc, core, python_version, min_version,
                          max_version, deps)
Beispiel #2
0
    def parse(config: ConfigParser) -> "PluginInfo":
        """
        Throws ConfigParserError with a meaningful message if the ConfigParser doesn't contain the minimal
         information required.
        """
        name = config.get("Core", "Name")
        module = config.get("Core", "Module")
        core = config.get("Core", "Core", fallback="false").lower() == "true"
        doc = config.get("Documentation", "Description", fallback=None)

        python_version = config.get("Python", "Version", fallback=None)
        # Old format backward compatibility
        if python_version:
            if python_version in ("2+", "3"):
                python_version = (3, 0, 0)
            elif python_version == "2":
                python_version = (2, 0, 0)
            else:
                try:
                    python_version = tuple(
                        version2tuple(python_version)
                        [0:3])  # We can ignore the alpha/beta part.
                except ValueError as ve:
                    raise ConfigParserError(
                        f"Invalid Python Version format: {python_version} ({ve})"
                    )

        min_version = config.get("Errbot", "Min", fallback=None)
        max_version = config.get("Errbot", "Max", fallback=None)
        try:
            if min_version:
                min_version = version2tuple(min_version)
        except ValueError as ve:
            raise ConfigParserError(
                f"Invalid Errbot min version format: {min_version} ({ve})")

        try:
            if max_version:
                max_version = version2tuple(max_version)
        except ValueError as ve:
            raise ConfigParserError(
                f"Invalid Errbot max version format: {max_version} ({ve})")
        depends_on = config.get("Core", "DependsOn", fallback=None)
        deps = [name.strip()
                for name in depends_on.split(",")] if depends_on else []

        return PluginInfo(name, module, doc, core, python_version, min_version,
                          max_version, deps)
Beispiel #3
0
    def parse(config: ConfigParser) -> 'PluginInfo':
        """
        Throws ConfigParserError with a meaningful message if the ConfigParser doesn't contain the minimal
         information required.
        """
        name = config.get('Core', 'Name')
        module = config.get('Core', 'Module')
        core = config.get('Core', 'Core', fallback='false').lower() == 'true'
        doc = config.get('Documentation', 'Description', fallback=None)

        python_version = config.get('Python', 'Version', fallback=None)
        # Old format backward compatibility
        if python_version:
            if python_version in ('2+', '3'):
                python_version = (3, 0, 0)
            elif python_version == '2':
                python_version = (2, 0, 0)
            else:
                try:
                    python_version = tuple(version2tuple(python_version)[0:3])  # We can ignore the alpha/beta part.
                except ValueError as ve:
                    raise ConfigParserError(f'Invalid Python Version format: {python_version} ({ve})')

        min_version = config.get('Errbot', 'Min', fallback=None)
        max_version = config.get('Errbot', 'Max', fallback=None)
        try:
            if min_version:
                min_version = version2tuple(min_version)
        except ValueError as ve:
            raise ConfigParserError(f'Invalid Errbot min version format: {min_version} ({ve})')

        try:
            if max_version:
                max_version = version2tuple(max_version)
        except ValueError as ve:
            raise ConfigParserError(f'Invalid Errbot max version format: {max_version} ({ve})')
        depends_on = config.get('Core', 'DependsOn', fallback=None)
        deps = [name.strip() for name in depends_on.split(',')] if depends_on else []

        return PluginInfo(name, module, doc, core, python_version, min_version, max_version, deps)
Beispiel #4
0
 def _async_vcheck(self):
     current_version_txt = self._get_version()
     self.log.debug("Installed Errbot version is: %s", current_version_txt)
     current_version = version2tuple(current_version_txt)
     if installed_version < current_version:
         self.log.debug(
             'A new version %s has been found, notify the admins!',
             current_version_txt)
         self.warn_admins(
             f'Version {current_version_txt} of Errbot is available. '
             f'http://pypi.python.org/pypi/errbot/{current_version_txt}. '
             f'To disable this check do: {self._bot.prefix}plugin blacklist VersionChecker'
         )
Beispiel #5
0
 def _async_vcheck(self):
     # noinspection PyBroadException
     try:
         current_version_txt = requests.get(HOME, params={'errbot': VERSION, 'python': PY_VERSION}).text.strip()
         self.log.debug("Tested current Errbot version and it is " + current_version_txt)
         current_version = version2tuple(current_version_txt)
         if installed_version < current_version:
             self.log.debug('A new version %s has been found, notify the admins!', current_version)
             self.warn_admins(f'Version {current_version_txt} of Errbot is available. '
                              f'http://pypi.python.org/pypi/errbot/{current_version_txt}. '
                              f'To disable this check do: {self._bot.prefix}plugin blacklist VersionChecker')
     except (HTTPError, URLError):
         self.log.info('Could not establish connection to retrieve latest version.')
Beispiel #6
0
from urllib.error import HTTPError, URLError
import threading
import sys

import requests
from requests.exceptions import ConnectionError

from errbot import BotPlugin
from errbot.utils import version2tuple
from errbot.version import VERSION

HOME = 'https://errbot-1127.appspot.com/'

installed_version = version2tuple(VERSION)

PY_VERSION = '.'.join(str(e) for e in sys.version_info[:3])


class VersionChecker(BotPlugin):

    connected = False
    activated = False

    def activate(self):
        if self.mode not in ('null', 'test', 'Dummy',
                             'text'):  # skip in all test confs.
            self.activated = True
            self.version_check()  # once at startup anyway
            self.start_poller(3600 * 24, self.version_check)  # once every 24H
            super().activate()
        else:
Beispiel #7
0
from urllib.error import HTTPError, URLError
import threading
import sys

import requests

from errbot import BotPlugin
from errbot.utils import version2tuple
from errbot.version import VERSION

HOME = 'http://version.errbot.io/'

installed_version = version2tuple(VERSION)

PY_VERSION = '.'.join(str(e) for e in sys.version_info[:3])


class VersionChecker(BotPlugin):

    connected = False
    activated = False

    def activate(self):
        if self.mode not in ('null', 'test', 'Dummy', 'text'):  # skip in all test confs.
            self.activated = True
            self.version_check()  # once at startup anyway
            self.start_poller(3600 * 24, self.version_check)  # once every 24H
            super().activate()
        else:
            self.log.info('Skip version checking under %s mode.', self.mode)