Skip to content

Commit 1fadf6e

Browse files
John MorrisJohn Morris
authored andcommitted
initial commit: fix java version parsing and multi-server behavior
1 parent 58e4198 commit 1fadf6e

4 files changed

Lines changed: 16 additions & 6 deletions

File tree

‎README.rst‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ Python wrapper for LanguageTool.
77
:target: https://travis-ci.org/myint/language-check
88
:alt: Build status
99

10-
This is a fork of
11-
https://bitbucket.org/spirit/language_tool that produces more easily parsable
10+
This is a fork of https://github.com/myint/language-check/ (which is a fork of
11+
https://bitbucket.org/spirit/language_tool) that produces more easily parsable
1212
results from the command-line.
1313

1414
Example usage

‎download_lt.py‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,16 @@
3232
JAVA_6_COMPATIBLE_VERSION = '2.2'
3333
JAVA_7_COMPATIBLE_VERSION = '3.1'
3434
LATEST_VERSION = '3.2'
35+
3536
JAVA_VERSION_REGEX = re.compile(
3637
r'^(?:java|openjdk) version "(?P<major1>\d+)\.(?P<major2>\d+)\.[^"]+"',
3738
re.MULTILINE)
3839

40+
# Updated for later versions of java
41+
JAVA_VERSION_REGEX_UPDATED = re.compile(
42+
r'^(?:java|openjdk) [version ]?(?P<major1>\d+)\.(?P<major2>\d+)',
43+
re.MULTILINE)
44+
3945

4046
def parse_java_version(version_text):
4147
"""Return Java version (major1, major2).
@@ -54,7 +60,7 @@ def parse_java_version(version_text):
5460
(1, 8)
5561
5662
"""
57-
match = re.search(JAVA_VERSION_REGEX, version_text)
63+
match = re.search(JAVA_VERSION_REGEX, version_text) or re.search(JAVA_VERSION_REGEX_UPDATED, version_text)
5864
if not match:
5965
raise SystemExit(
6066
'Could not parse Java version from """{}""".'.format(version_text))

‎language_check/__init__.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ class LanguageTool:
175175
"""Main class used for checking text against different rules."""
176176
_HOST = socket.gethostbyname('localhost')
177177
_MIN_PORT = 8081
178-
_MAX_PORT = 8083
178+
_MAX_PORT = 8999
179179
_TIMEOUT = 5 * 60
180180

181181
_remote = False
@@ -401,6 +401,7 @@ def _start_local_server(cls):
401401
if root.get('software') != 'LanguageTool':
402402
raise ServerError('unexpected software from {}: {!r}'
403403
.format(cls._url, root.get('software')))
404+
raise ServerError('Server running; don\'t start a server here.')
404405

405406
@classmethod
406407
def _server_is_alive(cls):

‎setup.cfg‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@
22
name=language-check
33
summary=Checks grammar using LanguageTool.
44
description-file=README.rst
5-
home-page=https://github.com/myint/language-check
6-
author=Steven Myint
5+
home-page=https://github.com/jxmorris12/language-tool-python
6+
author=Jack Morris
77
classifier=
88
License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)
99
Programming Language :: Python :: 2.7
1010
Programming Language :: Python :: 3
1111
Programming Language :: Python :: 3.3
1212
Programming Language :: Python :: 3.4
1313
Programming Language :: Python :: 3.5
14+
Programming Language :: Python :: 3.6
15+
Programming Language :: Python :: 3.7
16+
Programming Language :: Python :: 3.8
1417

1518
[files]
1619
packages=

0 commit comments

Comments
 (0)