Skip to content

Commit

Permalink
DEP: Drop Python 3.4 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Wagner committed Dec 9, 2019
1 parent 71dea2f commit 7535eda
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 61 deletions.
7 changes: 3 additions & 4 deletions .travis.yml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ python:
- 3.5 - 3.5
- 3.6 - 3.6
- 3.7 - 3.7
- 3.8
matrix: matrix:
include: include:
- python: 3.4 - python: 3.5
env: mode=debian env: mode=debian
- python: 3.4 - python: 3.8
env: requirements=false
- python: 3.6
env: mode=codestyle env: mode=codestyle
install: install:
- set -e - set -e
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ CHANGELOG


#### Collectors #### Collectors
- `intelmq.bots.collectors.misp.collector`: Deprecate parameter `misp_verify` in favor of generic parameter `http_verify_cert`. - `intelmq.bots.collectors.misp.collector`: Deprecate parameter `misp_verify` in favor of generic parameter `http_verify_cert`.
- `intelmq.bots.collectors.tcp.collector`: Drop compatibility with Python 3.4.


#### Parsers #### Parsers
- `intelmq.bots.parsers.autoshun.parser`: Drop compatibility with Python 3.4.
- `intelmq.bots.parsers.html_table.parser`: Drop compatibility with Python 3.4.


#### Experts #### Experts
- `intelmq.bots.experts.csv_converter`: Added as converter to CSV. - `intelmq.bots.experts.csv_converter`: Added as converter to CSV.
Expand All @@ -45,6 +48,9 @@ CHANGELOG
### Tests ### Tests
- Travis: Use `intelmqsetup` here too. - Travis: Use `intelmqsetup` here too.
- Install required build dependencies for the Debian package build test. - Install required build dependencies for the Debian package build test.
- This version is no longer automatically tested on Python `<` 3.5.
- Also run the tests on Python 3.8.
- Run the debian packaging tests on Python 3.5 and the codestyle test on 3.8.
- Added tests for the new bot `intelmq.bots.outputs.misp.output_feed` (#1473). - Added tests for the new bot `intelmq.bots.outputs.misp.output_feed` (#1473).
- Added tests for the new bot `intelmq.bots.experts.misp.expert` (#1473). - Added tests for the new bot `intelmq.bots.experts.misp.expert` (#1473).


Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ See the changelog for a full list of changes.
---------------------------------- ----------------------------------


### Requirements ### Requirements
- IntelMQ no longer supports Python 3.4, Python `>=` 3.5 is required.


### Tools ### Tools


Expand Down
2 changes: 1 addition & 1 deletion debian/control
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Maintainer: Sebastian Wagner <wagner@cert.at>
Section: python Section: python
Priority: optional Priority: optional
Build-Depends: debhelper (>= 4.1.16), python3-all, python3-setuptools, quilt, dh-python, python-setuptools, dh-systemd, safe-rm, python3-requests, python3-redis, python3-dnspython, python3-psutil, python3-dateutil, python3-termstyle, python3-tz, lsb-release Build-Depends: debhelper (>= 4.1.16), python3-all, python3-setuptools, quilt, dh-python, python-setuptools, dh-systemd, safe-rm, python3-requests, python3-redis, python3-dnspython, python3-psutil, python3-dateutil, python3-termstyle, python3-tz, lsb-release
X-Python3-Version: >= 3.4 X-Python3-Version: >= 3.5
Standards-Version: 3.9.6 Standards-Version: 3.9.6
Homepage: https://github.com/certtools/intelmq/ Homepage: https://github.com/certtools/intelmq/


Expand Down
24 changes: 0 additions & 24 deletions docs/INSTALL.md
Original file line number Original file line Diff line number Diff line change
@@ -1,7 +1,6 @@
**Table of Contents:** **Table of Contents:**
- [Requirements](#requirements) - [Requirements](#requirements)
- [Install Dependencies](#install-dependencies) - [Install Dependencies](#install-dependencies)
- [Debian 8](#debian-8)
- [Ubuntu 16.04 / Ubuntu 18.04 / Debian 9](#ubuntu-1604--ubuntu-1804--debian-9) - [Ubuntu 16.04 / Ubuntu 18.04 / Debian 9](#ubuntu-1604--ubuntu-1804--debian-9)
- [CentOS 7 / RHEL 7](#centos-7--rhel-7) - [CentOS 7 / RHEL 7](#centos-7--rhel-7)
- [openSUSE Leap 15.0 / 15.1](#opensuse-leap-150--151) - [openSUSE Leap 15.0 / 15.1](#opensuse-leap-150--151)
Expand Down Expand Up @@ -34,23 +33,6 @@ Other distributions which are (most probably) supported include RHEL, Fedora and


If you are using native packages, you can simply skip this section as all dependencies are installed automatically. If you are using native packages, you can simply skip this section as all dependencies are installed automatically.


## Debian 8

```bash
apt-get install python3 python3-pip
apt-get install build-essential libffi-dev
apt-get install python3-dev
apt-get install redis-server
```

**Special note for Debian 8**:
if you are using Debian 8, you need to install this package extra: ``apt-get install libgnutls28-dev``.
In addition, Debian 8 has an old version of pip3. Please get a current one via:
```bash
curl "https://bootstrap.pypa.io/get-pip.py" -o "/tmp/get-pip.py"
python3.4 /tmp/get-pip.py
```

## Ubuntu 16.04 / Ubuntu 18.04 / Debian 9 ## Ubuntu 16.04 / Ubuntu 18.04 / Debian 9


```bash ```bash
Expand All @@ -73,12 +55,6 @@ yum install gcc gcc-c++
yum install redis yum install redis
``` ```


Install the last pip version:
```bash
curl "https://bootstrap.pypa.io/get-pip.py" -o "/tmp/get-pip.py"
python3.4 /tmp/get-pip.py
```

## openSUSE 15.0 / 15.1 ## openSUSE 15.0 / 15.1


```bash ```bash
Expand Down
2 changes: 1 addition & 1 deletion intelmq/bots/BOTS
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@
} }
}, },
"TCP": { "TCP": {
"description": "TCP is the bot responsible to receive events on a TCP port (ex: from TCP Output of another IntelMQ instance). Might not be working on Python3.4.6.", "description": "TCP is the bot responsible to receive events on a TCP port (ex: from TCP Output of another IntelMQ instance).",
"module": "intelmq.bots.collectors.tcp.collector", "module": "intelmq.bots.collectors.tcp.collector",
"parameters": { "parameters": {
"ip": "<ip>", "ip": "<ip>",
Expand Down
5 changes: 1 addition & 4 deletions intelmq/bots/collectors/tcp/collector.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -60,10 +60,7 @@ def connect(self):
struct.pack('ii', 1, 0)) # immediately unbind port after closing so that we can restart struct.pack('ii', 1, 0)) # immediately unbind port after closing so that we can restart
self.con.bind(self.address) self.con.bind(self.address)
self.con.settimeout(15) self.con.settimeout(15)
if sys.version_info[1] > 4: # remove when we're having Python 3.5+, let here `self.con.listen()` self.con.listen()
self.con.listen()
else:
self.con.listen(1)
self.logger.info("Connected successfully to %s:%s.", self.address[0], self.address[1]) self.logger.info("Connected successfully to %s:%s.", self.address[0], self.address[1])


def shutdown(self): def shutdown(self):
Expand Down
14 changes: 1 addition & 13 deletions intelmq/bots/parsers/autoshun/parser.py
Original file line number Original file line Diff line number Diff line change
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import html import html
import html.parser import html.parser
import sys


from intelmq.lib import utils from intelmq.lib import utils
from intelmq.lib.bot import ParserBot from intelmq.lib.bot import ParserBot
Expand All @@ -19,14 +18,6 @@
class AutoshunParserBot(ParserBot): class AutoshunParserBot(ParserBot):


def parse(self, report): def parse(self, report):
if sys.version_info[:2] == (3, 4):
# See https://docs.python.org/3/whatsnew/3.4.html#html
# https://docs.python.org/3/whatsnew/3.5.html#changes-in-the-python-api
# raises DeprecationWarning otherwise on 3.4, True by default in 3.5
self.parser = html.parser.HTMLParser(convert_charrefs=True)
else:
self.parser = html.parser.HTMLParser()

raw_report = utils.base64_decode(report.get("raw")) raw_report = utils.base64_decode(report.get("raw"))
splitted = raw_report.split("</tr>") splitted = raw_report.split("</tr>")
self.tempdata = ['</tr>'.join(splitted[:2])] self.tempdata = ['</tr>'.join(splitted[:2])]
Expand All @@ -43,10 +34,7 @@ def parse_line(self, line, report):


ip = info[1].split('</td>')[0].strip() ip = info[1].split('</td>')[0].strip()
last_seen = info[2].split('</td>')[0].strip() + '-05:00' last_seen = info[2].split('</td>')[0].strip() + '-05:00'
if sys.version_info < (3, 4): description = html.parser.HTMLParser().unescape(info[3].split('</td>')[0].strip())
description = self.parser.unescape(info[3].split('</td>')[0].strip())
else:
description = html.unescape(info[3].split('</td>')[0].strip())


for key in ClassificationType.allowed_values: for key in ClassificationType.allowed_values:
if description.lower().find(key.lower()) > -1: if description.lower().find(key.lower()) > -1:
Expand Down
3 changes: 1 addition & 2 deletions intelmq/bots/parsers/html_table/REQUIREMENTS.txt
Original file line number Original file line Diff line number Diff line change
@@ -1,3 +1,2 @@
beautifulsoup4 beautifulsoup4
lxml<4.4.0; python_version < '3.5' lxml
lxml; python_version >= '3.5'
5 changes: 0 additions & 5 deletions intelmq/tests/bots/collectors/tcp/test_collector.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -80,11 +80,6 @@ def _delayed_start(self):
self.run_bot(iterations=len(self.input_message)) self.run_bot(iterations=len(self.input_message))




major, minor, micro, *_ = sys.version_info


@unittest.skipIf((major, minor) == (3, 4) and micro < 8, "Travis CI failed with Python3.4.6. "
"However, the developer managed to successfully test it on 3.4.8.")
class TestTCPCollectorBot(test.BotTestCase, unittest.TestCase): class TestTCPCollectorBot(test.BotTestCase, unittest.TestCase):
""" """
A TestCase for TCPCollectorBot. A TestCase for TCPCollectorBot.
Expand Down
2 changes: 0 additions & 2 deletions intelmq/tests/lib/test_utils.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ def test_stream_logger_given(self):
line_format = [line.format(name) for line in LINES['short']] line_format = [line.format(name) for line in LINES['short']]
self.assertSequenceEqual(line_format, stream_lines) self.assertSequenceEqual(line_format, stream_lines)


@unittest.skipIf(sys.version_info < (3, 5),
"contextlib.redirect_* is not supported in Python 3.4.")
def test_stream_logger(self): def test_stream_logger(self):
stdout = io.StringIO() stdout = io.StringIO()
stderr = io.StringIO() stderr = io.StringIO()
Expand Down
7 changes: 2 additions & 5 deletions setup.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
'pytz>=2012c', 'pytz>=2012c',
'redis>=2.10', 'redis>=2.10',
] ]
if sys.version_info < (3, 5):
REQUIRES.append('typing')



exec(open(os.path.join(os.path.dirname(__file__), exec(open(os.path.join(os.path.dirname(__file__),
'intelmq/version.py')).read()) # defines __version__ 'intelmq/version.py')).read()) # defines __version__
Expand All @@ -36,7 +33,7 @@
version=__version__, version=__version__,
maintainer='Sebastian Wagner', maintainer='Sebastian Wagner',
maintainer_email='wagner@cert.at', maintainer_email='wagner@cert.at',
python_requires='>=3.4', python_requires='>=3.5',
install_requires=REQUIRES, install_requires=REQUIRES,
tests_require=[ tests_require=[
'Cerberus!=1.3', 'Cerberus!=1.3',
Expand Down Expand Up @@ -71,10 +68,10 @@
'Operating System :: POSIX :: Linux', 'Operating System :: POSIX :: Linux',
'Programming Language :: Python', 'Programming Language :: Python',
'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3 :: Only', 'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: Implementation :: CPython', 'Programming Language :: Python :: Implementation :: CPython',
'Topic :: Security', 'Topic :: Security',
Expand Down

0 comments on commit 7535eda

Please sign in to comment.