2
0
mirror of https://github.com/frappe/bench.git synced 2024-09-28 06:49:06 +00:00

perf: Remove requests from the import tree

This commit is contained in:
Aditya Hase 2021-02-20 13:14:56 +05:30
parent 17ef5da5ce
commit cc92584927
No known key found for this signature in database
GPG Key ID: 0A55F0FCA0234972
3 changed files with 16 additions and 5 deletions

View File

@ -13,7 +13,6 @@ import sys
# imports - third party imports
import click
import git
import requests
import semantic_version
from six.moves import reload_module
@ -91,6 +90,8 @@ def remove_from_excluded_apps_txt(app, bench_path='.'):
return write_excluded_apps_txt(apps, bench_path=bench_path)
def get_app(git_url, branch=None, bench_path='.', skip_assets=False, verbose=False, restart_bench=True, overwrite=False):
import requests
if not os.path.exists(git_url):
if not is_git_url(git_url):
orgs = ['frappe', 'erpnext']
@ -433,6 +434,8 @@ def install_apps_from_path(path, bench_path='.'):
get_app(app['url'], branch=app.get('branch'), bench_path=bench_path, skip_assets=True)
def get_apps_json(path):
import requests
if path.startswith('http'):
r = requests.get(path)
return r.json()

View File

@ -4,11 +4,8 @@ import os
import sys
import semantic_version
import git
import requests
import getpass
import re
from requests.auth import HTTPBasicAuth
import requests.exceptions
from time import sleep
from .config.common_site_config import get_config
import click
@ -47,6 +44,9 @@ def release(bench_path, app, bump_type, from_branch, to_branch,
repo_name=repo_name, remote=remote, frontport=frontport)
def validate(bench_path, config):
import requests
from requests.auth import HTTPBasicAuth
global github_username, github_password
github_username = config.get('github_username')
@ -306,6 +306,9 @@ def push_release(repo_path, from_branch, to_branch, remote='upstream'):
def create_github_release(repo_path, tag_name, message, remote='upstream', owner='frappe', repo_name=None,
gh_username=None, gh_password=None, prerelease=False):
import requests
import requests.exceptions
from requests.auth import HTTPBasicAuth
print('creating release on github')

View File

@ -24,7 +24,6 @@ from distutils.spawn import find_executable
# imports - third party imports
import click
from crontab import CronTab
import requests
from semantic_version import Version
from six import iteritems
from six.moves.urllib.parse import urlparse
@ -93,6 +92,8 @@ def safe_decode(string, encoding = 'utf-8'):
def check_latest_version():
import requests
try:
pypi_request = requests.get("https://pypi.org/pypi/frappe-bench/json")
except Exception:
@ -815,6 +816,8 @@ sudo supervisorctl reload
def update_translations_p(args):
import requests
try:
update_translations(*args)
except requests.exceptions.HTTPError:
@ -846,6 +849,8 @@ def get_langs():
def update_translations(app, lang):
import requests
translations_dir = os.path.join('apps', app, app, 'translations')
csv_file = os.path.join(translations_dir, lang + '.csv')
url = "https://translate.erpnext.com/files/{}-{}.csv".format(app, lang)