Merge branch 'develop' of https://github.com/frappe/frappe into rebrand-ui

This commit is contained in:
Suraj Shetty 2020-05-11 08:57:36 +05:30
commit 02954c3cd7
8 changed files with 24 additions and 47 deletions

View file

@ -443,7 +443,7 @@ def console(context):
for app in all_apps:
locals()[app] = __import__(app)
print("Apps in this namespace:\n{}".format(", ".join(all_apps)))
IPython.embed(display_banner="", header="")
IPython.embed(display_banner="", header="", colors="neutral")
@click.command('run-tests')

View file

@ -299,7 +299,6 @@ def export_query():
_("You can try changing the filters of your report."))
return
data.columns = [col for col in data.columns if isinstance(col, dict) and not col.get('hidden')]
columns = get_columns_dict(data.columns)
from frappe.utils.xlsxutils import make_xlsx
@ -316,7 +315,8 @@ def build_xlsx_data(columns, data, visible_idx, include_indentation):
# add column headings
for idx in range(len(data.columns)):
result[0].append(columns[idx]["label"])
if not columns[idx].get("hidden"):
result[0].append(columns[idx]["label"])
# build table from result
for i, row in enumerate(data.result):

View file

@ -10,7 +10,7 @@ from frappe.utils import split_emails, get_backups_path
def send_email(success, service_name, doctype, email_field, error_status=None):
recipients = get_recipients(service_name, email_field)
recipients = get_recipients(doctype, email_field)
if not recipients:
frappe.log_error("No Email Recipient found for {0}".format(service_name),
"{0}: Failed to send backup status email".format(service_name))
@ -36,11 +36,11 @@ def send_email(success, service_name, doctype, email_field, error_status=None):
frappe.sendmail(recipients=recipients, subject=subject, message=message)
def get_recipients(service_name, email_field):
def get_recipients(doctype, email_field):
if not frappe.db:
frappe.connect()
return split_emails(frappe.db.get_value(service_name, None, email_field))
return split_emails(frappe.db.get_value(doctype, None, email_field))
def get_latest_backup_file(with_files=False):

View file

@ -452,6 +452,7 @@ class Meta(Document):
for link in self.links:
link.added = False
for group in data.transactions:
group = frappe._dict(group)
# group found
if link.group and group.label == link.group:
if link.link_doctype not in group.get('items'):
@ -460,7 +461,7 @@ class Meta(Document):
if not link.added:
# group not found, make a new group
data.transactions.append(frappe._dict(
data.transactions.append(dict(
label = link.group,
items = [link.link_doctype]
))

View file

@ -126,27 +126,9 @@
</thead>
<tbody>
<template v-for="(row, index) in call.stack">
<tr :key="index" @click="showing_traceback = showing_traceback == index ? null : index">
<tr :key="index">
<td v-for="key in ['filename', 'lineno', 'function']" :key="key">{{ row[key] }}</td>
</tr>
<tr v-if="showing_traceback == index">
<td colspan="4" v-html="row.context"></td>
</tr>
<tr v-if="showing_traceback == index">
<td colspan="4">
<table class="table table-striped">
<thead>
<tr><th>Variable</th><th>Value</th></tr>
</thead>
<tbody>
<tr v-for="(variable, index) in Object.entries(JSON.parse(row.locals))" :key="index">
<td>{{ variable[0] }}</td>
<td>{{ variable[1] }}</td>
</tr>
</tbody>
</table>
</td>
</tr>
</template>
</tbody>
</table>
@ -244,7 +226,6 @@ export default {
},
group_duplicates: false,
showing: null,
showing_traceback: null,
request: {
calls: [],
},

View file

@ -9,12 +9,8 @@ import inspect
import json
import re
import time
import traceback
import frappe
import sqlparse
from pygments import highlight
from pygments.lexers import PythonLexer
from pygments.formatters import HtmlFormatter
from frappe import _
@ -30,7 +26,7 @@ def sql(*args, **kwargs):
stack = list(get_current_stack_frames())
if frappe.db.db_type == 'postgres':
if frappe.db.db_type == "postgres":
query = frappe.db._cursor.query
else:
query = frappe.db._cursor._executed
@ -65,9 +61,6 @@ def get_current_stack_frames():
"filename": re.sub(".*/apps/", "", filename),
"lineno": lineno,
"function": function,
"context": "".join(context),
"index": index,
"locals": json.dumps(frame.f_locals, skipkeys=True, default=str)
}
@ -83,7 +76,7 @@ def dump():
frappe.local._recorder.dump()
class Recorder():
class Recorder:
def __init__(self):
self.uuid = frappe.generate_hash(length=10)
self.time = datetime.datetime.now()
@ -105,12 +98,18 @@ class Recorder():
"cmd": self.cmd,
"time": self.time,
"queries": len(self.calls),
"time_queries": float("{:0.3f}".format(sum(call["duration"] for call in self.calls))),
"duration": float("{:0.3f}".format((datetime.datetime.now() - self.time).total_seconds() * 1000)),
"time_queries": float(
"{:0.3f}".format(sum(call["duration"] for call in self.calls))
),
"duration": float(
"{:0.3f}".format((datetime.datetime.now() - self.time).total_seconds() * 1000)
),
"method": self.method,
}
frappe.cache().hset(RECORDER_REQUEST_SPARSE_HASH, self.uuid, request_data)
frappe.publish_realtime(event="recorder-dump-event", message=json.dumps(request_data, default=str))
frappe.publish_realtime(
event="recorder-dump-event", message=json.dumps(request_data, default=str)
)
self.mark_duplicates()
@ -137,6 +136,7 @@ def do_not_record(function):
del frappe.local._recorder
frappe.db.sql = frappe.db._sql
return function(*args, **kwargs)
return wrapper
@ -145,6 +145,7 @@ def administrator_only(function):
if frappe.session.user != "Administrator":
frappe.throw(_("Only Administrator is allowed to use Recorder"))
return function(*args, **kwargs)
return wrapper
@ -175,11 +176,6 @@ def stop(*args, **kwargs):
def get(uuid=None, *args, **kwargs):
if uuid:
result = frappe.cache().hget(RECORDER_REQUEST_HASH, uuid)
lexer = PythonLexer(tabsize=4)
for call in result["calls"]:
for stack in call["stack"]:
formatter = HtmlFormatter(noclasses=True, hl_lines=[stack["index"] + 1])
stack["context"] = highlight(stack["context"], lexer, formatter)
else:
result = list(frappe.cache().hgetall(RECORDER_REQUEST_SPARSE_HASH).values())
return result

View file

@ -65,7 +65,7 @@
frappe.ready_events.push(fn);
}
window.dev_server = {{ dev_server }};
window.socketio_port = {{ frappe.socketio_port }};
window.socketio_port = {{ (frappe.socketio_port or 'null') }};
</script>
</head>
<body frappe-session-status="{{ 'logged-in' if frappe.session.user != 'Guest' else 'logged-out'}}" data-path="{{ path | e }}" {%- if template and template.endswith('.md') %} frappe-content-type="markdown" {% endif -%}>

View file

@ -23,7 +23,7 @@ googlemaps==3.1.1
gunicorn==19.10.0
html2text==2016.9.19
html5lib==1.0.1
ipython==5.9.0
ipython==7.14.0
Jinja2==2.11.1
ldap3==2.7
markdown2==2.3.8
@ -38,7 +38,6 @@ Pillow==6.2.2
premailer==3.6.1
psycopg2-binary==2.8.4
pyasn1==0.4.8
Pygments==2.5.2
PyJWT==1.7.1
PyMySQL==0.9.3
pyOpenSSL==19.1.0