Skip to content

Commit

Permalink
Add travis job
Browse files Browse the repository at this point in the history
Launch pylint with pylint-django plugins
At this time, only report Warnings and Errors

Remove mysql dependencies because default configuration
use sqlite, we should add dedicated howto to enable it.

Fix error in exportbooks command.
Disable pylint for no-member for save method for FileField
(check pylint-dev/pylint-django#60)
  • Loading branch information
murlock committed Jun 4, 2017
1 parent 8051fdc commit 5f2edd7
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 3 deletions.
15 changes: 15 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
langague: python
distr: trusty
sudo: required
python:
- 2.7

before_install:
- sudo apt-get install -y python-virtualenv
- virtualenv /tmp/venv
- source /tmp/venv/bin/activate
- pip install -r requirements.pip
- pip install -r test-requirements.pip

script:
- scripts/run-pylint.sh
2 changes: 1 addition & 1 deletion books/management/commands/exportbooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def _handle_csv(self, csvpath):
'a_author': book.a_author.a_author.encode('utf-8'),
'a_summary': book.a_summary.encode('utf-8')}
writer.writerow(entry)
writer.close()
csvfile.close()


def handle(self, filepath='', *args, **options):
Expand Down
2 changes: 1 addition & 1 deletion books/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def save(self, *args, **kwargs):
cover_path = epub_file.get_cover_image_path()
if cover_path is not None and os.path.exists(cover_path):
cover_file = File(open(cover_path))
self.cover_img.save(os.path.basename(cover_path),
self.cover_img.save(os.path.basename(cover_path), # pylint: disable=no-member
cover_file)
epub_file.close()

Expand Down
1 change: 0 additions & 1 deletion requirements.pip
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
Django==1.4.5
django-tagging==0.3.1
django-sendfile==0.3.6
MySQL-python>=1.2.3
lxml==3.4.4
django-taggit==0.14.0
14 changes: 14 additions & 0 deletions scripts/run-pylint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

for file in $(git ls-files -- '*.py' | grep -vE 'deploy|fabfile'); do
echo "==== $file"
pylint --rcfile=pylintrc --load-plugins pylint_django --score=no --reports=no --disable=R,C $file
RET=$? # pylint returns bitfield of found issues
ERR=$(($RET&3)) # Fatal is 1 and Error is 2
if [[ $ERR -ne 0 ]]; then
echo "Aborting"
exit 1
fi
done

exit 0
2 changes: 2 additions & 0 deletions test-requirements.pip
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pylint==1.7.1
pylint-django==0.7.2

0 comments on commit 5f2edd7

Please sign in to comment.