misc: remove support for loading extra modules (#73957)

This commit is contained in:
Frédéric Péters 2023-01-29 13:56:52 +01:00 committed by Gitea
parent fa08a8f7b1
commit 13cd2b6562
7 changed files with 0 additions and 53 deletions

1
debian/settings.py vendored
View File

@ -54,4 +54,3 @@ TIME_ZONE = 'Europe/Paris'
# SESSION_COOKIE_SECURE = True
WCS_LEGACY_CONFIG_FILE = '/etc/wcs/wcs.cfg'
WCS_EXTRA_MODULES = []

View File

@ -92,11 +92,6 @@ class CmdCheckHobos(Command):
from .. import publisher
self.base_options = base_options
if sub_options.extra:
if not self.config.has_section('extra'):
self.config.add_section('extra')
for i, extra in enumerate(sub_options.extra):
self.config.set('extra', 'cmd_line_extra_%d' % i, extra)
publisher.WcsPublisher.configure(self.config)
pub = publisher.WcsPublisher.create_publisher(register_tld_names=False)

View File

@ -33,11 +33,6 @@ class CmdHoboNotify(Command):
def execute(self, base_options, sub_options, args):
self.base_options = base_options
if sub_options.extra:
if not self.config.has_section('extra'):
self.config.add_section('extra')
for i, extra in enumerate(sub_options.extra):
self.config.set('extra', 'cmd_line_extra_%d' % i, extra)
notification = self.load_notification(args)
if not self.check_valid_notification(notification):

View File

@ -120,9 +120,6 @@ class WcsPublisher(QommonPublisher):
@classmethod
def configure(cls, config):
if config.has_section('extra'):
for dummy, directory in config.items('extra'):
cls.register_extra_dir(directory)
if config.has_option("main", "app_dir"):
cls.APP_DIR = config.get("main", "app_dir")
if config.has_option("main", "data_dir"):
@ -593,4 +590,3 @@ class WcsPublisher(QommonPublisher):
set_publisher_class(WcsPublisher)
WcsPublisher.register_extra_dir(os.path.join(os.path.dirname(__file__), 'extra'))

View File

@ -173,11 +173,6 @@ class AppConfig(django.apps.AppConfig):
config = configparser.ConfigParser()
if settings.WCS_LEGACY_CONFIG_FILE:
config.read(settings.WCS_LEGACY_CONFIG_FILE)
if hasattr(settings, 'WCS_EXTRA_MODULES') and settings.WCS_EXTRA_MODULES:
if not config.has_section('extra'):
config.add_section('extra')
for i, extra in enumerate(settings.WCS_EXTRA_MODULES):
config.set('extra', 'cmd_line_extra_%d' % i, extra)
threading.Thread = TenantAwareThread
threading._DummyThread = _DummyThread

View File

@ -40,7 +40,6 @@ class Command:
options = options or []
self.config = configparser.ConfigParser()
self.options = options + [
make_option('--extra', metavar='DIR', action='append', dest='extra', default=[]),
make_option('--app-dir', metavar='DIR', action='store', dest='app_dir', default=None),
make_option('--data-dir', metavar='DIR', action='store', dest='data_dir', default=None),
]
@ -63,11 +62,6 @@ class Command:
self.config.set("main", "app_dir", sub_options.app_dir)
if sub_options.data_dir:
self.config.set("main", "data_dir", sub_options.data_dir)
if sub_options.extra:
if not self.config.has_section('extra'):
self.config.add_section('extra')
for i, extra in enumerate(sub_options.extra):
self.config.set("extra", "cmd_line_extra_%d" % i, extra)
return self.execute(base_options, sub_options, args)
def parse_args(self, args):

View File

@ -20,7 +20,6 @@ import collections
import configparser
import datetime
import hashlib
import importlib
import inspect
import io
import json
@ -709,7 +708,6 @@ class QommonPublisher(Publisher):
if cls._initialized:
return
cls._initialized = True
cls.load_extra_dirs()
@classmethod
def create_publisher(cls, **kwargs):
@ -735,31 +733,6 @@ class QommonPublisher(Publisher):
self._app_logger = None
self.init_publisher_substitutions(self.get_request())
extra_dirs = None
@classmethod
def register_extra_dir(cls, dir):
if not cls.extra_dirs:
cls.extra_dirs = []
cls.extra_dirs.append(dir)
@classmethod
def load_extra_dirs(cls):
for extra_dir in cls.extra_dirs or []:
if not os.path.exists(extra_dir):
continue
sys.path.append(extra_dir)
for filename in os.listdir(extra_dir):
if not filename.endswith('.py'):
continue
modulename = filename[:-3]
spec = importlib.util.spec_from_file_location(modulename, os.path.join(extra_dir, filename))
module = importlib.util.module_from_spec(spec)
try:
spec.loader.exec_module(module)
except Exception as e:
print('failed to load extra module: %s (%s)' % (modulename, e), file=sys.stderr)
translation_domains = None
@classmethod