Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix reports under python 3.3

  • Loading branch information...
commit d90cc371d8fbfd3cc42ac808b36eec0ba0a43c81 1 parent 401fdc5
@kmmbvnr authored
View
39 django_jenkins/tasks/run_csslint.py
@@ -6,30 +6,29 @@
import codecs
from optparse import make_option
from django.conf import settings
-from django_jenkins.functions import (CalledProcessError,
- find_first_existing_executable)
+from django_jenkins.functions import CalledProcessError
from django_jenkins.tasks import BaseTask, get_apps_locations
class Task(BaseTask):
option_list = [
- make_option("--csslint-with-staticdirs",
- dest="csslint_with-staticdirs",
- default=False, action="store_true",
- help="Check css files located in STATIC_DIRS settings"),
- make_option("--csslint-with-mincss",
- dest="csslint_with_mincss",
- default=False, action="store_true",
- help="Do not ignore .min.css files"),
- make_option("--csslint-exclude",
- dest="csslint_exclude", default="",
- help="Exclude patterns"),
- make_option("--csslint-static-dirname",
- dest="csslint_static-dirname", default="static",
- help="Name of dir with css static files"),
- make_option("--csslint-ignore",
- dest="csslint_ignore", default="",
- help="Ignore rules")]
+ make_option("--csslint-with-staticdirs",
+ dest="csslint_with-staticdirs",
+ default=False, action="store_true",
+ help="Check css files located in STATIC_DIRS settings"),
+ make_option("--csslint-with-mincss",
+ dest="csslint_with_mincss",
+ default=False, action="store_true",
+ help="Do not ignore .min.css files"),
+ make_option("--csslint-exclude",
+ dest="csslint_exclude", default="",
+ help="Exclude patterns"),
+ make_option("--csslint-static-dirname",
+ dest="csslint_static-dirname", default="static",
+ help="Name of dir with css static files"),
+ make_option("--csslint-ignore",
+ dest="csslint_ignore", default="",
+ help="Ignore rules")]
def __init__(self, test_labels, options):
super(Task, self).__init__(test_labels, options)
@@ -75,6 +74,8 @@ def teardown_test_environment(self, **kwargs):
self.output.write('<?xml version="1.0" encoding='
'"utf-8"?><lint></lint>')
+ self.output.close()
+
def static_files_iterator(self):
locations = get_apps_locations(self.test_labels, self.test_all)
View
7 django_jenkins/tasks/run_flake8.py
@@ -55,14 +55,12 @@ def teardown_test_environment(self, **kwargs):
class JenkinsReport(pep8.BaseReport):
def error(instance, line_number, offset, text, check):
- code = super(JenkinsReport, instance).error(
- line_number, offset, text, check)
+ code = super(JenkinsReport, instance).error(line_number, offset, text, check)
if not code:
return
sourceline = instance.line_offset + line_number
- self.output.write('%s:%s:%s: %s\n' %
- (instance.filename, sourceline, offset + 1, text))
+ self.output.write('%s:%s:%s: %s\n' % (instance.filename, sourceline, offset + 1, text))
pep8style = get_style_guide(parse_argv=False, config_file=self.pep8_rcfile,
reporter=JenkinsReport, max_complexity=self.max_complexity,
@@ -72,4 +70,3 @@ def error(instance, line_number, offset, text, check):
pep8style.input_dir(relpath(location))
self.output.close()
-
View
39 django_jenkins/tasks/run_jshint.py
@@ -12,20 +12,20 @@
class Task(BaseTask):
option_list = [
- make_option("--jshint-with-staticdirs",
- dest="jshint-with-staticdirs",
- default=False, action="store_true",
- help="Check js files located in STATIC_DIRS settings"),
- make_option("--jshint-with-minjs",
- dest="jshint_with-minjs",
- default=False, action="store_true",
- help="Do not ignore .min.js files"),
- make_option("--jshint-exclude",
- dest="jshint_exclude", default="",
- help="Exclude patterns"),
- make_option("--jshint-static-dirname",
- dest="jshint_static-dirname", default="static",
- help="Name of dir with js static files")]
+ make_option("--jshint-with-staticdirs",
+ dest="jshint-with-staticdirs",
+ default=False, action="store_true",
+ help="Check js files located in STATIC_DIRS settings"),
+ make_option("--jshint-with-minjs",
+ dest="jshint_with-minjs",
+ default=False, action="store_true",
+ help="Do not ignore .min.js files"),
+ make_option("--jshint-exclude",
+ dest="jshint_exclude", default="",
+ help="Exclude patterns"),
+ make_option("--jshint-static-dirname",
+ dest="jshint_static-dirname", default="static",
+ help="Name of dir with js static files")]
def __init__(self, test_labels, options):
super(Task, self).__init__(test_labels, options)
@@ -38,8 +38,7 @@ def __init__(self, test_labels, options):
output_dir = options['output_dir']
if not os.path.exists(output_dir):
os.makedirs(output_dir)
- self.output = codecs.open(os.path.join(output_dir,
- 'jshint.xml'), 'w', 'utf-8')
+ self.output = codecs.open(os.path.join(output_dir, 'jshint.xml'), 'w', 'utf-8')
else:
self.output = sys.stdout
@@ -61,6 +60,7 @@ def teardown_test_environment(self, **kwargs):
raise CalledProcessError(retcode, cmd, output='%s\n%s' % (output, err))
self.output.write(output.decode('utf-8'))
+ self.output.close()
def static_files_iterator(self):
locations = get_apps_locations(self.test_labels, self.test_all)
@@ -100,11 +100,8 @@ def is_excluded(path):
else:
# scan apps directories for static folders
for location in locations:
- for dirpath, dirnames, filenames in \
- os.walk(os.path.join(location, self.static_dirname)):
+ for dirpath, dirnames, filenames in os.walk(os.path.join(location, self.static_dirname)):
for filename in filenames:
path = os.path.join(dirpath, filename)
- if filename.endswith('.js') and \
- in_tested_locations(path) and not \
- is_excluded(path):
+ if filename.endswith('.js') and in_tested_locations(path) and not is_excluded(path):
yield path
View
1  django_jenkins/tasks/run_sloccount.py
@@ -42,3 +42,4 @@ def teardown_test_environment(self, **kwargs):
continue
self.output.write(line)
self.output.write('\n')
+ self.output.close()
View
6 tests/settings.py
@@ -34,6 +34,7 @@
JENKINS_TASKS = (
'django_jenkins.tasks.with_coverage',
+ 'django_jenkins.tasks.run_pylint',
'django_jenkins.tasks.run_pep8',
'django_jenkins.tasks.run_pyflakes',
'django_jenkins.tasks.run_flake8',
@@ -44,11 +45,6 @@
)
-# bug in python3 version
-if sys.version_info[0] < 3:
- JENKINS_TASKS += ('django_jenkins.tasks.run_pylint',)
-
-
JSHINT_CHECKED_FILES = [os.path.join(PROJECT_ROOT, 'static/js/test.js')]
CSSLINT_CHECKED_FILES = [os.path.join(PROJECT_ROOT, 'static/css/test.css')]
Please sign in to comment.
Something went wrong with that request. Please try again.