Clean unused code and improve logging

develop
blallo 2022-02-01 23:29:48 +01:00
parent b0d2f759ea
commit b704ea4d10
Signed by: blallo
GPG Key ID: 0CBE577C9B72DC3F
4 changed files with 11 additions and 41 deletions

View File

@ -41,9 +41,14 @@ logging:
phi: phi:
level: DEBUG level: DEBUG
handlers: [console, file] handlers: [console, file]
asyncio:
level: DEBUG
handlers: [console, file]
propagate: yes
aiohttp: aiohttp:
level: DEBUG level: DEBUG
handlers: [console, file] handlers: [console, file]
ldap3: propagate: yes
level: WARNING bonsai:
level: DEBUG
handlers: [console, file] handlers: [console, file]

View File

@ -1,6 +1,4 @@
# -*- encoding: utf-8 -*- # -*- encoding: utf-8 -*-
import logging
from aiohttp import web from aiohttp import web
from phi.logging import get_logger from phi.logging import get_logger
@ -8,16 +6,8 @@ from phi.async_ldap.client import AsyncClient
from phi.async_ldap.model import Hackers, Robots, Congregations from phi.async_ldap.model import Hackers, Robots, Congregations
from phi.api.routes import api_routes from phi.api.routes import api_routes
log = get_logger(__name__) log = get_logger(__name__)
alog = logging.getLogger("asyncio")
def api_startup(app):
app["ldap_client"].open()
def api_shutdown(app):
app["ldap_client"].close()
def api_app(config): def api_app(config):
@ -30,10 +20,7 @@ def api_app(config):
app["users"] = Hackers(ldap_client) app["users"] = Hackers(ldap_client)
app["services"] = Robots(ldap_client) app["services"] = Robots(ldap_client)
app["groups"] = Congregations(ldap_client) app["groups"] = Congregations(ldap_client)
app["alog"] = alog app["log"] = log
app.on_startup.append(api_startup)
app.on_shutdown.append(api_shutdown)
app.router.add_routes(api_routes) app.router.add_routes(api_routes)

View File

@ -1,7 +1,6 @@
# -*- encoding: utf-8 -*- # -*- encoding: utf-8 -*-
import pkg_resources import pkg_resources
from asyncio import get_event_loop
from aiohttp import web from aiohttp import web
import click import click
from pprint import pformat as pp from pprint import pformat as pp
@ -15,9 +14,7 @@ log = get_logger(__name__)
def setup_app(config): def setup_app(config):
loop = get_event_loop() app = web.Application()
app = web.Application(loop=loop)
app["config"] = config app["config"] = config
api = api_app(config) api = api_app(config)
@ -34,19 +31,6 @@ def run_app(app):
) )
def _validate_port(ctx, param, value):
"""
Callback to validate provided port.
"""
if 0 < value or value > 65535:
raise click.BadParameter(
"Provided value is not in the range 0-65535: {} [type: {}]".format(
value, type(value)
)
)
return value
@click.command(help="phid is the main application daemon.") @click.command(help="phid is the main application daemon.")
@click.option( @click.option(
"--config", "--config",

View File

@ -86,7 +86,7 @@ class AsyncClient(LDAPClient):
host=None, host=None,
port=None, port=None,
encryption=None, encryption=None,
ciphers=None, cyphers=None,
validate=False, validate=False,
ca_cert=None, ca_cert=None,
username=None, username=None,
@ -130,9 +130,3 @@ class AsyncClient(LDAPClient):
self.set_auto_page_acquire(True) self.set_auto_page_acquire(True)
self.set_credentials(self.method, user=self.username, password=self.password) self.set_credentials(self.method, user=self.username, password=self.password)
def open(self):
pass
def close(self):
pass