Browse Source

fix: Show deprecation warnings only if DEV_SERVER is set

This will show warnings in bench start commands by default as this
envvar is set.
version-14
Gavin D'souza 4 years ago
parent
commit
8cc6804850
3 changed files with 12 additions and 6 deletions
  1. +9
    -4
      frappe/__init__.py
  2. +2
    -1
      frappe/utils/bench_helper.py
  3. +1
    -1
      frappe/utils/safe_exec.py

+ 9
- 4
frappe/__init__.py View File

@@ -10,9 +10,16 @@ be used to build database driven apps.

Read the documentation: https://frappeframework.com/docs
"""
import os, warnings

_dev_server = os.environ.get('DEV_SERVER', False)

if _dev_server:
warnings.simplefilter('always', DeprecationWarning)
warnings.simplefilter('always', PendingDeprecationWarning)

from werkzeug.local import Local, release_local
import os, sys, importlib, inspect, json, warnings
import sys, importlib, inspect, json
import typing
from past.builtins import cmp
import click
@@ -31,8 +38,6 @@ __title__ = "Frappe Framework"

local = Local()
controllers = {}
warnings.simplefilter('always', DeprecationWarning)
warnings.simplefilter('always', PendingDeprecationWarning)

class _dict(dict):
"""dict like object that exposes keys as attributes"""
@@ -197,7 +202,7 @@ def init(site, sites_path=None, new_site=False):
local.meta_cache = {}
local.form_dict = _dict()
local.session = _dict()
local.dev_server = os.environ.get('DEV_SERVER', False)
local.dev_server = _dev_server

setup_module_map()



+ 2
- 1
frappe/utils/bench_helper.py View File

@@ -99,5 +99,6 @@ def get_apps():
return frappe.get_all_apps(with_internal_apps=False, sites_path='.')

if __name__ == "__main__":
warnings.simplefilter('ignore')
if not frappe._dev_server:
warnings.simplefilter('ignore')
main()

+ 1
- 1
frappe/utils/safe_exec.py View File

@@ -119,7 +119,7 @@ def get_safe_globals():
scrub=scrub,
guess_mimetype=mimetypes.guess_type,
html2text=html2text,
dev_server=1 if os.environ.get('DEV_SERVER', False) else 0,
dev_server=1 if frappe._dev_server else 0,
run_script=run_script
)



Loading…
Cancel
Save