Clean unused code and improve logging

This commit is contained in:
sfigato 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:
level: DEBUG
handlers: [console, file]
asyncio:
level: DEBUG
handlers: [console, file]
propagate: yes
aiohttp:
level: DEBUG
handlers: [console, file]
ldap3:
level: WARNING
propagate: yes
bonsai:
level: DEBUG
handlers: [console, file]

View File

@ -1,6 +1,4 @@
# -*- encoding: utf-8 -*-
import logging
from aiohttp import web
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.api.routes import api_routes
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):
@ -30,10 +20,7 @@ def api_app(config):
app["users"] = Hackers(ldap_client)
app["services"] = Robots(ldap_client)
app["groups"] = Congregations(ldap_client)
app["alog"] = alog
app.on_startup.append(api_startup)
app.on_shutdown.append(api_shutdown)
app["log"] = log
app.router.add_routes(api_routes)

View File

@ -1,7 +1,6 @@
# -*- encoding: utf-8 -*-
import pkg_resources
from asyncio import get_event_loop
from aiohttp import web
import click
from pprint import pformat as pp
@ -15,9 +14,7 @@ log = get_logger(__name__)
def setup_app(config):
loop = get_event_loop()
app = web.Application(loop=loop)
app = web.Application()
app["config"] = 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.option(
"--config",

View File

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