Python2 removal. #785

Merged
merged 5 commits into from Jun 11, 2016
Jump to file or symbol
Failed to load files and symbols.
+105 −394
Diff settings

Always

Just for now

View
@@ -1,5 +1,5 @@
+__pycache__
.venv
-*.pyc
/.idea
/atlassian-ide-plugin.xml
/.settings
View
@@ -1,7 +1,6 @@
language: python
python:
- - "2.7"
- "3.3"
- "3.4"
- "3.5"
View
@@ -106,8 +106,8 @@ Installation
Prerequisites
~~~~~~~~~~~~~
-Errbot runs under Python 3.3+ and Python 2.7 on Linux, Windows and Mac. For some chatting systems you'll need a key or a login for your bot to access it.
-Note: Python 2 support is going away ! Please check out the change log below for details.
+Errbot runs under Python 3.3+ on Linux, Windows and Mac. For some chatting systems you'll need a key or a login for your bot to access it.
+Note: Python 2 support is still supported in `errbot-4.2.x` but is it going away.
Quickstart
~~~~~~~~~~
@@ -139,8 +139,8 @@ Lets go ahead and create ours. Place the following in a file called
<https://docs.python.org/3/library/configparser.html#supported-ini-file-structure>`_
file structure.
-Lets look at what this does. We see three sections, `[Core]` ,
-`[Python]` and `[Documentation]`. The `[Core]` section is what tells
+Lets look at what this does. We see two sections, `[Core]` ,
+and `[Documentation]`. The `[Core]` section is what tells
Errbot where it can actually find the code for this plugin.
The key `Module` should point to a module that Python can find and
@@ -156,17 +156,6 @@ names can differ, doing so is not recommended.
the same as the class name anyway, this has to do with technical
limitations that we won't go into here.
-While the items from the `[Core]` section tell Errbot where to find the
-code, the `[Python]` section tells Errbot which versions of Python your
-plugin is compatible with. As you are probably aware, Errbot runs on
-both 2.7 and 3.\ *x* versions of Python, but maintaining compatibilty
-to both can take some time and effort however. Effort you might not
-want to put into your own plugins.
-
-The `Version` key allows you to specify which versions of Python your
-plugin works on. Supported values are `2` for Python 2, `3` for
-Python 3 and `2+` for both Python 2 and 3.
-
The `[Documentation]` section will be explained in more detail
further on in this guide, but you should make sure to at least have
the `Description` item here with a short description of your plugin.
@@ -1,35 +1,6 @@
Plugin compatibility settings
=============================
-
-Python compatibility
---------------------
-
-Your plugin might not be compatible with Python 2 or Python 3.
-In order to prevent users to install them under an incompatible environment,
-you can add a **Python** section to your plug file:
-
-.. code-block:: ini
-
- [Core]
- Name = MyPlugin
- Module = myplugin
-
- [Documentation]
- Description = my plugin
-
- [Python]
- Version=2+
-
-The possible choices for **Version** are:
-
-- 2 : only compatible with Python 2
-- 3 : only compatible with Python 3
-- 2+: compatible with both
-
-Of there is no Python section, your plugin will be restricted to Python 2 for backward compatibility.
-
-
Errbot compatibility
--------------------
@@ -4,8 +4,7 @@ Setup
Prerequisites
-------------
-Errbot runs under Python 3.2+ on Linux, Windows and Mac. You can still use it under Python 2.7 if you really
-must but it is not recommended and the support for Python 2 will be removed soon.
+Errbot runs under Python 3.3+ on Linux, Windows and Mac.
Installation
------------
@@ -53,7 +52,6 @@ Errbot may be installed directly from PyPi using `pip`_ by issuing::
which means you need to have development headers for some libraries installed.
On Debian/Ubuntu these may be installed with
`apt-get install python3-dev libssl-dev libffi-dev`
- (use `python-dev` instead of `python3-dev` if you're still stuck on Python 2).
Package names may differ on other OS's.
.. _configuration:
View
@@ -11,8 +11,6 @@
from .core_plugins.wsview import bottle_app, WebView
from .backends.base import Message, ONLINE, OFFLINE, AWAY, DND # noqa
-from .utils import compat_str
-from .utils import PY2, PY3 # noqa gbin: this is now used by plugins
from .botplugin import BotPlugin, SeparatorArgParser, ShlexArgParser, CommandError, Command # noqa
from .flow import FlowRoot, BotFlow, Flow, FLOW_END
from .core_plugins.wsview import route, view # noqa
@@ -436,9 +434,9 @@ def a_webhook(self, payload):
pass
"""
- if isinstance(args[0], (str, bytes)): # first param is uri_rule.
+ if isinstance(args[0], str): # first param is uri_rule.
return lambda func: _tag_webhook(func,
- compat_str(args[0]).rstrip('/'), # trailing / is also be stripped on incoming.
+ args[0].rstrip('/'), # trailing / is also be stripped on incoming.
methods=methods,
form_param=form_param,
raw=raw)
View
@@ -2,7 +2,7 @@
import logging
import random
import time
-from typing import Any, Mapping, BinaryIO, List, Union, Sequence, Tuple
+from typing import Any, Mapping, BinaryIO, List, Sequence, Tuple
from abc import abstractproperty, abstractmethod
from collections import deque, defaultdict
@@ -11,18 +11,13 @@
try:
from abc import ABC
except ImportError:
- # 3.3 compatibility
+ # 3.3 backward compatibility
from abc import ABCMeta
class ABC(metaclass=ABCMeta):
- """Helper class that provides a standard way to create an ABC using
- inheritance.
- """
pass
-from errbot.utils import compat_str, deprecated
-
# Can't use __name__ because of Yapsy
log = logging.getLogger('errbot.backends.base')
@@ -247,7 +242,7 @@ def __init__(self,
:param flow:
The flow in which this message has been triggered.
"""
- self._body = compat_str(body)
+ self._body = body
self._from = frm
self._to = to
self._delayed = delayed
@@ -20,8 +20,8 @@
from PySide.QtCore import Qt
except ImportError:
log.exception("Could not start the graphical backend")
- log.fatal(""" To install PySide use:
- pip install PySide
+ log.fatal(""" To install graphic support use:
+ pip install errbot[graphic]
""")
sys.exit(-1)
View
@@ -3,23 +3,16 @@
import logging
import re
import sys
-try:
- from functools import lru_cache
-except ImportError:
- from backports.functools_lru_cache import lru_cache
+from functools import lru_cache
+
+from errbot.backends.base import Room, RoomDoesNotExistError, RoomOccupant
+from errbot.backends.xmpp import XMPPRoomOccupant, XMPPBackend, XMPPConnection
from markdown import Markdown
from markdown.extensions.extra import ExtraExtension
from markdown.extensions import Extension
from markdown.treeprocessors import Treeprocessor
-from errbot.backends.base import Room, RoomDoesNotExistError, Message, RoomOccupant
-from errbot.backends.xmpp import (
- XMPPPerson, XMPPRoomOccupant,
- XMPPBackend, XMPPConnection,
- split_identifier
-)
-
# Can't use __name__ because of Yapsy
log = logging.getLogger('errbot.backends.hipchat')
@@ -29,9 +22,9 @@
except ImportError:
log.exception("Could not start the HipChat backend")
log.fatal(
- "You need to install the hypchat package in order to use the HipChat "
- "back-end. You should be able to install this package using: "
- "pip install hypchat"
+ "You need to install the hipchat support in order to use the HipChat.\n "
+ "You should be able to install this package using:\n"
+ "pip install errbot[hipchat]"
)
sys.exit(1)
View
@@ -57,18 +57,9 @@
import irc.connection
from irc.client import ServerNotConnectedError, NickMask
from irc.bot import SingleServerIRCBot
-except ImportError as _:
- log.exception("Could not start the IRC backend")
- log.fatal("""
- If you intend to use the IRC backend please install the python irc package:
- -> On debian-like systems
- sudo apt-get install python-software-properties
- sudo apt-get update
- sudo apt-get install python-irc
- -> On Gentoo
- sudo emerge -av dev-python/irc
- -> Generic
- pip install irc
+except ImportError:
+ log.fatal("""You need the IRC support to use IRC, you can install it with:
+ pip install errbot[IRC]
""")
sys.exit(-1)
View
@@ -6,46 +6,29 @@
import time
import sys
import pprint
+from functools import lru_cache
from errbot.backends.base import Message, Presence, ONLINE, AWAY, Room, RoomError, RoomDoesNotExistError, \
UserDoesNotExistError, RoomOccupant, Person, Card
from errbot.core import ErrBot
-from errbot.utils import PY3, split_string_after
+from errbot.utils import split_string_after
from errbot.rendering.slack import slack_markdown_converter
# Can't use __name__ because of Yapsy
log = logging.getLogger('errbot.backends.slack')
-try:
- from functools import lru_cache
-except ImportError:
- from backports.functools_lru_cache import lru_cache
+
try:
from slackclient import SlackClient
except ImportError:
log.exception("Could not start the Slack back-end")
log.fatal(
- "You need to install the slackclient package in order to use the Slack "
- "back-end. You should be able to install this package using: "
- "pip install slackclient"
- )
- sys.exit(1)
-except SyntaxError:
- if not PY3:
- raise
- log.exception("Could not start the Slack back-end")
- log.fatal(
- "I cannot start the Slack back-end because I cannot import the SlackClient. "
- "Python 3 compatibility on SlackClient is still quite young, you may be "
- "running an old version or perhaps they released a version with a Python "
- "3 regression. As a last resort to fix this, you could try installing the "
- "latest master version from them using: "
- "pip install --upgrade https://github.com/slackhq/python-slackclient/archive/master.zip"
+ "You need to install the slackclient support in order to use the Slack.\n"
+ "You can do `pip install errbot[slack]` to install it"
)
sys.exit(1)
-
# The Slack client automatically turns a channel name into a clickable
# link if you prefix it with a #. Other clients receive this link as a
# token matching this regex.
@@ -1,7 +1,6 @@
import logging
import sys
-from errbot import PY2
from errbot.backends.base import RoomError, Identifier, Person, RoomOccupant, ONLINE, Room
from errbot.core import ErrBot
from errbot.rendering import text
@@ -12,17 +11,17 @@
log = logging.getLogger('errbot.backends.telegram')
TELEGRAM_MESSAGE_SIZE_LIMIT = 1024
-UPDATES_OFFSET_KEY = b'_telegram_updates_offset' if PY2 else '_telegram_updates_offset'
+UPDATES_OFFSET_KEY = '_telegram_updates_offset'
try:
import telegram
except ImportError:
log.exception("Could not start the Telegram back-end")
log.fatal(
- "You need to install the python-telegram-bot package in order "
- "to use the Telegram back-end. "
- "You should be able to install this package using: "
- "pip install python-telegram-bot"
+ "You need to install the telegram support in order "
+ "to use the Telegram backend.\n"
+ "You should be able to install this package using:\n"
+ "pip install errbot[telegram]"
)
sys.exit(1)
View
@@ -1,13 +1,8 @@
import logging
import sys
+from functools import lru_cache
from sleekxmpp.exceptions import IqError
-
-try:
- from functools import lru_cache
-except ImportError:
- from backports.functools_lru_cache import lru_cache
-
from threading import Thread
from time import sleep
@@ -23,19 +18,11 @@
try:
from sleekxmpp import ClientXMPP
from sleekxmpp.xmlstream import resolver, cert
-except ImportError as _:
+except ImportError:
log.exception("Could not start the XMPP backend")
log.fatal("""
- If you intend to use the XMPP backend please install the python sleekxmpp package:
- -> On debian-like systems
- sudo apt-get install python-software-properties
- sudo apt-get update
- sudo apt-get install python-sleekxmpp
- -> On Gentoo
- sudo layman -a laurentb
- sudo emerge -av dev-python/sleekxmpp
- -> Generic
- pip install sleekxmpp
+ If you intend to use the XMPP backend pleas install the support for XMPP with:
+ pip install errbot[XMPP]
""")
sys.exit(-1)
View
@@ -1,14 +1,13 @@
from os import path, makedirs
import logging
+import sys
from errbot.core import ErrBot
from errbot.plugin_manager import BotPluginManager
from errbot.repo_manager import BotRepoManager
from errbot.specific_plugin_manager import SpecificPluginManager
-import sys
-
from errbot.storage.base import StoragePluginBase
-from errbot.utils import PLUGINS_SUBDIR, is_str
+from errbot.utils import PLUGINS_SUBDIR
log = logging.getLogger(__name__)
@@ -100,7 +99,7 @@ def setup_bot(backend_name, logger, config, restore=None):
makedirs(botplugins_dir, mode=0o755)
plugin_indexes = getattr(config, 'BOT_PLUGIN_INDEXES', (PLUGIN_DEFAULT_INDEX,))
- if is_str(plugin_indexes):
+ if isinstance(plugin_indexes, str):
plugin_indexes = (plugin_indexes, )
repo_manager = BotRepoManager(storage_plugin,
Oops, something went wrong.