Skip to content

Commit 4839c8b

Browse files
committed
fix: locked version to v3.x due to dns get_txt bug
1 parent 14f7fcd commit 4839c8b

File tree

3 files changed

+13
-54
lines changed

3 files changed

+13
-54
lines changed

.travis.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
language: python
2-
python: 2.7
2+
python: 3.5
33
before_install:
44
- nvm install v8.12.0
55
install:
6-
- sudo rm -rf /usr/lib/python2.7/dist-packages/ipaddress*
76
- npm install -g yarn
8-
- pip install pyspf==2.0.11
9-
- pip install pydns==2.3.4
10-
- pip install ipaddr
7+
- pip3 install pyspf
118
- yarn
129
script:
1310
npm run test-coverage

README.md

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -22,42 +22,16 @@
2222

2323
## Requirements
2424

25-
1. Ensure that you have a Python version of >=2.6 installed per [pyspf][] requirements:
25+
1. Ensure that you have a Python version of >= 3.5 installed per [pyspf][] requirements (note that Python v3 is required because of a bug with DNS recursive CNAME lookups on v2.7):
2626

2727
```sh
28-
python --version
28+
python3 --version
2929
```
3030

31-
2. Install the package "pyspf" using `pip` globally (**NOTE**: Versions > 2.0.11 currently have a bug that I emailed Scott Kitterman with regards to, specifically an exception is thrown of "Global name strict is not defined" due to a bug in the newer codebase that is not yet patched):
31+
2. Install the packages [pyspf][]:
3232

3333
```sh
34-
pip install pyspf==2.0.11
35-
```
36-
37-
3. Install the DNS package based off your version of Python:
38-
39-
> If you are using Python version >= 3:
40-
41-
```sh
42-
pip install py3dns
43-
```
44-
45-
> Otherwise install the older version (note `2.3.4` is the only version that seems to work OK on Mac):
46-
47-
```sh
48-
pip install pydns==2.3.4
49-
```
50-
51-
4. Lastly if you are using Python version < 3.3 you will need to install "ipaddr" package:
52-
53-
```sh
54-
pip install ipaddr
55-
```
56-
57-
5. If you run `pip list` and it shows `ipaddress` is installed, you will need to manually remove using the following command until this issue [sdgathman/pyspf#7](https://github.com/sdgathman/pyspf/issues/7) is resolved:
58-
59-
```sh
60-
sudo rm -rf /usr/lib/python2.7/dist-packages/ipaddress*
34+
pip3 install pyspf
6135
```
6236

6337

index.js

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,27 @@ const semver = require('semver');
55
const filePath = path.join(__dirname, 'spfcheck2.py');
66

77
// ensure python installed
8-
if (!which('python')) throw new Error(`Python v2.6+ is required`);
8+
if (!which('python3')) throw new Error(`Python v3.5+ is required`);
99

10-
const silent = { silent: true };
10+
const silent = process.env.NODE_ENV !== 'test';
1111

12-
// ensure python v2.6+
13-
let version = exec('python --version', silent);
12+
// ensure python v3.5+
13+
let version = exec('python3 --version', { silent });
1414
version = semver.coerce(
1515
(version.stdout || version.stderr).split(' ')[1].trim()
1616
);
1717

18-
if (!semver.satisfies(version, '>= 2.6'))
18+
if (!semver.satisfies(version, '>= 3.5'))
1919
throw new Error(
20-
`Python v2.6+ is required, you currently have v${version} installed`
20+
`Python v3.5+ is required, you currently have v${version} installed`
2121
);
2222

2323
module.exports = function(ip, address, host) {
2424
return new Promise((resolve, reject) => {
2525
exec(
26-
`python ${filePath} ${ip} ${address} ${host}`,
26+
`python3 ${filePath} ${ip} ${address} ${host}`,
2727
silent,
2828
(code, stdout, stderr) => {
29-
if (typeof stdout === 'string') {
30-
if (stdout.includes('ImportError: No module named spf'))
31-
stderr = 'Please install "pyspf" locally using `pip install pyspf`';
32-
else if (stdout.includes('ipaddr module required'))
33-
stderr =
34-
'Please install "ipaddr" locally using `pip install ipaddr`';
35-
else if (stdout.includes('ImportError: No module named DNS'))
36-
stderr = `Please install "dns" locally using \`pip install ${
37-
semver.satisfies(version, '>= 3') ? 'py3dns' : 'pydns==2.3.4'
38-
}\``;
39-
}
40-
4129
if (code !== 0) return reject(new Error(stderr));
4230
resolve(stdout.trim().split(','));
4331
}

0 commit comments

Comments
 (0)