Skip to content

Commit

Permalink
Update waitress to 2.0 and add log-level option
Browse files Browse the repository at this point in the history
Also update some more packages used for docs and testing.
  • Loading branch information
Cito committed Apr 30, 2021
1 parent 9ee6ea4 commit df2fc74
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@

requireDev = [
'Pygments>=2.7,<3', 'WebTest>=2.0,<3',
'waitress>=1.4.4,<2', 'hupper>=1.10,<2',
'waitress>=2,<3', 'hupper>=1.10,<2',
]
requireDocs = [
'Sphinx>=3,<4', 'sphinx_rtd_theme>=0.5'
'Sphinx>=3.5,<4', 'sphinx_rtd_theme>=0.5'
]
requireExamples = [
'DBUtils>=2,<4', 'dominate>=2.6,<3', 'yattag>=1.14,<2',
'Pygments>=2.7,<3', 'Pillow>=8,<9'
]
requireTests = [
'psutil>=5.8,<6', 'flake8>=3.8,<4', 'pylint>=2.6,<3', 'tox>=3.21,<4',
'psutil>=5.8,<6', 'flake8>=3.9,<4', 'pylint>=2.8,<3', 'tox>=3.23,<4',
'pywin32>=300,<400;'
'sys_platform=="win32" and implementation_name=="cpython"'
] + requireDev + requireDocs + requireExamples
Expand Down
6 changes: 3 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ envlist = py{36,37,38,39}, pypy3, flake8, pylint, docs, manifest

[testenv:flake8]
basepython = python3.8
deps = flake8>=3.8,<4
deps = flake8>=3.9,<4
commands =
flake8 webware setup.py

[testenv:pylint]
basepython = python3.8
deps = pylint>=2.6,<3
deps = pylint>=2.8,<3
commands =
pylint webware

Expand All @@ -22,7 +22,7 @@ commands =

[testenv:manifest]
basepython = python3.8
deps = check-manifest>=0.43
deps = check-manifest>=0.46
commands =
check-manifest -v

Expand Down
17 changes: 16 additions & 1 deletion webware/Scripts/WaitressServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""Serve Webware for Python Application using the waitress WSGI server."""

import argparse
import logging


def serve(args):
Expand Down Expand Up @@ -68,7 +69,6 @@ def openBrowser():
'Cannot find Webware application.\nIs the current directory'
' the application working directory?') from e

print("Waitress serving Webware application...")
args = vars(args)
for arg in 'browser reload reload_interval prod wsgi_script'.split():
del args[arg]
Expand All @@ -80,6 +80,14 @@ def openBrowser():
del args['trusted_proxy_count']
if not args['trusted_proxy_headers']:
del args['trusted_proxy_headers']
logLevel = args.pop('log_level')
if logLevel:
logLevel = logging.getLevelName(logLevel)
if isinstance(logLevel, int):
logger = logging.getLogger('waitress')
logger.setLevel(logLevel)

print("Waitress serving Webware application...")
serve(application, **args)


Expand Down Expand Up @@ -155,6 +163,13 @@ def addArguments(parser):
help='The file path of the WSGI script',
default='Scripts/WSGIScript.py',
)
parser.add_argument(
'--log-level',
help='Logs output on the given level',
default=None,
choices=('DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'),
type=str.upper
)


def main(args=None):
Expand Down
3 changes: 1 addition & 2 deletions webware/Tests/TestEndToEnd/TestServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
Loading context: PSP/Examples at .+Examples
Waitress serving Webware application...
Serving on http://.+:8080
'''

expectedStartPage = r'''
Expand Down Expand Up @@ -74,7 +73,7 @@
class RunServer(Process):
"""Run a given command until a given line is found in the output."""

def __init__(self, cmd=None, waitForLine='Serving on '):
def __init__(self, cmd=None, waitForLine='Waitress serving Webware'):
super().__init__()
self.cmd = cmd or ['webware', 'serve']
self.waitForLine = waitForLine
Expand Down

0 comments on commit df2fc74

Please sign in to comment.