Skip to content

Commit

Permalink
Sort module imports using Ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
pgiraud committed Aug 13, 2024
1 parent 7fd6001 commit 10c1673
Show file tree
Hide file tree
Showing 23 changed files with 392 additions and 249 deletions.
2 changes: 1 addition & 1 deletion .ruff.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[lint]
# Add "Q" to the list of enabled codes.
extend-select = ["E4", "E7", "E9", "F", "Q"]
extend-select = ["E4", "E7", "E9", "F", "Q", "I"]
110 changes: 70 additions & 40 deletions powa/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from __future__ import print_function

"""
Powa main application.
"""
Expand All @@ -12,26 +13,33 @@

POWA_ROOT = os.path.dirname(__file__)

from tornado.web import Application, URLSpec as U # noqa: E402
from powa.options import parse_options # noqa: E402
from tornado.options import options # noqa: E402
from powa import ui_modules, ui_methods # noqa: E402
from tornado.web import Application # noqa: E402
from tornado.web import URLSpec as U # noqa: E402

from powa import ui_methods, ui_modules # noqa: E402
from powa.collector import ( # noqa: E402
CollectorDbCatRefreshHandler, # noqa: E402
CollectorForceSnapshotHandler, # noqa: E402
CollectorReloadHandler,
)
from powa.config import RemoteConfigOverview, RepositoryConfigOverview # noqa: E402
from powa.database import DatabaseOverview, DatabaseSelector # noqa: E402
from powa.framework import AuthHandler # noqa: E402
from powa.user import LoginHandler, LogoutHandler # noqa: E402
from powa.function import FunctionOverview # noqa: E402
from powa.io import ( # noqa: E402
ByBackendTypeIoOverview,
ByContextIoOverview, # noqa: E402
ByObjIoOverview,
)
from powa.options import parse_options # noqa: E402
from powa.overview import Overview # noqa: E402
from powa.server import ServerSelector, ServerOverview # noqa: E402
from powa.database import DatabaseSelector, DatabaseOverview # noqa: E402
from powa.query import QueryOverview # noqa: E402
from powa.qual import QualOverview # noqa: E402
from powa.function import FunctionOverview # noqa: E402
from powa.config import RepositoryConfigOverview, RemoteConfigOverview # noqa: E402
from powa.collector import (CollectorReloadHandler, # noqa: E402
CollectorForceSnapshotHandler, # noqa: E402
CollectorDbCatRefreshHandler) # noqa: E402
from powa.wizard import IndexSuggestionHandler # noqa: E402
from powa.io import (ByBackendTypeIoOverview, ByObjIoOverview, # noqa: E402
ByContextIoOverview) # noqa: E402
from powa.query import QueryOverview # noqa: E402
from powa.server import ServerOverview, ServerSelector # noqa: E402
from powa.slru import ByNameSlruOverview # noqa: E402
from powa.user import LoginHandler, LogoutHandler # noqa: E402
from powa.wizard import IndexSuggestionHandler # noqa: E402


class IndexHandler(AuthHandler):
Expand All @@ -52,38 +60,59 @@ def make_app(**kwargs):
URLS = [
U(r"%slogin/" % options.url_prefix, LoginHandler, name="login"),
U(r"%slogout/" % options.url_prefix, LogoutHandler, name="logout"),
U(r"%sreload_collector/" % options.url_prefix, CollectorReloadHandler,
name="reload_collector"),
U(r"%sforce_snapshot/(\d+)" % options.url_prefix,
CollectorForceSnapshotHandler, name="force_snapshot"),
U(r"%srefresh_db_cat/" % options.url_prefix,
CollectorDbCatRefreshHandler, name="refresh_db_cat"),
U(r"%sserver/select" % options.url_prefix, ServerSelector,
name="server_selector"),
U(r"%sdatabase/select" % options.url_prefix, DatabaseSelector,
name="database_selector"),
U(
r"%sreload_collector/" % options.url_prefix,
CollectorReloadHandler,
name="reload_collector",
),
U(
r"%sforce_snapshot/(\d+)" % options.url_prefix,
CollectorForceSnapshotHandler,
name="force_snapshot",
),
U(
r"%srefresh_db_cat/" % options.url_prefix,
CollectorDbCatRefreshHandler,
name="refresh_db_cat",
),
U(
r"%sserver/select" % options.url_prefix,
ServerSelector,
name="server_selector",
),
U(
r"%sdatabase/select" % options.url_prefix,
DatabaseSelector,
name="database_selector",
),
U(r"%s" % options.url_prefix, IndexHandler, name="index"),
U(r"%sserver/(\d+)/database/([^\/]+)/suggest/" % options.url_prefix,
IndexSuggestionHandler, name="index_suggestion")
U(
r"%sserver/(\d+)/database/([^\/]+)/suggest/" % options.url_prefix,
IndexSuggestionHandler,
name="index_suggestion",
),
]

for dashboard in (Overview,
ServerOverview,
DatabaseOverview,
QueryOverview,
QualOverview,
FunctionOverview,
RepositoryConfigOverview,
RemoteConfigOverview,
ByBackendTypeIoOverview,
ByObjIoOverview,
ByContextIoOverview,
ByNameSlruOverview):
for dashboard in (
Overview,
ServerOverview,
DatabaseOverview,
QueryOverview,
QualOverview,
FunctionOverview,
RepositoryConfigOverview,
RemoteConfigOverview,
ByBackendTypeIoOverview,
ByObjIoOverview,
ByContextIoOverview,
ByNameSlruOverview,
):
URLS.extend(dashboard.url_specs(options.url_prefix))

_cls = Application
if "legacy_wsgi" in kwargs:
from tornado.wsgi import WSGIApplication

_cls = WSGIApplication

return _cls(
Expand All @@ -95,4 +124,5 @@ def make_app(**kwargs):
static_url_prefix=("%sstatic/" % options.url_prefix),
cookie_secret=options.cookie_secret,
template_path=os.path.join(POWA_ROOT, "templates"),
**kwargs)
**kwargs,
)
2 changes: 2 additions & 0 deletions powa/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
collector handling.
"""
from __future__ import absolute_import

import json

from powa.dashboards import MetricGroupDef
from powa.framework import AuthHandler

Expand Down
4 changes: 3 additions & 1 deletion powa/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
"""
from __future__ import absolute_import

import json

import psycopg2
from psycopg2 import extensions
import json

# If psycopg2 < 2.5, register json type
psycopg2_version = tuple(psycopg2.__version__.split(" ")[0].split("."))
Expand Down
16 changes: 11 additions & 5 deletions powa/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@
Dashboard for the configuration summary page.
"""
from __future__ import absolute_import

import json

from powa.collector import CollectorServerDetail
from powa.dashboards import (
Dashboard, Grid,
MetricGroupDef, MetricDef,
DashboardPage, ContentWidget)
ContentWidget,
Dashboard,
DashboardPage,
Grid,
MetricDef,
MetricGroupDef,
)
from powa.sql.views import get_config_changes
from powa.collector import CollectorServerDetail
import json


def get_pgts_query(handler, restrict_database=False):
Expand Down
Loading

0 comments on commit 10c1673

Please sign in to comment.