diff --git a/py4web/__init__.py b/py4web/__init__.py index 365ee8c58..29e9ed72a 100644 --- a/py4web/__init__.py +++ b/py4web/__init__.py @@ -23,16 +23,5 @@ def _maybe_gevent(): from .core import Translator # from pluralize from .core import action # main py4web decorator from .core import render # yatl -from .core import ( - DAL, - Cache, - Condition, - Flash, - Session, - abort, - check_compatible, - redirect, - request, - response, - safely, -) +from .core import (DAL, Cache, Condition, Flash, Session, abort, + check_compatible, redirect, request, response, safely) diff --git a/py4web/core.py b/py4web/core.py index 0da715f56..36c704300 100644 --- a/py4web/core.py +++ b/py4web/core.py @@ -10,6 +10,7 @@ import datetime import enum import functools +import html as sanitize_html import http.client import http.cookies import importlib.machinery @@ -34,7 +35,6 @@ import zipfile from collections import OrderedDict from contextlib import redirect_stderr, redirect_stdout -import html as sanitize_html import portalocker from watchgod import awatch @@ -48,7 +48,6 @@ gunicorn = None import click - # Third party modules import ombott as bottle import pluralize diff --git a/py4web/server_adapters.py b/py4web/server_adapters.py index 012d6caf1..9139c4391 100644 --- a/py4web/server_adapters.py +++ b/py4web/server_adapters.py @@ -128,8 +128,8 @@ def get_workers(opts, default=10): def check_port(host="127.0.0.1", port=8000): - import socket import errno + import socket import subprocess def os_cmd(run_cmd): @@ -177,9 +177,10 @@ def os_cmd(run_cmd): def gunicorn(): - from gevent import local # pip install gevent gunicorn setproctitle import threading + from gevent import local # pip install gevent gunicorn setproctitle + if isinstance(threading.local(), local.local): print("gunicorn: monkey.patch_all() applied") @@ -386,7 +387,6 @@ def run(self, app_handler): def geventWebSocketServer(): from gevent import pywsgi - # from geventwebsocket.handler import WebSocketHandler # pip install gevent-websocket from gevent_ws import WebSocketHandler # pip install gevent gevent-ws @@ -445,7 +445,8 @@ def wsgirefThreadingServer(): import socket from concurrent.futures import ThreadPoolExecutor # pip install futures from socketserver import ThreadingMixIn - from wsgiref.simple_server import WSGIRequestHandler, WSGIServer, make_server + from wsgiref.simple_server import (WSGIRequestHandler, WSGIServer, + make_server) class WSGIRefThreadingServer(ServerAdapter): def run(self, app_handler): diff --git a/py4web/utils/auth.py b/py4web/utils/auth.py index a637d6ad6..64e7ad0cd 100644 --- a/py4web/utils/auth.py +++ b/py4web/utils/auth.py @@ -8,15 +8,8 @@ import time import uuid -from pydal.validators import ( - CRYPT, - IS_EMAIL, - IS_EQUAL_TO, - IS_MATCH, - IS_NOT_EMPTY, - IS_NOT_IN_DB, - IS_STRONG, -) +from pydal.validators import (CRYPT, IS_EMAIL, IS_EQUAL_TO, IS_MATCH, + IS_NOT_EMPTY, IS_NOT_IN_DB, IS_STRONG) from yatl.helpers import DIV, A from py4web import HTTP, URL, Field, action, redirect, request, response diff --git a/py4web/utils/auth_plugins/oauth2facebook.py b/py4web/utils/auth_plugins/oauth2facebook.py index 934386e3a..a3f3c6e46 100644 --- a/py4web/utils/auth_plugins/oauth2facebook.py +++ b/py4web/utils/auth_plugins/oauth2facebook.py @@ -1,6 +1,7 @@ -from . import OAuth2 import requests +from . import OAuth2 + class OAuth2Facebook(OAuth2): name = "oauth2facebook" diff --git a/py4web/utils/auth_plugins/pam.py b/py4web/utils/auth_plugins/pam.py index da77d710a..5af9c7112 100644 --- a/py4web/utils/auth_plugins/pam.py +++ b/py4web/utils/auth_plugins/pam.py @@ -14,20 +14,8 @@ __all__ = ["authenticate"] import sys -from ctypes import ( - CDLL, - CFUNCTYPE, - POINTER, - Structure, - byref, - c_char, - c_char_p, - c_int, - c_uint, - c_void_p, - cast, - sizeof, -) +from ctypes import (CDLL, CFUNCTYPE, POINTER, Structure, byref, c_char, + c_char_p, c_int, c_uint, c_void_p, cast, sizeof) from ctypes.util import find_library libpam = CDLL(find_library("pam")) diff --git a/py4web/utils/auth_plugins/x509_auth_plugin.py b/py4web/utils/auth_plugins/x509_auth_plugin.py index aadfb9b2e..0a25a6e6f 100644 --- a/py4web/utils/auth_plugins/x509_auth_plugin.py +++ b/py4web/utils/auth_plugins/x509_auth_plugin.py @@ -14,7 +14,6 @@ from gluon.globals import current from gluon.storage import Storage - # requires M2Crypto from M2Crypto import X509 diff --git a/py4web/utils/form.py b/py4web/utils/form.py index de19ecc77..5fcbd619f 100644 --- a/py4web/utils/form.py +++ b/py4web/utils/form.py @@ -7,20 +7,8 @@ import jwt from pydal._compat import to_native from pydal.objects import FieldVirtual -from yatl.helpers import ( - CAT, - DIV, - FORM, - INPUT, - LABEL, - OPTION, - SELECT, - SPAN, - TEXTAREA, - XML, - A, - P, -) +from yatl.helpers import (CAT, DIV, FORM, INPUT, LABEL, OPTION, SELECT, SPAN, + TEXTAREA, XML, A, P) from py4web import HTTP, request, response from py4web.utils.param import Param diff --git a/py4web/utils/grid.py b/py4web/utils/grid.py index beedb3b45..f1ac8ac5a 100644 --- a/py4web/utils/grid.py +++ b/py4web/utils/grid.py @@ -8,25 +8,8 @@ from urllib.parse import urlparse from pydal.objects import Expression, Field, FieldVirtual -from yatl.helpers import ( - CAT, - DIV, - FORM, - INPUT, - OPTION, - SELECT, - SPAN, - TABLE, - TAG, - TBODY, - TD, - TH, - THEAD, - TR, - XML, - A, - I, -) +from yatl.helpers import (CAT, DIV, FORM, INPUT, OPTION, SELECT, SPAN, TABLE, + TAG, TBODY, TD, TH, THEAD, TR, XML, A, I) from py4web import HTTP, URL, redirect, request, safely from py4web.utils.form import Form, FormStyleDefault, join_classes @@ -758,10 +741,7 @@ def process(self): self.form.param.submit_value = self.param.edit_submit_value # redirect to the referrer - if ( - self.form.accepted - or (readonly and request.method == "POST") - ): + if self.form.accepted or (readonly and request.method == "POST"): referrer = request.query.get("_referrer") if referrer: redirect(base64.b16decode(referrer.encode("utf8")).decode("utf8")) diff --git a/py4web/utils/tags.py b/py4web/utils/tags.py index 26172e695..df3b8150a 100644 --- a/py4web/utils/tags.py +++ b/py4web/utils/tags.py @@ -1,6 +1,5 @@ import logging - logging.warning( "Deprecation notice: replace py4web.utils.tags with pydal.tools.tags in your code." )