perf: Remove requests from import tree
This commit is contained in:
parent
637aa059b9
commit
9614886fa5
3 changed files with 8 additions and 3 deletions
|
|
@ -15,7 +15,6 @@ import frappe
|
|||
from frappe.utils.minify import JavascriptMinify
|
||||
|
||||
import click
|
||||
from requests import get
|
||||
from six import iteritems, text_type
|
||||
from six.moves.urllib.parse import urlparse
|
||||
|
||||
|
|
@ -26,6 +25,8 @@ sites_path = os.path.abspath(os.getcwd())
|
|||
|
||||
|
||||
def download_file(url, prefix):
|
||||
from requests import get
|
||||
|
||||
filename = urlparse(url).path.split("/")[-1]
|
||||
local_filename = os.path.join(prefix, filename)
|
||||
with get(url, stream=True, allow_redirects=True) as r:
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
from __future__ import unicode_literals, print_function
|
||||
from werkzeug.test import Client
|
||||
import os, re, sys, json, hashlib, requests, traceback
|
||||
import os, re, sys, json, hashlib, traceback
|
||||
import functools
|
||||
from .html_utils import sanitize_html
|
||||
import frappe
|
||||
|
|
@ -176,6 +176,8 @@ def random_string(length):
|
|||
|
||||
def has_gravatar(email):
|
||||
'''Returns gravatar url if user has set an avatar at gravatar.com'''
|
||||
import requests
|
||||
|
||||
if (frappe.flags.in_import
|
||||
or frappe.flags.in_install
|
||||
or frappe.flags.in_test):
|
||||
|
|
@ -463,6 +465,7 @@ def get_sites(sites_path=None):
|
|||
return sorted(sites)
|
||||
|
||||
def get_request_session(max_retries=3):
|
||||
import requests
|
||||
from urllib3.util import Retry
|
||||
session = requests.Session()
|
||||
session.mount("http://", requests.adapters.HTTPAdapter(max_retries=Retry(total=5, status_forcelist=[500])))
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
# MIT License. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import requests
|
||||
import frappe
|
||||
from frappe import _
|
||||
from frappe.utils import get_request_site_address, encode
|
||||
|
|
@ -77,6 +76,8 @@ class WebsiteSettings(Document):
|
|||
frappe.clear_cache()
|
||||
|
||||
def get_access_token(self):
|
||||
import requests
|
||||
|
||||
google_settings = frappe.get_doc("Google Settings")
|
||||
|
||||
if not google_settings.enable:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue