Skip to content

Commit 417887a

Browse files
authored
Merge pull request ojarva#75 from ojarva/ojarva-fix-ci
Migrate from travis to more reliable github actions
2 parents 04a60d5 + a4c5f34 commit 417887a

4 files changed

Lines changed: 46 additions & 25 deletions

File tree

.github/workflows/python-tests.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Run python tests
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
8+
runs-on: ubuntu-latest
9+
strategy:
10+
matrix:
11+
python-version: [3.6, 3.7, 3.8]
12+
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Set up Python ${{ matrix.python-version }}
16+
uses: actions/setup-python@v2
17+
with:
18+
python-version: ${{ matrix.python-version }}
19+
- name: Install dependencies
20+
run: |
21+
python -m pip install --upgrade pip
22+
pip install pycodestyle isort pylint yapf
23+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
24+
- name: Check import sorting
25+
run: |
26+
isort --diff --check --recursive sshpubkeys tests
27+
- name: Check pycodestyle
28+
run: |
29+
pycodestyle --ignore E501,E402 --exclude=.git,dev3 sshpubkeys tests
30+
- name: Run pylint
31+
run: |
32+
pylint sshpubkeys tests
33+
- name: Run tests
34+
run: |
35+
python3 setup.py test
36+
- name: Check formatting
37+
run: |
38+
isort --recursive sshpubkeys tests; yapf --recursive .
39+
git diff --exit-code # This fails if isort&yapf combo made any changes

.travis.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@
2323
'Topic :: Security',
2424
'License :: OSI Approved :: BSD License',
2525
'Programming Language :: Python :: 3',
26-
'Programming Language :: Python :: 3.4',
27-
'Programming Language :: Python :: 3.5',
2826
'Programming Language :: Python :: 3.6',
2927
'Programming Language :: Python :: 3.7',
28+
'Programming Language :: Python :: 3.8',
3029
'Programming Language :: Python :: Implementation :: PyPy',
3130
],
3231
keywords='ssh pubkey public key openssh ssh-rsa ssh-dss ssh-ed25519',

sshpubkeys/keys.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ def _unpack_by_int(self, data, current_position):
170170
# Unpack length of data field
171171
try:
172172
requested_data_length = struct.unpack('>I', data[current_position:current_position + self.INT_LEN])[0]
173-
except struct.error:
174-
raise MalformedDataError("Unable to unpack %s bytes from the data" % self.INT_LEN)
173+
except struct.error as ex:
174+
raise MalformedDataError("Unable to unpack %s bytes from the data" % self.INT_LEN) from ex
175175

176176
# Move pointer to the beginning of the data field
177177
current_position += self.INT_LEN
@@ -240,8 +240,8 @@ def decode_key(cls, pubkey_content):
240240
"""Decode base64 coded part of the key."""
241241
try:
242242
decoded_key = base64.b64decode(pubkey_content.encode("ascii"))
243-
except (TypeError, binascii.Error):
244-
raise MalformedDataError("Unable to decode the key")
243+
except (TypeError, binascii.Error) as ex:
244+
raise MalformedDataError("Unable to decode the key") from ex
245245
return decoded_key
246246

247247
@classmethod
@@ -363,8 +363,8 @@ def _process_ecdsa_sha(self, data):
363363
try:
364364
# data starts with \x04, which should be discarded.
365365
ecdsa_key = ecdsa.VerifyingKey.from_string(key_data[1:], curve, hash_algorithm)
366-
except AssertionError:
367-
raise InvalidKeyError("Invalid ecdsa key")
366+
except AssertionError as ex:
367+
raise InvalidKeyError("Invalid ecdsa key") from ex
368368
self.bits = int(curve_information.replace(b"nistp", b""))
369369
self.ecdsa = ecdsa_key
370370
return current_position

0 commit comments

Comments
 (0)