Skip to content

Commit

Permalink
Merge pull request #21873 from blaggacao/dont-exceed-python-module-bo…
Browse files Browse the repository at this point in the history
…undary
  • Loading branch information
barredterra committed Aug 21, 2023
2 parents 8f1c083 + 8dabd2b commit 8f7a4f6
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
8 changes: 8 additions & 0 deletions frappe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1414,6 +1414,14 @@ def get_app_path(app_name, *joins):
return get_pymodule_path(app_name, *joins)


def get_app_source_path(app_name, *joins):
"""Return source path of given app.
:param app: App name.
:param *joins: Join additional path elements using `os.path.join`."""
return get_app_path(app_name, "..", *joins)


def get_site_path(*joins):
"""Return path of current site.
Expand Down
4 changes: 2 additions & 2 deletions frappe/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def bundle(
command += " --save-metafiles"

check_node_executable()
frappe_app_path = frappe.get_app_path("frappe", "..")
frappe_app_path = frappe.get_app_source_path("frappe")
frappe.commands.popen(command, cwd=frappe_app_path, env=get_node_env(), raise_err=True)


Expand All @@ -271,7 +271,7 @@ def watch(apps=None):
command += " --live-reload"

check_node_executable()
frappe_app_path = frappe.get_app_path("frappe", "..")
frappe_app_path = frappe.get_app_source_path("frappe")
frappe.commands.popen(command, cwd=frappe_app_path, env=get_node_env())


Expand Down
2 changes: 1 addition & 1 deletion frappe/commands/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,7 @@ def _drop_site(
drop_user_and_database(frappe.conf.db_name, db_root_username, db_root_password)

archived_sites_path = archived_sites_path or os.path.join(
frappe.get_app_path("frappe"), "..", "..", "..", "archived", "sites"
frappe.utils.get_bench_path(), "archived", "sites"
)
archived_sites_path = os.path.realpath(archived_sites_path)

Expand Down
4 changes: 2 additions & 2 deletions frappe/commands/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ def run_ui_tests(
):
"Run UI tests"
site = get_site(context)
app_base_path = os.path.abspath(os.path.join(frappe.get_app_path(app), ".."))
app_base_path = frappe.get_app_source_path(app)
site_url = frappe.utils.get_site_url(site)
admin_password = frappe.get_conf(site).admin_password

Expand Down Expand Up @@ -1075,7 +1075,7 @@ def get_version(output):
app_info = frappe._dict()

try:
app_info.commit = Repo(frappe.get_app_path(app, "..")).head.object.hexsha[:7]
app_info.commit = Repo(frappe.get_app_source_path(app)).head.object.hexsha[:7]
except InvalidGitRepositoryError:
app_info.commit = ""

Expand Down
2 changes: 1 addition & 1 deletion frappe/website/doctype/website_theme/website_theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def generate_bootstrap_theme(self):
content = content.replace("\n", "\\n")
command = ["node", "generate_bootstrap_theme.js", output_path, content]

process = Popen(command, cwd=frappe.get_app_path("frappe", ".."), stdout=PIPE, stderr=PIPE)
process = Popen(command, cwd=frappe.get_app_source_path("frappe"), stdout=PIPE, stderr=PIPE)

stderr = process.communicate()[1]

Expand Down

0 comments on commit 8f7a4f6

Please sign in to comment.