From c6ec9327aa89920bccbdd40694c38d4be0f3af41 Mon Sep 17 00:00:00 2001 From: Faustin Lammler Date: Fri, 21 Jun 2024 15:35:42 +0200 Subject: [PATCH] Black linting --- buildbot.tac | 19 +- ci_build_images/buildbot.tac | 22 +- cross-reference/crossreference/cr/apps.py | 4 +- cross-reference/crossreference/cr/models.py | 486 +++++++++--------- cross-reference/crossreference/cr/router.py | 17 +- cross-reference/crossreference/cr/urls.py | 2 +- .../crossreference/crossreference/asgi.py | 2 +- .../crossreference/crossreference/settings.py | 99 ++-- .../crossreference/crossreference/urls.py | 6 +- .../crossreference/crossreference/wsgi.py | 2 +- cross-reference/crossreference/manage.py | 4 +- master-bintars/buildbot.tac | 19 +- master-docker-nonstandard-2/buildbot.tac | 19 +- master-docker-nonstandard/buildbot.tac | 19 +- master-galera/buildbot.tac | 19 +- master-libvirt/buildbot.tac | 19 +- master-libvirt/get_ssh_cnx_num.py | 5 +- master-nonlatent/buildbot.tac | 19 +- master-protected-branches/buildbot.tac | 19 +- master-web/buildbot.tac | 19 +- schedulers_definition.py | 15 +- utils.py | 18 +- 22 files changed, 474 insertions(+), 379 deletions(-) diff --git a/buildbot.tac b/buildbot.tac index b987eabb..af56b53b 100644 --- a/buildbot.tac +++ b/buildbot.tac @@ -3,28 +3,33 @@ import os from twisted.application import service from buildbot.master import BuildMaster -basedir = '.' -log_basedir = '/var/log/buildbot/' +basedir = "." +log_basedir = "/var/log/buildbot/" rotateLength = 20000000 maxRotatedFiles = 30 -configfile = 'master.cfg' +configfile = "master.cfg" # Default umask for server umask = None # if this is a relocatable tac file, get the directory containing the TAC -if basedir == '.': +if basedir == ".": import os + basedir = os.path.abspath(os.path.dirname(__file__)) # note: this line is matched against to check that this is a buildmaster # directory; do not edit it. -application = service.Application('buildmaster') +application = service.Application('buildmaster') # fmt: skip from twisted.python.logfile import LogFile from twisted.python.log import ILogObserver, FileLogObserver -logfile = LogFile.fromFullPath(os.path.join(log_basedir, "%s"), rotateLength=rotateLength, - maxRotatedFiles=maxRotatedFiles) + +logfile = LogFile.fromFullPath( + os.path.join(log_basedir, "%s"), + rotateLength=rotateLength, + maxRotatedFiles=maxRotatedFiles, +) application.setComponent(ILogObserver, FileLogObserver(logfile).emit) m = BuildMaster(basedir, configfile, umask) diff --git a/ci_build_images/buildbot.tac b/ci_build_images/buildbot.tac index 7bfce797..c3884a84 100644 --- a/ci_build_images/buildbot.tac +++ b/ci_build_images/buildbot.tac @@ -10,14 +10,14 @@ from buildbot_worker.bot import Worker # setup worker basedir = os.path.abspath(os.path.dirname(__file__)) -application = service.Application('buildbot-worker') +application = service.Application('buildbot-worker') # fmt: skip application.setComponent(ILogObserver, FileLogObserver(sys.stdout).emit) # and worker on the same process! -buildmaster_host = os.environ.get("BUILDMASTER", 'localhost') +buildmaster_host = os.environ.get("BUILDMASTER", "localhost") port = int(os.environ.get("BUILDMASTER_PORT", 9989)) -workername = os.environ.get("WORKERNAME", 'docker') +workername = os.environ.get("WORKERNAME", "docker") passwd = os.environ.get("WORKERPASS") # delete the password from the environ so that it is not leaked in the log @@ -33,7 +33,17 @@ maxdelay = 300 allow_shutdown = None maxretries = 10 -s = Worker(buildmaster_host, port, workername, passwd, basedir, - keepalive, umask=umask, maxdelay=maxdelay, - allow_shutdown=allow_shutdown, maxRetries=maxretries, unicode_encoding='utf-8') +s = Worker( + buildmaster_host, + port, + workername, + passwd, + basedir, + keepalive, + umask=umask, + maxdelay=maxdelay, + allow_shutdown=allow_shutdown, + maxRetries=maxretries, + unicode_encoding="utf-8", +) s.setServiceParent(application) diff --git a/cross-reference/crossreference/cr/apps.py b/cross-reference/crossreference/cr/apps.py index 4f713321..ebfdcc42 100644 --- a/cross-reference/crossreference/cr/apps.py +++ b/cross-reference/crossreference/cr/apps.py @@ -2,5 +2,5 @@ class CrConfig(AppConfig): - default_auto_field = 'django.db.models.BigAutoField' - name = 'cr' + default_auto_field = "django.db.models.BigAutoField" + name = "cr" diff --git a/cross-reference/crossreference/cr/models.py b/cross-reference/crossreference/cr/models.py index af0f55e2..40147171 100644 --- a/cross-reference/crossreference/cr/models.py +++ b/cross-reference/crossreference/cr/models.py @@ -5,6 +5,7 @@ from django.db import connection from datetime import datetime + class Builder(models.Model): id = models.IntegerField(primary_key=True) name = models.TextField() @@ -13,243 +14,264 @@ class Builder(models.Model): class Meta: managed = False - db_table = 'builders' + db_table = "builders" + class TestRun(models.Model): - branch = models.CharField(max_length=100, blank=True, null=True) - revision = models.CharField(max_length=256, blank=True, null=True) - platform = models.CharField(max_length=100) - dt = models.DateTimeField() - bbnum = models.IntegerField() - typ = models.CharField(max_length=32) - info = models.CharField(max_length=255, blank=True, null=True) - - @property - def platform_name(self): - builder = Builder.objects.filter(name=self.platform).first() - return builder.id if builder else None - - class Meta: - managed = False - db_table = 'test_run' + branch = models.CharField(max_length=100, blank=True, null=True) + revision = models.CharField(max_length=256, blank=True, null=True) + platform = models.CharField(max_length=100) + dt = models.DateTimeField() + bbnum = models.IntegerField() + typ = models.CharField(max_length=32) + info = models.CharField(max_length=255, blank=True, null=True) + + @property + def platform_name(self): + builder = Builder.objects.filter(name=self.platform).first() + return builder.id if builder else None + + class Meta: + managed = False + db_table = "test_run" + class TestFailure(models.Model): - test_run_id = models.ForeignKey(TestRun, - null=False, - blank=False, - db_column='test_run_id', - primary_key=True, - unique=False, - on_delete=models.DO_NOTHING - ) - test_name = models.CharField(max_length=100) - test_variant = models.CharField(max_length=64) - info_text = models.CharField(max_length=255, blank=True, null=True) - failure_text = models.TextField(blank=True, null=True) - - @property - def platform(self): - return self.test_run_id.platform - - class Meta: - managed = False - db_table = 'test_failure' - unique_together = (('test_run_id', 'test_name', 'test_variant'),) + test_run_id = models.ForeignKey( + TestRun, + null=False, + blank=False, + db_column="test_run_id", + primary_key=True, + unique=False, + on_delete=models.DO_NOTHING, + ) + test_name = models.CharField(max_length=100) + test_variant = models.CharField(max_length=64) + info_text = models.CharField(max_length=255, blank=True, null=True) + failure_text = models.TextField(blank=True, null=True) + + @property + def platform(self): + return self.test_run_id.platform + + class Meta: + managed = False + db_table = "test_failure" + unique_together = (("test_run_id", "test_name", "test_variant"),) def select_test_failures(filters, include_failures=True): - available_filters = ["branch", "revision", "platform", "dt", "bbnum", "typ", "info", "test_name", "test_variant", "info_text", "failure_text"] - - # New implementation - limit = 50 - if 'limit' in filters and filters['limit'] != '': - limit = int(filters['limit']) - - test_run_filters = None - test_failure_filters = None - - reg_exp = { - 'branch': [ - # Pattern: 10.? - { - 'pattern': '^([0-9]{1,2}\.)(\?)$', - 'filter': [('test_run_id__branch__startswith', 'AND')], - 'replace': True - }, - # Pattern: 10.1, 10.2, 5.5... - { - 'pattern': '^([0-9]{1,2}\.)([0-9]{1,2})$', - 'filter': [('test_run_id__branch__exact', 'AND')], - 'replace': False - }, - # Pattern: *10.1*, *10.2*... - { - 'pattern': '^\*([0-9]{1,2}\.)([0-9]{1,2})\*$', - 'filter': [('test_run_id__branch__icontains', 'AND')], - 'replace': True - }, - # Pattern *10.?* - { - 'pattern': '^\*([0-9]{1,2}\.)(\?)\*$', - 'filter': [('test_run_id__branch__icontains', 'AND'), ('test_run_id__branch__startswith', 'OR')], - 'replace': True - }, - { - 'pattern': '^[a-zA-Z0-9_.-]*$', - 'filter': [('test_run_id__branch__icontains', 'AND')], - 'replace': False - } - ], - 'revision': [ - { - 'pattern': '^[a-zA-Z0-9]*$', - 'filter': [('test_run_id__revision__startswith', 'AND')], - 'replace': False - } - ], - 'platform': [ - { - 'pattern': '^[a-zA-Z0-9_.-]*$', - 'filter': [('test_run_id__platform__exact', 'AND')], - 'replace': False - }, - { - 'pattern': '^\*[a-zA-Z0-9_.-]*\*$', - 'filter': [('test_run_id__platform__icontains', 'AND')], - 'replace': True - } - ], - 'typ': [ - { - 'pattern': '^[a-zA-Z0-9]*$', - 'filter': [('test_run_id__typ__exact', 'AND')], - 'replace': False - }, - { - 'pattern': '^[a-zA-Z0-9]*\*$', - 'filter': [('test_run_id__typ__startswith', 'AND')], - 'replace': True - } - ], - 'info': [ - { - 'pattern': '^[a-zA-Z0-9]*$', - 'filter': [('test_run_id__info__exact', 'AND')], - 'replace': False - }, - { - 'pattern': '^[a-zA-Z0-9]*\*$', - 'filter': [('test_run_id__info__startswith', 'AND')], - 'replace': True - } - ], - 'test_name': [ - { - 'pattern': '^[/a-zA-Z0-9_.-]*$', - 'filter': [('test_name__exact', 'AND')], - 'replace': False - }, - { - 'pattern': '^\*\.[/a-zA-Z0-9_.-]*$', - 'filter': [('test_name__icontains', 'AND')], - 'replace': True - } - ], - 'test_variant': [ - { - 'pattern': '^[a-zA-Z0-9]*$', - 'filter': [('test_variant__exact', 'AND')], - 'replace': False - }, - { - 'pattern': '^\*[a-zA-Z0-9]*\*$', - 'filter': [('test_variant__in', 'AND')], - 'replace': True - } - ], - 'failure_text': [ - { - 'pattern': '^[^*].*[^*]$', - 'filter': [('failure_text__icontains', 'AND')], - 'replace': False - }, - { - 'pattern': '^\*[a-zA-Z0-9]*\*$', - 'filter': [('failure_text__icontains', 'AND')], - 'replace': True - } - ], - - } - - # Loop each dropdown input - for key in filters: - if filters[key] and key in available_filters: - match = None - search_string = filters[key] - q_objects = Q() - - # If the dropdown is found in the Regex rule dict - if key in reg_exp: - # Loop through each possible Regex pattern until one matches - for expression in reg_exp[key]: - # Try matching the Regex pattern with the input of the dropdown - match = re.search(expression['pattern'], filters[key]) - if match is None: - continue - - # If the input contains ? or * then eliminate them - # This is the case for multiple Regex rules. Example: 10.?, *timeout* etc. - if expression['replace']: - search_string = re.sub('(\?)|(\*)', '', search_string) - - # Loop through all the filters of a pattern - # The filters are used for the database columns - for f in expression['filter']: - # Filtering columns is done through Q objects - if f[1] == 'OR': - q_objects |= Q(**{f[0]: search_string}) + available_filters = [ + "branch", + "revision", + "platform", + "dt", + "bbnum", + "typ", + "info", + "test_name", + "test_variant", + "info_text", + "failure_text", + ] + + # New implementation + limit = 50 + if "limit" in filters and filters["limit"] != "": + limit = int(filters["limit"]) + + test_run_filters = None + test_failure_filters = None + + reg_exp = { + "branch": [ + # Pattern: 10.? + { + "pattern": "^([0-9]{1,2}\.)(\?)$", + "filter": [("test_run_id__branch__startswith", "AND")], + "replace": True, + }, + # Pattern: 10.1, 10.2, 5.5... + { + "pattern": "^([0-9]{1,2}\.)([0-9]{1,2})$", + "filter": [("test_run_id__branch__exact", "AND")], + "replace": False, + }, + # Pattern: *10.1*, *10.2*... + { + "pattern": "^\*([0-9]{1,2}\.)([0-9]{1,2})\*$", + "filter": [("test_run_id__branch__icontains", "AND")], + "replace": True, + }, + # Pattern *10.?* + { + "pattern": "^\*([0-9]{1,2}\.)(\?)\*$", + "filter": [ + ("test_run_id__branch__icontains", "AND"), + ("test_run_id__branch__startswith", "OR"), + ], + "replace": True, + }, + { + "pattern": "^[a-zA-Z0-9_.-]*$", + "filter": [("test_run_id__branch__icontains", "AND")], + "replace": False, + }, + ], + "revision": [ + { + "pattern": "^[a-zA-Z0-9]*$", + "filter": [("test_run_id__revision__startswith", "AND")], + "replace": False, + } + ], + "platform": [ + { + "pattern": "^[a-zA-Z0-9_.-]*$", + "filter": [("test_run_id__platform__exact", "AND")], + "replace": False, + }, + { + "pattern": "^\*[a-zA-Z0-9_.-]*\*$", + "filter": [("test_run_id__platform__icontains", "AND")], + "replace": True, + }, + ], + "typ": [ + { + "pattern": "^[a-zA-Z0-9]*$", + "filter": [("test_run_id__typ__exact", "AND")], + "replace": False, + }, + { + "pattern": "^[a-zA-Z0-9]*\*$", + "filter": [("test_run_id__typ__startswith", "AND")], + "replace": True, + }, + ], + "info": [ + { + "pattern": "^[a-zA-Z0-9]*$", + "filter": [("test_run_id__info__exact", "AND")], + "replace": False, + }, + { + "pattern": "^[a-zA-Z0-9]*\*$", + "filter": [("test_run_id__info__startswith", "AND")], + "replace": True, + }, + ], + "test_name": [ + { + "pattern": "^[/a-zA-Z0-9_.-]*$", + "filter": [("test_name__exact", "AND")], + "replace": False, + }, + { + "pattern": "^\*\.[/a-zA-Z0-9_.-]*$", + "filter": [("test_name__icontains", "AND")], + "replace": True, + }, + ], + "test_variant": [ + { + "pattern": "^[a-zA-Z0-9]*$", + "filter": [("test_variant__exact", "AND")], + "replace": False, + }, + { + "pattern": "^\*[a-zA-Z0-9]*\*$", + "filter": [("test_variant__in", "AND")], + "replace": True, + }, + ], + "failure_text": [ + { + "pattern": "^[^*].*[^*]$", + "filter": [("failure_text__icontains", "AND")], + "replace": False, + }, + { + "pattern": "^\*[a-zA-Z0-9]*\*$", + "filter": [("failure_text__icontains", "AND")], + "replace": True, + }, + ], + } + + # Loop each dropdown input + for key in filters: + if filters[key] and key in available_filters: + match = None + search_string = filters[key] + q_objects = Q() + + # If the dropdown is found in the Regex rule dict + if key in reg_exp: + # Loop through each possible Regex pattern until one matches + for expression in reg_exp[key]: + # Try matching the Regex pattern with the input of the dropdown + match = re.search(expression["pattern"], filters[key]) + if match is None: + continue + + # If the input contains ? or * then eliminate them + # This is the case for multiple Regex rules. Example: 10.?, *timeout* etc. + if expression["replace"]: + search_string = re.sub("(\?)|(\*)", "", search_string) + + # Loop through all the filters of a pattern + # The filters are used for the database columns + for f in expression["filter"]: + # Filtering columns is done through Q objects + if f[1] == "OR": + q_objects |= Q(**{f[0]: search_string}) + else: + q_objects &= Q(**{f[0]: search_string}) + + break + + # If the Q object is empty then skip to the next dropdown input + # Without this check, it pulls random results + if not len(q_objects): + continue + + # If it's the first time filtering, then query the database model + # Otherwise use the variable to continue filtering + if test_failure_filters is not None: + test_failure_filters = test_failure_filters.filter(q_objects) + else: + test_failure_filters = TestFailure.objects.filter(q_objects) + + # From Date dropdown filtering + if filters["dt"]: + # Check 2 date and time formats (one with time, another without) + for dt_format in ("%Y-%m-%d", "%Y-%m-%d %H:%M:%S"): + try: + formatted_date = datetime.strptime(filters["dt"], dt_format) + except ValueError as e: + print(e) + pass + # Include the date in filtering if the passes the try/except block else: - q_objects &= Q(**{f[0]: search_string}) - - break - - # If the Q object is empty then skip to the next dropdown input - # Without this check, it pulls random results - if not len(q_objects): - continue - - # If it's the first time filtering, then query the database model - # Otherwise use the variable to continue filtering - if test_failure_filters is not None: - test_failure_filters = test_failure_filters.filter(q_objects) - else: - test_failure_filters = TestFailure.objects.filter(q_objects) - - # From Date dropdown filtering - if filters['dt']: - # Check 2 date and time formats (one with time, another without) - for dt_format in ('%Y-%m-%d', '%Y-%m-%d %H:%M:%S'): - try: - formatted_date = datetime.strptime(filters['dt'], dt_format) - except ValueError as e: - print(e) - pass - # Include the date in filtering if the passes the try/except block - else: - if test_failure_filters is not None: - test_failure_filters = test_failure_filters.filter(Q(test_run_id__dt__gte=formatted_date)) - else: - test_failure_filters = TestFailure.objects.filter(Q(test_run_id__dt__gte=formatted_date)) - - # Apply the limit filer and get related models to limit the no. of queries - if test_failure_filters is not None: - test_failure_filters = test_failure_filters.order_by('-test_run_id__dt') - test_failure_filters = test_failure_filters[0:limit] - test_failure_filters = test_failure_filters.select_related('test_run_id') - - result = { - 'test_runs': test_failure_filters, - } - - return result + if test_failure_filters is not None: + test_failure_filters = test_failure_filters.filter( + Q(test_run_id__dt__gte=formatted_date) + ) + else: + test_failure_filters = TestFailure.objects.filter( + Q(test_run_id__dt__gte=formatted_date) + ) + + # Apply the limit filer and get related models to limit the no. of queries + if test_failure_filters is not None: + test_failure_filters = test_failure_filters.order_by("-test_run_id__dt") + test_failure_filters = test_failure_filters[0:limit] + test_failure_filters = test_failure_filters.select_related("test_run_id") + + result = { + "test_runs": test_failure_filters, + } + + return result diff --git a/cross-reference/crossreference/cr/router.py b/cross-reference/crossreference/cr/router.py index e5ea1b3e..fede9d79 100644 --- a/cross-reference/crossreference/cr/router.py +++ b/cross-reference/crossreference/cr/router.py @@ -1,5 +1,6 @@ from .models import TestRun, TestFailure, Builder + class MariaDBRouter: """ Database router directing TestRun and TestFailure models to MariaDB. @@ -7,17 +8,23 @@ class MariaDBRouter: def db_for_read(self, model, **hints): if model in [TestRun, TestFailure, Builder]: - return 'mariadb' - return 'default' + return "mariadb" + return "default" def db_for_write(self, model, **hints): - return 'default' + return "default" def allow_relation(self, obj1, obj2, **hints): # Allow relations between TestRun and TestFailure, but not with other models - if obj1._meta.model in [TestRun, TestFailure] and obj2._meta.model in [TestRun, TestFailure]: + if obj1._meta.model in [TestRun, TestFailure] and obj2._meta.model in [ + TestRun, + TestFailure, + ]: return True - elif obj1._meta.model not in [TestRun, TestFailure] and obj2._meta.model not in [TestRun, TestFailure]: + elif obj1._meta.model not in [ + TestRun, + TestFailure, + ] and obj2._meta.model not in [TestRun, TestFailure]: return True return False diff --git a/cross-reference/crossreference/cr/urls.py b/cross-reference/crossreference/cr/urls.py index 88a9caca..5119061b 100644 --- a/cross-reference/crossreference/cr/urls.py +++ b/cross-reference/crossreference/cr/urls.py @@ -3,5 +3,5 @@ from . import views urlpatterns = [ - path('', views.index, name='index'), + path("", views.index, name="index"), ] diff --git a/cross-reference/crossreference/crossreference/asgi.py b/cross-reference/crossreference/crossreference/asgi.py index 31d80a35..f85ed234 100644 --- a/cross-reference/crossreference/crossreference/asgi.py +++ b/cross-reference/crossreference/crossreference/asgi.py @@ -11,6 +11,6 @@ from django.core.asgi import get_asgi_application -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'crossreference.settings') +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "crossreference.settings") application = get_asgi_application() diff --git a/cross-reference/crossreference/crossreference/settings.py b/cross-reference/crossreference/crossreference/settings.py index c6e9eac7..c2ab77b2 100644 --- a/cross-reference/crossreference/crossreference/settings.py +++ b/cross-reference/crossreference/crossreference/settings.py @@ -8,49 +8,49 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = os.getenv('DJANGO_SECRET_KEY') +SECRET_KEY = os.getenv("DJANGO_SECRET_KEY") # SECURITY WARNING: don't run with debug turned on in production! DEBUG = False -ALLOWED_HOSTS = ['buildbot.mariadb.org', 'localhost'] +ALLOWED_HOSTS = ["buildbot.mariadb.org", "localhost"] # Application definition INSTALLED_APPS = [ - 'django.contrib.admin', - 'django.contrib.auth', - 'django.contrib.contenttypes', - 'django.contrib.sessions', - 'django.contrib.messages', - 'django.contrib.staticfiles', - 'cr', + "django.contrib.admin", + "django.contrib.auth", + "django.contrib.contenttypes", + "django.contrib.sessions", + "django.contrib.messages", + "django.contrib.staticfiles", + "cr", ] MIDDLEWARE = [ - 'django.middleware.security.SecurityMiddleware', - 'django.contrib.sessions.middleware.SessionMiddleware', - 'django.middleware.common.CommonMiddleware', - 'django.middleware.csrf.CsrfViewMiddleware', - 'django.contrib.auth.middleware.AuthenticationMiddleware', - 'django.contrib.messages.middleware.MessageMiddleware', - 'django.middleware.clickjacking.XFrameOptionsMiddleware', + "django.middleware.security.SecurityMiddleware", + "django.contrib.sessions.middleware.SessionMiddleware", + "django.middleware.common.CommonMiddleware", + "django.middleware.csrf.CsrfViewMiddleware", + "django.contrib.auth.middleware.AuthenticationMiddleware", + "django.contrib.messages.middleware.MessageMiddleware", + "django.middleware.clickjacking.XFrameOptionsMiddleware", ] -ROOT_URLCONF = 'crossreference.urls' -WSGI_APPLICATION = 'crossreference.wsgi.application' -ASGI_APPLICATION = 'crossreference.asgi.application' +ROOT_URLCONF = "crossreference.urls" +WSGI_APPLICATION = "crossreference.wsgi.application" +ASGI_APPLICATION = "crossreference.asgi.application" TEMPLATES = [ { - 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [os.path.join(BASE_DIR, 'templates')], - 'APP_DIRS': True, - 'OPTIONS': { - 'context_processors': [ - 'django.template.context_processors.debug', - 'django.template.context_processors.request', - 'django.contrib.auth.context_processors.auth', - 'django.contrib.messages.context_processors.messages', + "BACKEND": "django.template.backends.django.DjangoTemplates", + "DIRS": [os.path.join(BASE_DIR, "templates")], + "APP_DIRS": True, + "OPTIONS": { + "context_processors": [ + "django.template.context_processors.debug", + "django.template.context_processors.request", + "django.contrib.auth.context_processors.auth", + "django.contrib.messages.context_processors.messages", ], }, }, @@ -58,48 +58,47 @@ # Database DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': os.path.join(BASE_DIR, "db.sqlite3"), + "default": { + "ENGINE": "django.db.backends.sqlite3", + "NAME": os.path.join(BASE_DIR, "db.sqlite3"), + }, + "mariadb": { + "ENGINE": "django.db.backends.mysql", + "NAME": os.getenv("DB_NAME"), + "USER": os.getenv("DB_USER"), + "PASSWORD": os.getenv("DB_PASSWORD"), + "HOST": "localhost", + "PORT": "3306", }, - 'mariadb': { - 'ENGINE': 'django.db.backends.mysql', - 'NAME': os.getenv('DB_NAME'), - 'USER': os.getenv('DB_USER'), - 'PASSWORD': os.getenv('DB_PASSWORD'), - 'HOST': 'localhost', - 'PORT': '3306', - } } -DATABASE_ROUTERS = ['cr.router.MariaDBRouter'] +DATABASE_ROUTERS = ["cr.router.MariaDBRouter"] AUTH_PASSWORD_VALIDATORS = [ { - 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator", }, { - 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator", }, { - 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator", }, { - 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator", }, ] # Internationalization -LANGUAGE_CODE = 'en-us' -TIME_ZONE = 'UTC' +LANGUAGE_CODE = "en-us" +TIME_ZONE = "UTC" USE_I18N = True USE_L10N = True USE_TZ = True # Static files (CSS, JavaScript, Images) -STATIC_URL = '/cr/static/' -STATICFILES_DIRS = [os.path.join(BASE_DIR, 'cr', 'static')] -STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') +STATIC_URL = "/cr/static/" +STATICFILES_DIRS = [os.path.join(BASE_DIR, "cr", "static")] +STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles") # Add any other settings you may need... - diff --git a/cross-reference/crossreference/crossreference/urls.py b/cross-reference/crossreference/crossreference/urls.py index 16d7423e..f2bd1d1b 100644 --- a/cross-reference/crossreference/crossreference/urls.py +++ b/cross-reference/crossreference/crossreference/urls.py @@ -13,11 +13,11 @@ 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ + from django.contrib import admin from django.urls import include, path urlpatterns = [ - path('admin/', admin.site.urls), - path('cr/', include('cr.urls')), + path("admin/", admin.site.urls), + path("cr/", include("cr.urls")), ] - diff --git a/cross-reference/crossreference/crossreference/wsgi.py b/cross-reference/crossreference/crossreference/wsgi.py index 9b55caac..15f60331 100644 --- a/cross-reference/crossreference/crossreference/wsgi.py +++ b/cross-reference/crossreference/crossreference/wsgi.py @@ -11,6 +11,6 @@ from django.core.wsgi import get_wsgi_application -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'crossreference.settings') +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "crossreference.settings") application = get_wsgi_application() diff --git a/cross-reference/crossreference/manage.py b/cross-reference/crossreference/manage.py index c331fadc..df75bfca 100755 --- a/cross-reference/crossreference/manage.py +++ b/cross-reference/crossreference/manage.py @@ -6,7 +6,7 @@ def main(): """Run administrative tasks.""" - os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'crossreference.settings') + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "crossreference.settings") try: from django.core.management import execute_from_command_line except ImportError as exc: @@ -18,5 +18,5 @@ def main(): execute_from_command_line(sys.argv) -if __name__ == '__main__': +if __name__ == "__main__": main() diff --git a/master-bintars/buildbot.tac b/master-bintars/buildbot.tac index 40027360..92d80594 100644 --- a/master-bintars/buildbot.tac +++ b/master-bintars/buildbot.tac @@ -3,28 +3,33 @@ import os from twisted.application import service from buildbot.master import BuildMaster -basedir = '.' -log_basedir = '/var/log/buildbot/' +basedir = "." +log_basedir = "/var/log/buildbot/" rotateLength = 20000000 maxRotatedFiles = 30 -configfile = 'master.cfg' +configfile = "master.cfg" # Default umask for server umask = None # if this is a relocatable tac file, get the directory containing the TAC -if basedir == '.': +if basedir == ".": import os + basedir = os.path.abspath(os.path.dirname(__file__)) # note: this line is matched against to check that this is a buildmaster # directory; do not edit it. -application = service.Application('buildmaster') +application = service.Application('buildmaster') # fmt: skip from twisted.python.logfile import LogFile from twisted.python.log import ILogObserver, FileLogObserver -logfile = LogFile.fromFullPath(os.path.join(log_basedir, "master-bintars.log"), rotateLength=rotateLength, - maxRotatedFiles=maxRotatedFiles) + +logfile = LogFile.fromFullPath( + os.path.join(log_basedir, "master-bintars.log"), + rotateLength=rotateLength, + maxRotatedFiles=maxRotatedFiles, +) application.setComponent(ILogObserver, FileLogObserver(logfile).emit) m = BuildMaster(basedir, configfile, umask) diff --git a/master-docker-nonstandard-2/buildbot.tac b/master-docker-nonstandard-2/buildbot.tac index e0b52da9..e0780de4 100644 --- a/master-docker-nonstandard-2/buildbot.tac +++ b/master-docker-nonstandard-2/buildbot.tac @@ -3,28 +3,33 @@ import os from twisted.application import service from buildbot.master import BuildMaster -basedir = '.' -log_basedir = '/var/log/buildbot/' +basedir = "." +log_basedir = "/var/log/buildbot/" rotateLength = 20000000 maxRotatedFiles = 30 -configfile = 'master.cfg' +configfile = "master.cfg" # Default umask for server umask = None # if this is a relocatable tac file, get the directory containing the TAC -if basedir == '.': +if basedir == ".": import os + basedir = os.path.abspath(os.path.dirname(__file__)) # note: this line is matched against to check that this is a buildmaster # directory; do not edit it. -application = service.Application('buildmaster') +application = service.Application('buildmaster') # fmt: skip from twisted.python.logfile import LogFile from twisted.python.log import ILogObserver, FileLogObserver -logfile = LogFile.fromFullPath(os.path.join(log_basedir, "master-docker-non-standard-2.log"), rotateLength=rotateLength, - maxRotatedFiles=maxRotatedFiles) + +logfile = LogFile.fromFullPath( + os.path.join(log_basedir, "master-docker-non-standard-2.log"), + rotateLength=rotateLength, + maxRotatedFiles=maxRotatedFiles, +) application.setComponent(ILogObserver, FileLogObserver(logfile).emit) m = BuildMaster(basedir, configfile, umask) diff --git a/master-docker-nonstandard/buildbot.tac b/master-docker-nonstandard/buildbot.tac index d8b78a87..984b5b39 100644 --- a/master-docker-nonstandard/buildbot.tac +++ b/master-docker-nonstandard/buildbot.tac @@ -3,28 +3,33 @@ import os from twisted.application import service from buildbot.master import BuildMaster -basedir = '.' -log_basedir = '/var/log/buildbot/' +basedir = "." +log_basedir = "/var/log/buildbot/" rotateLength = 20000000 maxRotatedFiles = 30 -configfile = 'master.cfg' +configfile = "master.cfg" # Default umask for server umask = None # if this is a relocatable tac file, get the directory containing the TAC -if basedir == '.': +if basedir == ".": import os + basedir = os.path.abspath(os.path.dirname(__file__)) # note: this line is matched against to check that this is a buildmaster # directory; do not edit it. -application = service.Application('buildmaster') +application = service.Application('buildmaster') # fmt: skip from twisted.python.logfile import LogFile from twisted.python.log import ILogObserver, FileLogObserver -logfile = LogFile.fromFullPath(os.path.join(log_basedir, "master-docker-non-standard.log"), rotateLength=rotateLength, - maxRotatedFiles=maxRotatedFiles) + +logfile = LogFile.fromFullPath( + os.path.join(log_basedir, "master-docker-non-standard.log"), + rotateLength=rotateLength, + maxRotatedFiles=maxRotatedFiles, +) application.setComponent(ILogObserver, FileLogObserver(logfile).emit) m = BuildMaster(basedir, configfile, umask) diff --git a/master-galera/buildbot.tac b/master-galera/buildbot.tac index a9910538..5738e78d 100644 --- a/master-galera/buildbot.tac +++ b/master-galera/buildbot.tac @@ -3,28 +3,33 @@ import os from twisted.application import service from buildbot.master import BuildMaster -basedir = '.' -log_basedir = '/var/log/buildbot/' +basedir = "." +log_basedir = "/var/log/buildbot/" rotateLength = 10000000 maxRotatedFiles = 10 -configfile = 'master.cfg' +configfile = "master.cfg" # Default umask for server umask = None # if this is a relocatable tac file, get the directory containing the TAC -if basedir == '.': +if basedir == ".": import os + basedir = os.path.abspath(os.path.dirname(__file__)) # note: this line is matched against to check that this is a buildmaster # directory; do not edit it. -application = service.Application('buildmaster') +application = service.Application('buildmaster') # fmt: skip from twisted.python.logfile import LogFile from twisted.python.log import ILogObserver, FileLogObserver -logfile = LogFile.fromFullPath(os.path.join(log_basedir, "master-galera.log"), rotateLength=rotateLength, - maxRotatedFiles=maxRotatedFiles) + +logfile = LogFile.fromFullPath( + os.path.join(log_basedir, "master-galera.log"), + rotateLength=rotateLength, + maxRotatedFiles=maxRotatedFiles, +) application.setComponent(ILogObserver, FileLogObserver(logfile).emit) m = BuildMaster(basedir, configfile, umask) diff --git a/master-libvirt/buildbot.tac b/master-libvirt/buildbot.tac index 61f8b522..2b64c006 100644 --- a/master-libvirt/buildbot.tac +++ b/master-libvirt/buildbot.tac @@ -3,28 +3,33 @@ import os from twisted.application import service from buildbot.master import BuildMaster -basedir = '.' -log_basedir = '/var/log/buildbot/' +basedir = "." +log_basedir = "/var/log/buildbot/" rotateLength = 10000000 maxRotatedFiles = 10 -configfile = 'master.cfg' +configfile = "master.cfg" # Default umask for server umask = None # if this is a relocatable tac file, get the directory containing the TAC -if basedir == '.': +if basedir == ".": import os + basedir = os.path.abspath(os.path.dirname(__file__)) # note: this line is matched against to check that this is a buildmaster # directory; do not edit it. -application = service.Application('buildmaster') +application = service.Application('buildmaster') # fmt: skip from twisted.python.logfile import LogFile from twisted.python.log import ILogObserver, FileLogObserver -logfile = LogFile.fromFullPath(os.path.join(log_basedir, "master-libvirt.log"), rotateLength=rotateLength, - maxRotatedFiles=maxRotatedFiles) + +logfile = LogFile.fromFullPath( + os.path.join(log_basedir, "master-libvirt.log"), + rotateLength=rotateLength, + maxRotatedFiles=maxRotatedFiles, +) application.setComponent(ILogObserver, FileLogObserver(logfile).emit) m = BuildMaster(basedir, configfile, umask) diff --git a/master-libvirt/get_ssh_cnx_num.py b/master-libvirt/get_ssh_cnx_num.py index ddae8fb2..cb373d22 100644 --- a/master-libvirt/get_ssh_cnx_num.py +++ b/master-libvirt/get_ssh_cnx_num.py @@ -9,10 +9,7 @@ SSH_CONNECTIONS = 0 for os in os_info: for arch in os_info[os]["arch"]: - if ( - arch not in ["s390x", "x86"] - and "sles" not in os - ): + if arch not in ["s390x", "x86"] and "sles" not in os: SSH_CONNECTIONS += 1 print(SSH_CONNECTIONS) diff --git a/master-nonlatent/buildbot.tac b/master-nonlatent/buildbot.tac index aac9c413..89a96f9f 100644 --- a/master-nonlatent/buildbot.tac +++ b/master-nonlatent/buildbot.tac @@ -3,28 +3,33 @@ import os from twisted.application import service from buildbot.master import BuildMaster -basedir = '.' -log_basedir = '/var/log/buildbot/' +basedir = "." +log_basedir = "/var/log/buildbot/" rotateLength = 10000000 maxRotatedFiles = 10 -configfile = 'master.cfg' +configfile = "master.cfg" # Default umask for server umask = None # if this is a relocatable tac file, get the directory containing the TAC -if basedir == '.': +if basedir == ".": import os + basedir = os.path.abspath(os.path.dirname(__file__)) # note: this line is matched against to check that this is a buildmaster # directory; do not edit it. -application = service.Application('buildmaster') +application = service.Application('buildmaster') # fmt: skip from twisted.python.logfile import LogFile from twisted.python.log import ILogObserver, FileLogObserver -logfile = LogFile.fromFullPath(os.path.join(log_basedir, "master-nonlatent.log"), rotateLength=rotateLength, - maxRotatedFiles=maxRotatedFiles) + +logfile = LogFile.fromFullPath( + os.path.join(log_basedir, "master-nonlatent.log"), + rotateLength=rotateLength, + maxRotatedFiles=maxRotatedFiles, +) application.setComponent(ILogObserver, FileLogObserver(logfile).emit) m = BuildMaster(basedir, configfile, umask) diff --git a/master-protected-branches/buildbot.tac b/master-protected-branches/buildbot.tac index 3070ed0a..deb4e066 100644 --- a/master-protected-branches/buildbot.tac +++ b/master-protected-branches/buildbot.tac @@ -3,28 +3,33 @@ import os from twisted.application import service from buildbot.master import BuildMaster -basedir = '.' -log_basedir = '/var/log/buildbot/' +basedir = "." +log_basedir = "/var/log/buildbot/" rotateLength = 20000000 maxRotatedFiles = 30 -configfile = 'master.cfg' +configfile = "master.cfg" # Default umask for server umask = None # if this is a relocatable tac file, get the directory containing the TAC -if basedir == '.': +if basedir == ".": import os + basedir = os.path.abspath(os.path.dirname(__file__)) # note: this line is matched against to check that this is a buildmaster # directory; do not edit it. -application = service.Application('buildmaster') +application = service.Application('buildmaster') # fmt: skip from twisted.python.logfile import LogFile from twisted.python.log import ILogObserver, FileLogObserver -logfile = LogFile.fromFullPath(os.path.join(log_basedir, "master-protected-branches.log"), rotateLength=rotateLength, - maxRotatedFiles=maxRotatedFiles) + +logfile = LogFile.fromFullPath( + os.path.join(log_basedir, "master-protected-branches.log"), + rotateLength=rotateLength, + maxRotatedFiles=maxRotatedFiles, +) application.setComponent(ILogObserver, FileLogObserver(logfile).emit) m = BuildMaster(basedir, configfile, umask) diff --git a/master-web/buildbot.tac b/master-web/buildbot.tac index 6b419cc9..9d28ce9c 100644 --- a/master-web/buildbot.tac +++ b/master-web/buildbot.tac @@ -3,28 +3,33 @@ import os from twisted.application import service from buildbot.master import BuildMaster -basedir = '.' -log_basedir = '/var/log/buildbot/' +basedir = "." +log_basedir = "/var/log/buildbot/" rotateLength = 10000000 maxRotatedFiles = 10 -configfile = 'master.cfg' +configfile = "master.cfg" # Default umask for server umask = None # if this is a relocatable tac file, get the directory containing the TAC -if basedir == '.': +if basedir == ".": import os + basedir = os.path.abspath(os.path.dirname(__file__)) # note: this line is matched against to check that this is a buildmaster # directory; do not edit it. -application = service.Application('buildmaster') +application = service.Application('buildmaster') # fmt: skip from twisted.python.logfile import LogFile from twisted.python.log import ILogObserver, FileLogObserver -logfile = LogFile.fromFullPath(os.path.join(log_basedir, "master-web.log"), rotateLength=rotateLength, - maxRotatedFiles=maxRotatedFiles) + +logfile = LogFile.fromFullPath( + os.path.join(log_basedir, "master-web.log"), + rotateLength=rotateLength, + maxRotatedFiles=maxRotatedFiles, +) application.setComponent(ILogObserver, FileLogObserver(logfile).emit) m = BuildMaster(basedir, configfile, umask) diff --git a/schedulers_definition.py b/schedulers_definition.py index dc98cf43..2460b314 100644 --- a/schedulers_definition.py +++ b/schedulers_definition.py @@ -1,9 +1,16 @@ from buildbot.plugins import schedulers, util -from constants import (builders_autobake, builders_big, builders_dockerlibrary, - builders_eco, builders_install, builders_upgrade, - builders_wordpress, github_status_builders, - supportedPlatforms) +from constants import ( + builders_autobake, + builders_big, + builders_dockerlibrary, + builders_eco, + builders_install, + builders_upgrade, + builders_wordpress, + github_status_builders, + supportedPlatforms, +) ####### SCHEDULER HELPER FUNCTIONS diff --git a/utils.py b/utils.py index 06cd7e27..21d1ecd6 100644 --- a/utils.py +++ b/utils.py @@ -10,15 +10,23 @@ from buildbot.process.remotecommand import RemoteCommand from buildbot.process.results import FAILURE from buildbot.steps.mtrlogobserver import MTR, MtrLogObserver -from buildbot.steps.shell import (Compile, SetPropertyFromCommand, - ShellCommand, Test) +from buildbot.steps.shell import Compile, SetPropertyFromCommand, ShellCommand, Test from buildbot.steps.source.github import GitHub from pyzabbix import ZabbixAPI from twisted.internet import defer -from constants import (DEVELOPMENT_BRANCH, builders_autobake, builders_big, - builders_eco, builders_galera_mtr, builders_install, - builders_upgrade, releaseBranches, savedPackageBranches, os_info) +from constants import ( + DEVELOPMENT_BRANCH, + builders_autobake, + builders_big, + builders_eco, + builders_galera_mtr, + builders_install, + builders_upgrade, + releaseBranches, + savedPackageBranches, + os_info, +) private_config = {"private": {}} exec(open("/srv/buildbot/master/master-private.cfg").read(), private_config, {})