2
0
mirror of https://github.com/frappe/bench.git synced 2025-01-09 16:36:25 +00:00

refactor: Bench.sync => Bench.apps.sync

* Added missing imports
* Fixed broken import paths
This commit is contained in:
Gavin D'souza 2021-11-12 22:13:27 +05:30
parent 71d178dde9
commit 4d1ddc4722
5 changed files with 15 additions and 16 deletions

View File

@ -96,14 +96,14 @@ class Bench(Base, Validator):
app = App(app, branch=branch) app = App(app, branch=branch)
self.apps.append(app) self.apps.append(app)
self.sync() self.apps.sync()
def uninstall(self, app): def uninstall(self, app):
from bench.app import App from bench.app import App
self.validate_app_uninstall(app) self.validate_app_uninstall(app)
self.apps.remove(App(app, bench=self)) self.apps.remove(App(app, bench=self))
self.sync() self.apps.sync()
self.build() self.build()
self.reload() self.reload()
@ -118,17 +118,17 @@ class Bench(Base, Validator):
if conf.get('restart_systemd_on_update'): if conf.get('restart_systemd_on_update'):
restart_systemd_processes(bench_path=self.name) restart_systemd_processes(bench_path=self.name)
def sync(self):
self.apps.initialize_apps()
with open(self.apps_txt, "w") as f:
return f.write("\n".join(self.apps))
class BenchApps(MutableSequence): class BenchApps(MutableSequence):
def __init__(self, bench : Bench): def __init__(self, bench : Bench):
self.bench = bench self.bench = bench
self.initialize_apps() self.initialize_apps()
def sync(self):
self.initialize_apps()
with open(self.bench.apps_txt, "w") as f:
return f.write("\n".join(self.apps))
def initialize_apps(self): def initialize_apps(self):
try: try:
self.apps = [x for x in os.listdir( self.apps = [x for x in os.listdir(

View File

@ -44,5 +44,5 @@ def switch_to_branch(branch, apps, upgrade=False):
@click.command('switch-to-develop') @click.command('switch-to-develop')
def switch_to_develop(upgrade=False): def switch_to_develop(upgrade=False):
"Switch frappe and erpnext to develop branch" "Switch frappe and erpnext to develop branch"
from bench.app import switch_to_develop from bench.utils.app import switch_to_develop
switch_to_develop(apps=['frappe', 'erpnext']) switch_to_develop(apps=['frappe', 'erpnext'])

View File

@ -1,5 +1,6 @@
# imports - standard imports # imports - standard imports
import json import json
import logging
import os import os
import re import re
import subprocess import subprocess
@ -8,12 +9,13 @@ from json.decoder import JSONDecodeError
# imports - third party imports # imports - third party imports
import click import click
import bench
# imports - module imports # imports - module imports
from bench.utils import which, log, exec_cmd, get_bench_name, get_cmd_output
from bench.exceptions import PatchError, ValidationError from bench.exceptions import PatchError, ValidationError
# TODO: Fix this logger = logging.getLogger(bench.PROJECT_NAME)
from bench.utils import *
def get_env_cmd(cmd, bench_path='.'): def get_env_cmd(cmd, bench_path='.'):
@ -74,7 +76,7 @@ def update_python_packages(bench_path='.'):
def update_node_packages(bench_path='.'): def update_node_packages(bench_path='.'):
print('Updating node packages...') print('Updating node packages...')
from bench.app import get_develop_version from bench.utils.app import get_develop_version
from distutils.version import LooseVersion from distutils.version import LooseVersion
v = LooseVersion(get_develop_version('frappe', bench_path = bench_path)) v = LooseVersion(get_develop_version('frappe', bench_path = bench_path))
@ -302,7 +304,7 @@ def update(pull=False, apps=None, patch=False, build=False, requirements=False,
import re import re
from bench import patches from bench import patches
from bench.utils import clear_command_cache, pause_exec, log from bench.utils import clear_command_cache, pause_exec, log
from bench.utils.bench import restart_supervisor_processes, restart_systemd_processes from bench.utils.bench import restart_supervisor_processes, restart_systemd_processes, backup_all_sites
from bench.app import pull_apps from bench.app import pull_apps
from bench.utils.app import is_version_upgrade from bench.utils.app import is_version_upgrade
from bench.config.common_site_config import update_config from bench.config.common_site_config import update_config

View File

@ -57,7 +57,7 @@ def init(path, apps_path=None, no_procfile=False, no_backups=False,
if apps_path: if apps_path:
install_apps_from_path(apps_path, bench_path=path) install_apps_from_path(apps_path, bench_path=path)
bench.sync() bench.apps.sync()
if not skip_assets: if not skip_assets:
build_assets(bench_path=path) build_assets(bench_path=path)

View File

@ -3,9 +3,6 @@ import itertools
import json import json
import os import os
# TODO: Fix this
from bench.utils import *
def update_translations_p(args): def update_translations_p(args):
import requests import requests