Skip to content

Commit

Permalink
feat: update v15 dec 19 and 20
Browse files Browse the repository at this point in the history
  • Loading branch information
sibikumarkuppusamy committed Dec 26, 2024
1 parent b992704 commit 2bb52ef
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion frappe/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def symlink(target, link_name, overwrite=False):
if os.path.isdir(link_name):
raise IsADirectoryError(f"Cannot symlink over existing directory: '{link_name}'")
try:
os.replace(temp_link_name, link_name)
shutil.move(temp_link_name, link_name)
except AttributeError:
os.renames(temp_link_name, link_name)
except Exception:
Expand Down
10 changes: 9 additions & 1 deletion frappe/core/doctype/prepared_report/prepared_report.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"column_break_4",
"queued_at",
"report_end_time",
"peak_memory_usage",
"section_break_7",
"error_message",
"filters_sb",
Expand Down Expand Up @@ -101,11 +102,18 @@
"is_virtual": 1,
"label": "Queued At",
"read_only": 1
},
{
"fieldname": "peak_memory_usage",
"fieldtype": "Int",
"label": "Peak Memory Usage",
"print_hide": 1,
"read_only": 1
}
],
"in_create": 1,
"links": [],
"modified": "2024-03-07 12:01:58.209879",
"modified": "2024-12-20 10:18:19.174608",
"modified_by": "Administrator",
"module": "Core",
"name": "Prepared Report",
Expand Down
4 changes: 4 additions & 0 deletions frappe/core/doctype/prepared_report/prepared_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# License: MIT. See LICENSE
import gzip
import json
import resource
from contextlib import suppress
from typing import Any

Expand Down Expand Up @@ -33,6 +34,7 @@ class PreparedReport(Document):
error_message: DF.Text | None
filters: DF.SmallText | None
job_id: DF.Data | None
peak_memory_usage: DF.Int
queued_at: DF.Datetime | None
queued_by: DF.Data | None
report_end_time: DF.Datetime | None
Expand Down Expand Up @@ -119,6 +121,8 @@ def generate_report(prepared_report):
_save_error(instance, error=frappe.get_traceback(with_context=True))

instance.report_end_time = frappe.utils.now()
instance.peak_memory_usage = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
add_data_to_monitor(peak_memory_usage=instance.peak_memory_usage)
instance.save(ignore_permissions=True)

frappe.publish_realtime(
Expand Down
4 changes: 2 additions & 2 deletions frappe/website/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,14 +545,14 @@ def build_response(path, data, http_status_code, headers: dict | None = None):
response = Response()
response.data = set_content_type(response, data, path)
response.status_code = http_status_code
response.headers["X-Page-Name"] = cstr(path.encode("ascii", errors="xmlcharrefreplace"))
response.headers["X-Page-Name"] = cstr(cstr(path).encode("ascii", errors="xmlcharrefreplace"))
response.headers["X-From-Cache"] = frappe.local.response.from_cache or False

add_preload_for_bundled_assets(response)

if headers:
for key, val in headers.items():
response.headers[key] = cstr(val.encode("ascii", errors="xmlcharrefreplace"))
response.headers[key] = cstr(cstr(val).encode("ascii", errors="xmlcharrefreplace")

return response

Expand Down

0 comments on commit 2bb52ef

Please sign in to comment.