mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2026-09-03 20:52:57 -05:00
Improve the debugger's default page layout, and prevent attempts to continue debugging after the user has stopped. Fixes #2512, Fixes #2511
This commit is contained in:
committed by
Dave Page
parent
1977a5fcda
commit
2d5e55964a
@@ -524,7 +524,7 @@ def initialize_target(debug_type, sid, did, scid, func_id, tri_id=None):
|
||||
'newBrowserTab': new_browser_tab})
|
||||
|
||||
|
||||
@blueprint.route('/close/<int:trans_id>', methods=["GET"])
|
||||
@blueprint.route('/close/<int:trans_id>', methods=["DELETE"])
|
||||
def close(trans_id):
|
||||
"""
|
||||
close(trans_id)
|
||||
@@ -849,10 +849,16 @@ def execute_debugger_query(trans_id, query_type):
|
||||
template_path = 'debugger/sql/v2'
|
||||
|
||||
if conn.connected():
|
||||
sql = render_template("/".join([template_path, query_type + ".sql"]), session_id=obj['session_id'])
|
||||
# As the query type is continue or step_into or step_over then we may get result after some time so poll the
|
||||
# result. We need to update the frame id variable when user move the next step for debugging.
|
||||
if query_type == 'continue' or query_type == 'step_into' or query_type == 'step_over':
|
||||
sql = render_template(
|
||||
"/".join([template_path, query_type + ".sql"]),
|
||||
session_id=obj['session_id']
|
||||
)
|
||||
# As the query type is continue or step_into or step_over then we
|
||||
# may get result after some time so poll the result.
|
||||
# We need to update the frame id variable when user move the next
|
||||
# step for debugging.
|
||||
if query_type == 'continue' or query_type == 'step_into' or \
|
||||
query_type == 'step_over':
|
||||
# We should set the frame_id to 0 when execution starts.
|
||||
if obj['frame_id'] != 0:
|
||||
session_obj = debugger_data[str(trans_id)]
|
||||
@@ -860,29 +866,30 @@ def execute_debugger_query(trans_id, query_type):
|
||||
update_session_debugger_transaction(trans_id, session_obj)
|
||||
|
||||
status, result = conn.execute_async(sql)
|
||||
return make_json_response(data={'status': status, 'result': result})
|
||||
return make_json_response(
|
||||
data={'status': status, 'result': result}
|
||||
)
|
||||
elif query_type == 'abort_target':
|
||||
status, result = conn.execute_dict(sql)
|
||||
|
||||
manager.release(did=obj['database_id'], conn_id=obj['conn_id'])
|
||||
|
||||
# Delete the existing debugger data in session variable
|
||||
del session['debuggerData'][str(trans_id)]
|
||||
del session['functionData'][str(trans_id)]
|
||||
|
||||
if not status:
|
||||
return internal_server_error(errormsg=result)
|
||||
else:
|
||||
return make_json_response(info=gettext('Target Aborted.'), data={'status': status, 'result': result})
|
||||
return make_json_response(
|
||||
info=gettext('Debugging aborted successfully.'),
|
||||
data={'status': 'Success', 'result': result}
|
||||
)
|
||||
else:
|
||||
status, result = conn.execute_dict(sql)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=result)
|
||||
else:
|
||||
status = False
|
||||
result = gettext('Not connected to server or connection with the server has been closed.')
|
||||
result = gettext('Not connected to server or connection '
|
||||
'with the server has been closed.')
|
||||
return internal_server_error(errormsg=result)
|
||||
|
||||
return make_json_response(data={'status': 'Success', 'result': result['rows']})
|
||||
return make_json_response(
|
||||
data={'status': 'Success', 'result': result['rows']}
|
||||
)
|
||||
|
||||
|
||||
@blueprint.route('/messages/<int:trans_id>/', methods=["GET"])
|
||||
@@ -915,9 +922,12 @@ def messages(trans_id):
|
||||
status, result = conn.poll()
|
||||
notify = conn.messages()
|
||||
if notify:
|
||||
# In notice message we need to find "PLDBGBREAK" string to find the port number to attach.
|
||||
# Notice message returned by the server is "NOTICE: PLDBGBREAK:7".
|
||||
# From the above message we need to find out port number as "7" so below logic will find 7 as port number
|
||||
# In notice message we need to find "PLDBGBREAK" string to find the
|
||||
# port number to attach.
|
||||
# Notice message returned by the server is
|
||||
# "NOTICE: PLDBGBREAK:7".
|
||||
# From the above message we need to find out port number
|
||||
# as "7" so below logic will find 7 as port number
|
||||
# and attach listened to that port number
|
||||
offset = notify[0].find('PLDBGBREAK')
|
||||
str_len = len('PLDBGBREAK')
|
||||
@@ -935,11 +945,18 @@ def messages(trans_id):
|
||||
status = 'Busy'
|
||||
else:
|
||||
status = 'Busy'
|
||||
else:
|
||||
status = 'NotConnected'
|
||||
result = gettext('Not connected to server or connection with the server has been closed.')
|
||||
|
||||
return make_json_response(data={'status': status, 'result': port_number})
|
||||
return make_json_response(
|
||||
data={'status': status, 'result': port_number}
|
||||
)
|
||||
else:
|
||||
result = gettext(
|
||||
'Not connected to server or connection with the '
|
||||
'server has been closed.'
|
||||
)
|
||||
return internal_server_error(errormsg=str(result))
|
||||
|
||||
|
||||
|
||||
|
||||
@blueprint.route('/start_execution/<int:trans_id>/<int:port_num>', methods=['GET'])
|
||||
@@ -1422,7 +1439,10 @@ def poll_end_execution_result(trans_id):
|
||||
if str(trans_id) not in debugger_data:
|
||||
return make_json_response(
|
||||
data={'status': 'NotConnected',
|
||||
'result': gettext('Not connected to server or connection with the server has been closed.')}
|
||||
'result': gettext(
|
||||
'Not connected to server or connection with the '
|
||||
'server has been closed.')
|
||||
}
|
||||
)
|
||||
obj = debugger_data[str(trans_id)]
|
||||
|
||||
@@ -1447,18 +1467,23 @@ def poll_end_execution_result(trans_id):
|
||||
else:
|
||||
statusmsg = additional_msgs
|
||||
|
||||
return make_json_response(success=1, info=gettext("Execution Completed."),
|
||||
data={'status': status, 'status_message': statusmsg})
|
||||
return make_json_response(
|
||||
success=1, info=gettext("Execution Completed."),
|
||||
data={'status': status, 'status_message': statusmsg}
|
||||
)
|
||||
if result:
|
||||
if 'ERROR' in result:
|
||||
status = 'ERROR'
|
||||
return make_json_response(info=gettext("Execution completed with error"),
|
||||
data={'status': status, 'status_message': result})
|
||||
return make_json_response(
|
||||
info=gettext("Execution completed with error"),
|
||||
data={'status': status, 'status_message': result}
|
||||
)
|
||||
else:
|
||||
status = 'Success'
|
||||
additional_msgs = conn.messages()
|
||||
if len(additional_msgs) > 0:
|
||||
additional_msgs = [msg.strip("\n") for msg in additional_msgs]
|
||||
additional_msgs = [msg.strip("\n")
|
||||
for msg in additional_msgs]
|
||||
additional_msgs = "\n".join(additional_msgs)
|
||||
if statusmsg:
|
||||
statusmsg = additional_msgs + "\n" + statusmsg
|
||||
@@ -1467,9 +1492,11 @@ def poll_end_execution_result(trans_id):
|
||||
|
||||
columns, result = convert_data_to_dict(conn, result)
|
||||
|
||||
return make_json_response(success=1, info=gettext("Execution Completed."),
|
||||
data={'status': status, 'result': result,
|
||||
'col_info': columns, 'status_message': statusmsg})
|
||||
return make_json_response(
|
||||
success=1, info=gettext("Execution Completed."),
|
||||
data={'status': status, 'result': result,
|
||||
'col_info': columns, 'status_message': statusmsg}
|
||||
)
|
||||
else:
|
||||
status = 'Busy'
|
||||
additional_msgs = conn.messages()
|
||||
@@ -1485,7 +1512,8 @@ def poll_end_execution_result(trans_id):
|
||||
})
|
||||
else:
|
||||
status = 'NotConnected'
|
||||
result = gettext('Not connected to server or connection with the server has been closed.')
|
||||
result = gettext('Not connected to server or connection with the '
|
||||
'server has been closed.')
|
||||
|
||||
return make_json_response(data={'status': status, 'result': result})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user