Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switched from check_output to Popen #57

Merged
merged 4 commits into from
Oct 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ pypy*
.eggs
*.egg-info
dist

build
.DS_Store
.vscode
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ before_install:

install:
- "pip install .[tests]"
script: flake8 && nosetests -vv
script:
- flake8
- nosetests -vv
28 changes: 15 additions & 13 deletions html5validator/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,31 +125,33 @@ def validate(self, files):
['-jar', self.vnu_jar_location] + self._vnu_options() +
files)
LOGGER.debug(cmd)
o = subprocess.check_output(
p = subprocess.Popen(
cmd,
stderr=subprocess.STDOUT,
).decode('utf-8')
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)
stdout, stderr = p.communicate()
except OSError as e:
if e.errno == os.errno.ENOENT:
raise JavaNotFoundException()
else:
raise
except subprocess.CalledProcessError as e:
o = e.output.decode('utf-8')
except subprocess.CalledProcessError as error:
raise (error.output.decode('utf-8'))

# process fancy quotes into standard quotes
o = self._normalize_string(o)
stderr = self._normalize_string(stderr.decode('utf-8'))

e = stderr.splitlines()

o = o.splitlines()
for i in self.ignore:
o = [l for l in o if i not in l]
e = [l for l in e if i not in l]
for i in self.ignore_re:
regex = re.compile(i)
o = [l for l in o if not regex.search(l)]
e = [l for l in e if not regex.search(l)]

if o:
LOGGER.error('\n'.join(o))
if stderr:
LOGGER.error(stderr)
else:
LOGGER.info('All good.')

return len(o)
return len(e)
Binary file modified vnujar/vnu.jar
Binary file not shown.