Skip to content

Commit

Permalink
perf: Remove requests from the import tree
Browse files Browse the repository at this point in the history
  • Loading branch information
adityahase committed Feb 20, 2021
1 parent 17ef5da commit cc92584
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
5 changes: 4 additions & 1 deletion bench/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# imports - third party imports
import click
import git
import requests
import semantic_version
from six.moves import reload_module

Expand Down Expand Up @@ -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']
Expand Down Expand Up @@ -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()
Expand Down
9 changes: 6 additions & 3 deletions bench/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@
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
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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')

Expand Down
7 changes: 6 additions & 1 deletion bench/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
# 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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -815,6 +816,8 @@ def post_upgrade(from_ver, to_ver, bench_path='.'):


def update_translations_p(args):
import requests

try:
update_translations(*args)
except requests.exceptions.HTTPError:
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit cc92584

Please sign in to comment.