From 45835a3f158833bc6cbd2c712e6554708c7a6bc6 Mon Sep 17 00:00:00 2001 From: Lars Kruse <devel@sumpfralle.de> Date: Thu, 17 Feb 2022 03:09:41 +0100 Subject: [PATCH] style: apply uniform import order (via isort) --- contrib/heartbeat-monitor/PyHeartBeat.py | 5 ++--- run.py | 13 ++++++------- src/base/config.py | 5 ++--- src/base/utils.py | 1 - src/client/client.py | 5 ++--- src/client/connector.py | 3 ++- src/control.py | 8 ++++---- src/engine.py | 24 +++++++++++------------- src/events.py | 3 +-- src/mixer.py | 1 - src/plugins/mailer.py | 1 - src/plugins/monitor.py | 16 +++++++--------- src/plugins/trackservice.py | 7 +++---- src/scheduling/api.py | 2 +- src/scheduling/models.py | 11 +++++------ src/scheduling/programme.py | 8 +++----- src/scheduling/scheduler.py | 10 ++++------ src/scheduling/utils.py | 5 ++--- tests/test_config.py | 1 + tests/test_engine_executor.py | 2 +- tests/test_logger.py | 2 +- 21 files changed, 58 insertions(+), 75 deletions(-) diff --git a/contrib/heartbeat-monitor/PyHeartBeat.py b/contrib/heartbeat-monitor/PyHeartBeat.py index 0115d99b..b3071f7b 100755 --- a/contrib/heartbeat-monitor/PyHeartBeat.py +++ b/contrib/heartbeat-monitor/PyHeartBeat.py @@ -53,9 +53,8 @@ https://www.oreilly.com/library/view/python-cookbook/0596001673/ch10s13.html import os import socket import sys -from threading import Lock, Thread, Event -from time import time, ctime, sleep - +from threading import Event, Lock, Thread +from time import ctime, sleep, time DEFAULT_HEARTBEAT_PORT = 43334 DEFAULT_WAIT_PERIOD = 10 diff --git a/run.py b/run.py index 9b12ec2c..73fd70b6 100755 --- a/run.py +++ b/run.py @@ -21,21 +21,20 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. +import logging import os -import sys import signal -import logging +import sys import threading -from flask import Flask -from flask_sqlalchemy import SQLAlchemy +from flask import Flask +from flask_sqlalchemy import SQLAlchemy -from src.base.logger import AuraLogger from src.base.config import AuraConfig -from src.base.utils import SimpleUtil as SU +from src.base.logger import AuraLogger +from src.base.utils import SimpleUtil as SU from src.scheduling.models import DB - config = AuraConfig() def configure_flask(): app.config["SQLALCHEMY_DATABASE_URI"] = config.get_database_uri() diff --git a/src/base/config.py b/src/base/config.py index b16f29af..b7845da4 100644 --- a/src/base/config.py +++ b/src/base/config.py @@ -17,13 +17,12 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. +import logging import os import os.path import sys -import logging - -from pathlib import Path from configparser import ConfigParser +from pathlib import Path class AuraConfig: diff --git a/src/base/utils.py b/src/base/utils.py index 14074337..3636dc5d 100644 --- a/src/base/utils.py +++ b/src/base/utils.py @@ -19,7 +19,6 @@ import datetime import time - from enum import Enum diff --git a/src/client/client.py b/src/client/client.py index 27fa97eb..2fa2c2ae 100644 --- a/src/client/client.py +++ b/src/client/client.py @@ -17,11 +17,10 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. -import socket -import urllib.parse import configparser import logging - +import socket +import urllib.parse from multiprocessing import Lock from src.base.exceptions import LQConnectionError diff --git a/src/client/connector.py b/src/client/connector.py index ce4fb660..96b0b8c6 100644 --- a/src/client/connector.py +++ b/src/client/connector.py @@ -21,8 +21,9 @@ import logging import time from src.base.config import AuraConfig -from src.base.utils import TerminalColors, SimpleUtil as SU from src.base.exceptions import LQConnectionError +from src.base.utils import SimpleUtil as SU +from src.base.utils import TerminalColors from src.client.playerclient import LiquidSoapPlayerClient diff --git a/src/control.py b/src/control.py index 90d03c80..b88f5427 100644 --- a/src/control.py +++ b/src/control.py @@ -17,14 +17,14 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. +import json import logging import socket import time -import json -import requests - -from threading import Thread, Timer, Lock from datetime import datetime, timedelta +from threading import Lock, Thread, Timer + +import requests from http_parser.http import HttpStream from http_parser.reader import SocketReader diff --git a/src/engine.py b/src/engine.py index 0ebdfdb2..654f746d 100644 --- a/src/engine.py +++ b/src/engine.py @@ -17,38 +17,36 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. -import time import logging - +import time from collections import namedtuple from contextlib import suppress from threading import Thread import meta - from src.base.config import AuraConfig -from src.base.utils import SimpleUtil as SU from src.base.exceptions import ( - LQConnectionError, InvalidChannelException, - LQStreamException, LoadSourceException, + LQConnectionError, + LQStreamException, ) -from src.resources import ResourceClass, ResourceUtil +from src.base.utils import SimpleUtil as SU from src.channels import ( Channel, + ChannelResolver, + ChannelRouter, ChannelType, - TransitionType, - LiquidsoapResponse, EntryPlayState, + LiquidsoapResponse, ResourceType, - ChannelRouter, - ChannelResolver, + TransitionType, ) -from src.events import EngineEventDispatcher +from src.client.connector import PlayerConnector from src.control import EngineControlInterface +from src.events import EngineEventDispatcher from src.mixer import Mixer, MixerType -from src.client.connector import PlayerConnector +from src.resources import ResourceClass, ResourceUtil class Engine: diff --git a/src/events.py b/src/events.py index 6d2a4e90..6df21245 100644 --- a/src/events.py +++ b/src/events.py @@ -17,9 +17,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. -import logging import datetime - +import logging from threading import Thread from src.base.config import AuraConfig diff --git a/src/mixer.py b/src/mixer.py index 44d6b5df..7aa46130 100644 --- a/src/mixer.py +++ b/src/mixer.py @@ -19,7 +19,6 @@ import logging import time - from enum import Enum from src.base.exceptions import LQConnectionError diff --git a/src/plugins/mailer.py b/src/plugins/mailer.py index ff0f0659..f34f2583 100644 --- a/src/plugins/mailer.py +++ b/src/plugins/mailer.py @@ -19,7 +19,6 @@ import logging import smtplib - from email.message import EmailMessage from src.base.config import AuraConfig diff --git a/src/plugins/monitor.py b/src/plugins/monitor.py index 17d7e128..36a9484b 100644 --- a/src/plugins/monitor.py +++ b/src/plugins/monitor.py @@ -17,24 +17,22 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. -import os import datetime -import urllib -import logging import json -import threading +import logging +import os import platform -import requests - +import threading +import urllib from enum import Enum -from socket import socket, AF_INET, SOCK_DGRAM, SOL_SOCKET, SO_BROADCAST +from socket import AF_INET, SO_BROADCAST, SOCK_DGRAM, SOL_SOCKET, socket -import meta +import requests +import meta from src.base.config import AuraConfig from src.base.utils import SimpleUtil as SU - # Exceptions diff --git a/src/plugins/trackservice.py b/src/plugins/trackservice.py index ee6f9c84..1f33e66b 100644 --- a/src/plugins/trackservice.py +++ b/src/plugins/trackservice.py @@ -19,14 +19,13 @@ import json import logging -import requests - from collections import deque +import requests + from src.base.config import AuraConfig from src.base.utils import SimpleUtil as SU -from src.resources import ResourceClass -from src.resources import ResourceUtil +from src.resources import ResourceClass, ResourceUtil class TrackServiceHandler: diff --git a/src/scheduling/api.py b/src/scheduling/api.py index 3eb487e8..fe1abcdf 100644 --- a/src/scheduling/api.py +++ b/src/scheduling/api.py @@ -18,10 +18,10 @@ import logging -import requests import queue import threading +import requests from src.base.utils import SimpleUtil as SU from src.scheduling.utils import TimeslotFilter diff --git a/src/scheduling/models.py b/src/scheduling/models.py index 2f0c43e2..c81f708f 100644 --- a/src/scheduling/models.py +++ b/src/scheduling/models.py @@ -17,26 +17,25 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. +import datetime +import logging import sys import time -import logging -import datetime import sqlalchemy as sa - from sqlalchemy import ( BigInteger, Boolean, Column, + ColumnDefault, DateTime, + ForeignKey, Integer, String, - ForeignKey, - ColumnDefault, ) -from sqlalchemy.orm import relationship from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.ext.hybrid import hybrid_property +from sqlalchemy.orm import relationship from src.base.config import AuraConfig from src.base.utils import SimpleUtil diff --git a/src/scheduling/programme.py b/src/scheduling/programme.py index 2c47e4eb..09e10fc5 100644 --- a/src/scheduling/programme.py +++ b/src/scheduling/programme.py @@ -18,21 +18,19 @@ import logging - from datetime import datetime - from src.base.config import AuraConfig from src.base.utils import SimpleUtil as SU from src.engine import Engine -from src.scheduling.utils import M3UPlaylistProcessor +from src.scheduling.api import ApiFetcher from src.scheduling.models import ( - Timeslot, Playlist, PlaylistEntry, PlaylistEntryMetaData, + Timeslot, ) -from src.scheduling.api import ApiFetcher +from src.scheduling.utils import M3UPlaylistProcessor class ProgrammeService: diff --git a/src/scheduling/scheduler.py b/src/scheduling/scheduler.py index 7fc59bfe..2d3f5b27 100644 --- a/src/scheduling/scheduler.py +++ b/src/scheduling/scheduler.py @@ -21,18 +21,16 @@ import logging import threading import time - from src.base.config import AuraConfig +from src.base.exceptions import LoadSourceException, NoActiveTimeslotException from src.base.utils import SimpleUtil as SU -from src.scheduling.models import AuraDatabaseModel -from src.base.exceptions import NoActiveTimeslotException, LoadSourceException +from src.channels import ChannelType, EntryPlayState, TransitionType from src.control import EngineExecutor from src.engine import Engine -from src.channels import ChannelType, TransitionType, EntryPlayState from src.resources import ResourceClass, ResourceUtil - -from src.scheduling.utils import TimeslotRenderer +from src.scheduling.models import AuraDatabaseModel from src.scheduling.programme import ProgrammeService +from src.scheduling.utils import TimeslotRenderer class AuraScheduler(threading.Thread): diff --git a/src/scheduling/utils.py b/src/scheduling/utils.py index e66241fb..152bcc49 100644 --- a/src/scheduling/utils.py +++ b/src/scheduling/utils.py @@ -18,12 +18,11 @@ import logging - -from enum import Enum from datetime import datetime +from enum import Enum -from src.base.utils import SimpleUtil as SU from src.base.config import AuraConfig +from src.base.utils import SimpleUtil as SU class EntryQueueState(Enum): diff --git a/tests/test_config.py b/tests/test_config.py index 678e6b52..fbf3c564 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -19,6 +19,7 @@ import os import unittest + import validators from src.base.config import AuraConfig diff --git a/tests/test_engine_executor.py b/tests/test_engine_executor.py index 2ce535d6..b771e023 100644 --- a/tests/test_engine_executor.py +++ b/tests/test_engine_executor.py @@ -17,8 +17,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. -import unittest import time +import unittest from src.base.utils import SimpleUtil as SU from src.control import EngineExecutor diff --git a/tests/test_logger.py b/tests/test_logger.py index dc3e4d29..c7ef5956 100644 --- a/tests/test_logger.py +++ b/tests/test_logger.py @@ -19,8 +19,8 @@ import unittest -from src.base.logger import AuraLogger from src.base.config import AuraConfig +from src.base.logger import AuraLogger class TestLogger(unittest.TestCase): -- GitLab