def ready(self): autoreload_started.connect(watchDjangoSettings) # Validate all required modules are activated missing = [] required_apps = [ "django.contrib.auth", "django.contrib.contenttypes", "django.contrib.messages", "django.contrib.staticfiles", "bootstrap3", "freppledb.boot", "freppledb.input", "freppledb.output", "freppledb.execute", "freppledb.common", "django_filters", "rest_framework", "django_admin_bootstrapped", "django.contrib.admin", ] for app in required_apps: if app not in settings.INSTALLED_APPS: missing.append(app) if missing: raise ImproperlyConfigured( "Missing required apps in INSTALLED_APPS: %s" % ", ".join(missing))
def add_autoreload_extra_files(extra_files: Iterable[Union[str, Path]]): if not settings.DEBUG: return try: from werkzeug.serving import is_running_from_reloader except ImportError: is_running_from_reloader = None if is_running_from_reloader and is_running_from_reloader(): # we're running from the main runserver_plus process if not hasattr(settings, 'RUNSERVER_PLUS_EXTRA_FILES'): settings.RUNSERVER_PLUS_EXTRA_FILES = [] settings.RUNSERVER_PLUS_EXTRA_FILES += extra_files else: # either: # - we're using the runserver (django) server # - we're running from a child runserver_plus thread. If this is the case # then the django autoreload signal will do nothing: working as intended def add_watched_files(sender: StatReloader, **kwargs): sender.extra_files.update([Path(p) for p in extra_files]) autoreload_started.connect(add_watched_files)
def ready(self): check = check_url_trailing_slash(expect_trailing_slash=True, ignore_attrs={"_regex": ["^.*"]}) register(check=check, tags=Tags.urls) # register(check=check_git_hooks) register(check=check_admins) if settings.DEBUG: from django.utils.autoreload import autoreload_started autoreload_started.connect(add_watchers)
def __getattr__(self, real_name): from django.conf import settings if settings.USE_I18N: from django.utils.translation import trans_real as trans from django.utils.translation.reloader import watch_for_translation_changes, translation_file_changed autoreload_started.connect(watch_for_translation_changes, dispatch_uid='translation_file_changed') file_changed.connect(translation_file_changed, dispatch_uid='translation_file_changed') else: from django.utils.translation import trans_null as trans setattr(self, real_name, getattr(trans, real_name)) return getattr(trans, real_name)
def __getattr__(self, real_name): from django.conf import settings if settings.USE_I18N: from django.utils.translation import trans_real as trans from django.utils.translation.reloader import watch_for_translation_changes, translation_file_changed autoreload_started.connect(watch_for_translation_changes, dispatch_uid='translation_file_changed') file_changed.connect(translation_file_changed, dispatch_uid='translation_file_changed') else: from django.utils.translation import trans_null as trans setattr(self, real_name, getattr(trans, real_name)) return getattr(trans, real_name)
def ready(self): loaded_files = init_oso() if OSO_RELOAD_SERVER: autoreload_started.connect(functools.partial(watch_files, files=loaded_files), weak=False)
def ready(self): if settings.DEBUG: sft_compile() autoreload_started.connect(watch_sft)
def ready(self): autoreload_started.connect(schema_watchdog)
def _django_setup(): os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'rssant.settings') if not apps.ready and not settings.configured: django.setup() autoreload_started.connect(_watch_changelog)
def ready(self): autoreload_started.connect(reload_graphql_shemas)
def ready(self): autoreload_started.connect(watch_extra_files)
def y(self, path: str, default=None, sep='.') -> Any: """Access attribute by using yaml path""" # Walk sub_dicts before parsing path root = self.raw for sub in self.__sub_dicts: root = root.get(sub, None) # Walk each component of the path for comp in path.split(sep): if comp in root: root = root.get(comp) else: return default return root def y_bool(self, path: str, default=False) -> bool: """Wrapper for y that converts value into boolean""" return str(self.y(path, default)).lower() == 'true' CONFIG = ConfigLoader() # pylint: disable=unused-argument def signal_handler(sender, **_): """Add all loaded config files to autoreload watcher""" for path in CONFIG.loaded_file: sender.watch_file(path) autoreload_started.connect(signal_handler)
def ready(self): # perform one-time startup logic if 'runserver' in sys.argv: # pragma: no cover # very likely started with ./manage.py runserver # monitor for .dtl file changes autoreload_started.connect(my_watchdog_dtl)
def ready(self): autoreload_started.connect(watchDjangoSettings)
def ready(self): autoreload_started.connect(jsonnet_watchdog) try: import chemreg.openapi.signals # noqa F401 except ImportError: pass
from django.apps import AppConfig from django.utils.autoreload import autoreload_started from pathlib import Path def watch_extra_files(sender, *args, **kwargs): watch = sender.extra_files.add # List of file paths to watch path_elm = Path("c:/Users", "qbernard", "PycharmProjects", "drunkpoker", "drunkpoker", "main", "elm.js") path_index = Path("c:/Users", "qbernard", "PycharmProjects", "drunkpoker", "drunkpoker", "main", "index.html") print(path_elm.exists()) watch_list = [path_elm, path_index] for file in watch_list: watch(file) autoreload_started.connect(watch_extra_files) class MainConfig(AppConfig): name = 'main'