diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/__init__.py index 17cc10fdf..f9feb1eeb 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/__init__.py @@ -196,6 +196,7 @@ class IndexConstraintView(PGChildNodeView): - This function will generate dependent list to show it in dependent pane for the selected Index constraint. """ + icon_sign = "icon-%s" node_type = 'index_constraint' @@ -232,7 +233,6 @@ class IndexConstraintView(PGChildNodeView): database connection before running view, it will also attaches manager,conn & template_path properties to self """ - @wraps(f) def wrap(*args, **kwargs): # Here args[0] will hold self & kwargs will hold gid,sid,did @@ -245,8 +245,8 @@ class IndexConstraintView(PGChildNodeView): self.manager.db_info[kwargs['did']]['datlastsysoid'] \ if self.manager.db_info is not None and \ kwargs['did'] in self.manager.db_info else 0 - self.template_path = 'index_constraint/sql/#{0}#'\ - .format(self.manager.version) + self.template_path = 'index_constraint/sql/#{0}#'.\ + format(self.manager.version) # We need parent's name eg table name and schema name schema, table = idxcons_utils.get_parent(self.conn, kwargs['tid']) @@ -263,6 +263,12 @@ class IndexConstraintView(PGChildNodeView): # End transaction if any. self.conn.execute_scalar(SQL) + def get_error_msg(self): + return _("""Could not find the {} in the table.""").format( + _("primary key") if self.constraint_type == "p" + else _("unique key") + ) + @check_precondition def properties(self, gid, sid, did, scid, tid, cid=None): """ @@ -287,10 +293,7 @@ class IndexConstraintView(PGChildNodeView): return res if len(res) == 0: - return gone(_("""Could not find the {} in the table.""").format( - _("primary key") if self.constraint_type == "p" - else _("unique key") - )) + return gone(self.get_error_msg()) result = res if cid: @@ -329,6 +332,7 @@ class IndexConstraintView(PGChildNodeView): except Exception as e: return internal_server_error(errormsg=str(e)) + @check_precondition def get_node_list(self, gid, sid, did, scid, tid, cid=None): """ This function returns all primary keys @@ -345,11 +349,6 @@ class IndexConstraintView(PGChildNodeView): Returns: """ - self.manager = get_driver(PG_DEFAULT_DRIVER).connection_manager(sid) - self.conn = self.manager.connection(did=did) - self.template_path = 'index_constraint/sql/#{0}#'\ - .format(self.manager.version) - # We need parent's name eg table name and schema name schema, table = idxcons_utils.get_parent(self.conn, tid) self.schema = schema @@ -392,16 +391,13 @@ class IndexConstraintView(PGChildNodeView): return internal_server_error(errormsg=rset) if len(rset['rows']) == 0: - return gone(_("""Could not find the {} in the table.""").format( - _("primary key") if self.constraint_type == "p" - else _("unique key") - )) + return gone(self.get_error_msg()) res = self.blueprint.generate_browser_node( rset['rows'][0]['oid'], tid, rset['rows'][0]['name'], - icon="icon-%s" % self.node_type + icon=self.icon_sign % self.node_type ) return make_json_response( data=res, @@ -441,7 +437,7 @@ class IndexConstraintView(PGChildNodeView): row['oid'], tid, row['name'], - icon="icon-%s" % self.node_type + icon=self.icon_sign % self.node_type ) ) return make_json_response( @@ -449,6 +445,7 @@ class IndexConstraintView(PGChildNodeView): status=200 ) + @check_precondition def get_nodes(self, gid, sid, did, scid, tid, cid=None): """ This function returns all event trigger nodes as a list. @@ -464,11 +461,6 @@ class IndexConstraintView(PGChildNodeView): Returns: """ - self.manager = get_driver(PG_DEFAULT_DRIVER).connection_manager(sid) - self.conn = self.manager.connection(did=did) - self.template_path = 'index_constraint/sql/#{0}#'\ - .format(self.manager.version) - # We need parent's name eg table name and schema name schema, table = idxcons_utils.get_parent(self.conn, tid) self.schema = schema @@ -486,7 +478,7 @@ class IndexConstraintView(PGChildNodeView): row['oid'], tid, row['name'], - icon="icon-%s" % self.node_type + icon=self.icon_sign % self.node_type )) return res @@ -627,7 +619,7 @@ class IndexConstraintView(PGChildNodeView): res['rows'][0]['oid'], tid, data['name'], - icon="icon-%s" % self.node_type + icon=self.icon_sign % self.node_type ) ) @@ -688,7 +680,7 @@ class IndexConstraintView(PGChildNodeView): cid, tid, name, - icon="icon-%s" % self.node_type + icon=self.icon_sign % self.node_type ) ) except Exception as e: @@ -848,10 +840,7 @@ class IndexConstraintView(PGChildNodeView): if not status: return internal_server_error(errormsg=res) if len(res['rows']) == 0: - return gone(_("""Could not find the {} in the table.""").format( - _("primary key") if self.constraint_type == "p" - else _("unique key") - )) + return gone(self.get_error_msg()) data = res['rows'][0] data['schema'] = self.schema @@ -940,12 +929,7 @@ class IndexConstraintView(PGChildNodeView): if not status: return internal_server_error(errormsg=res) if len(res['rows']) == 0: - return gone( - _("""Could not find the {} in the table.""").format( - _("primary key") if self.constraint_type == "p" - else _("unique key") - ) - ) + return gone(self.get_error_msg()) result = res['rows'][0] name = result['name'] diff --git a/web/pgadmin/misc/file_manager/__init__.py b/web/pgadmin/misc/file_manager/__init__.py index 89adacf6e..186e8c6de 100644 --- a/web/pgadmin/misc/file_manager/__init__.py +++ b/web/pgadmin/misc/file_manager/__init__.py @@ -33,6 +33,7 @@ from pgadmin.utils.preferences import Preferences # Checks if platform is Windows if _platform == "win32": import ctypes + oldmode = ctypes.c_uint() kernel32 = ctypes.WinDLL('kernel32') SEM_FAILCRITICALERRORS = 1 @@ -178,6 +179,7 @@ class FileManagerModule(PgAdminModule): # Initialise the module blueprint = FileManagerModule(MODULE_NAME, __name__) +mime_type = "application/javascript" @blueprint.route("/", endpoint='index') @@ -195,7 +197,7 @@ def utility(): return Response(response=render_template( "file_manager/js/utility.js", _=gettext), status=200, - mimetype="application/javascript") + mimetype=mime_type) @blueprint.route("/file_manager.js") @@ -205,7 +207,7 @@ def file_manager_js(): return Response(response=render_template( "file_manager/js/file_manager.js", _=gettext), status=200, - mimetype="application/javascript") + mimetype=mime_type) @blueprint.route("/en.json") @@ -224,7 +226,7 @@ def file_manager_config_js(): return Response(response=render_template( "file_manager/js/file_manager_config.js", _=gettext), status=200, - mimetype="application/javascript") + mimetype=mime_type) @blueprint.route("//file_manager_config.json") @@ -312,6 +314,8 @@ def save_show_hidden_file_option(trans_id): class Filemanager(object): """FileManager Class.""" + error_msg_label = u"Error: {0}" + not_allowed_error_label = 'Not allowed' # Stores list of dict for filename & its encoding loaded_file_encoding_list = [] @@ -340,7 +344,6 @@ class Filemanager(object): capabilities: Allow/Disallow user to perform selection, rename, delete etc. """ - # Define configs for dialog types # select file, select folder, create mode Filemanager.suspend_windows_warning() @@ -558,7 +561,7 @@ class Filemanager(object): Filemanager.check_access_permission(in_dir, path) except Exception as e: Filemanager.resume_windows_warning() - err_msg = gettext(u"Error: {0}").format(e) + err_msg = gettext(Filemanager.error_msg_label).format(e) files = { 'Code': 0, 'Error': err_msg @@ -566,7 +569,7 @@ class Filemanager(object): return files files = {} - if (_platform == "win32" and (path == '/' or path == '\\'))\ + if (_platform == "win32" and (path == '/' or path == '\\')) \ and in_dir is None: drives = Filemanager._get_drives() for drive in drives: @@ -642,7 +645,7 @@ class Filemanager(object): if file_type is not None and file_type != "*" and \ (folders_only or len(supported_types) > 0 and file_extension not in supported_types or - file_type != file_extension): + file_type != file_extension): continue # create a list of files and folders @@ -661,9 +664,10 @@ class Filemanager(object): Filemanager.resume_windows_warning() if (hasattr(e, 'strerror') and e.strerror == gettext('Permission denied')): - err_msg = gettext(u"Error: {0}").format(e.strerror) + err_msg = gettext(Filemanager.error_msg_label).\ + format(e.strerror) else: - err_msg = gettext(u"Error: {0}").format(e) + err_msg = gettext(Filemanager.error_msg_label).format(e) files = { 'Code': 0, 'Error': err_msg @@ -742,37 +746,11 @@ class Filemanager(object): about the given file. """ path = unquote(path) - if hasattr(str, 'decode'): - path = unquote(path).encode('utf-8').decode('utf-8') - if self.dir is None: - self.dir = "" - orig_path = u"{0}{1}".format(self.dir, path) - - try: - Filemanager.check_access_permission(self.dir, path) - except Exception as e: - thefile = { - 'Filename': split_path(path)[-1], - 'FileType': '', - 'Path': path, - 'Error': gettext(u"Error: {0}").format(e), - 'Code': 0, - 'Info': '', - 'Properties': { - 'Date Created': '', - 'Date Modified': '', - 'Width': '', - 'Height': '', - 'Size': '' - } - } - return thefile - user_dir = path thefile = { - 'Filename': split_path(orig_path)[-1], + 'Filename': '', 'FileType': '', - 'Path': user_dir, + 'Path': '', 'Error': '', 'Code': 1, 'Info': '', @@ -784,6 +762,26 @@ class Filemanager(object): 'Size': '' } } + if hasattr(str, 'decode'): + path = unquote(path).encode('utf-8').decode('utf-8') + if self.dir is None: + self.dir = "" + orig_path = u"{0}{1}".format(self.dir, path) + + try: + Filemanager.check_access_permission(self.dir, path) + except Exception as e: + thefile['Filename'] = split_path(path)[-1] + thefile['Path'] = path + thefile['Error'] = gettext(self.error_msg_label).format(e) + thefile['Code'] = 0 + return thefile + + user_dir = path + + thefile['Filename'] = split_path(path)[-1] + thefile['Path'] = user_dir + thefile['Code'] = 1 if not path_exists(orig_path): thefile['Error'] = gettext( @@ -791,7 +789,7 @@ class Filemanager(object): thefile['Code'] = -1 return thefile - if split_path(user_dir)[-1] == '/'\ + if split_path(user_dir)[-1] == '/' \ or os.path.isfile(orig_path) is False: thefile['FileType'] = 'Directory' else: @@ -828,7 +826,7 @@ class Filemanager(object): """ if not self.validate_request('rename'): return { - 'Error': gettext('Not allowed'), + 'Error': gettext(self.not_allowed_error_label), 'Code': 0 } @@ -839,7 +837,7 @@ class Filemanager(object): Filemanager.check_access_permission(the_dir, new) except Exception as e: res = { - 'Error': gettext(u"Error: {0}").format(e), + 'Error': gettext(self.error_msg_label).format(e), 'Code': 0 } return res @@ -893,7 +891,7 @@ class Filemanager(object): """ if not self.validate_request('delete'): return { - 'Error': gettext('Not allowed'), + 'Error': gettext(self.not_allowed_error_label), 'Code': 0 } @@ -906,7 +904,7 @@ class Filemanager(object): Filemanager.check_access_permission(the_dir, path) except Exception as e: res = { - 'Error': gettext(u"Error: {0}").format(e), + 'Error': gettext(self.error_msg_label).format(e), 'Code': 0 } return res @@ -920,7 +918,7 @@ class Filemanager(object): os.remove(orig_path) except Exception as e: code = 0 - err_msg = gettext(u"Error: {0}").format(e.strerror) + err_msg = gettext(self.error_msg_label).format(e.strerror) result = { 'Path': path, @@ -936,7 +934,7 @@ class Filemanager(object): """ if not self.validate_request('upload'): return { - 'Error': gettext('Not allowed'), + 'Error': gettext(self.not_allowed_error_label), 'Code': 0 } @@ -964,14 +962,14 @@ class Filemanager(object): f.write(data) except Exception as e: code = 0 - err_msg = gettext(u"Error: {0}").format( + err_msg = gettext(self.error_msg_label).format( e.strerror if hasattr(e, 'strerror') else gettext(u'Unknown')) try: Filemanager.check_access_permission(the_dir, path) except Exception as e: res = { - 'Error': gettext(u"Error: {0}").format(e), + 'Error': gettext(self.error_msg_label).format(e), 'Code': 0 } return res @@ -1008,9 +1006,9 @@ class Filemanager(object): except Exception as e: code = 0 if hasattr(e, 'strerror'): - err_msg = gettext(u"Error: {0}").format(e.strerror) + err_msg = gettext(self.error_msg_label).format(e.strerror) else: - err_msg = gettext(u"Error: {0}").format(e) + err_msg = gettext(self.error_msg_label).format(e) result = { 'Path': path, @@ -1061,8 +1059,7 @@ class Filemanager(object): # check if file type is text or binary text_chars = bytearray([7, 8, 9, 10, 12, 13, 27]) \ - + bytearray(range(0x20, 0x7f)) \ - + bytearray(range(0x80, 0x100)) + + bytearray(range(0x20, 0x7f)) + bytearray(range(0x80, 0x100)) def is_binary_string(bytes_data): """Checks if string data is binary""" @@ -1100,13 +1097,14 @@ class Filemanager(object): # we don't want to expose real path of file # so only show error message. if ex.strerror == 'Permission denied': - err_msg = gettext(u"Error: {0}").format(ex.strerror) + err_msg = gettext(Filemanager.error_msg_label).\ + format(ex.strerror) else: - err_msg = gettext(u"Error: {0}").format(str(ex)) + err_msg = gettext(Filemanager.error_msg_label).format(str(ex)) except Exception as ex: status = False - err_msg = gettext(u"Error: {0}").format(str(ex)) + err_msg = gettext(Filemanager.error_msg_label).format(str(ex)) # Remove root storage path from error message # when running in Server mode @@ -1123,7 +1121,7 @@ class Filemanager(object): """ if not self.validate_request('create'): return { - 'Error': gettext('Not allowed'), + 'Error': gettext(self.not_allowed_error_label), 'Code': 0 } @@ -1134,7 +1132,7 @@ class Filemanager(object): path, name)) except Exception as e: res = { - 'Error': gettext(u"Error: {0}").format(e), + 'Error': gettext(self.error_msg_label).format(e), 'Code': 0 } return res @@ -1152,14 +1150,14 @@ class Filemanager(object): os.mkdir(new_path) except Exception as e: code = 0 - err_msg = gettext(u"Error: {0}").format(e.strerror) + err_msg = gettext(self.error_msg_label).format(e.strerror) else: new_path, new_name = self.get_new_name(the_dir, path, name) try: os.mkdir(new_path) except Exception as e: code = 0 - err_msg = gettext(u"Error: {0}").format(e.strerror) + err_msg = gettext(self.error_msg_label).format(e.strerror) result = { 'Parent': path, @@ -1176,7 +1174,7 @@ class Filemanager(object): """ if not self.validate_request('download'): return { - 'Error': gettext('Not allowed'), + 'Error': gettext(self.not_allowed_error_label), 'Code': 0 } @@ -1193,7 +1191,7 @@ class Filemanager(object): the_dir, u"{}{}".format(path, path) ) except Exception as e: - resp = Response(gettext(u"Error: {0}").format(e)) + resp = Response(gettext(self.error_msg_label).format(e)) resp.headers['Content-Disposition'] = \ 'attachment; filename=' + name return resp @@ -1210,7 +1208,7 @@ class Filemanager(object): try: Filemanager.check_access_permission(the_dir, path) except Exception as e: - err_msg = gettext(u"Error: {0}").format(e) + err_msg = gettext(self.error_msg_label).format(e) res['Code'] = 0 res['Error'] = err_msg return res diff --git a/web/pgadmin/tools/debugger/__init__.py b/web/pgadmin/tools/debugger/__init__.py index 3209e4f0a..832ddb027 100644 --- a/web/pgadmin/tools/debugger/__init__.py +++ b/web/pgadmin/tools/debugger/__init__.py @@ -72,6 +72,7 @@ class DebuggerModule(PgAdminModule): return scripts def register_preferences(self): + keyboard_shortcut_label = 'Keyboard shortcuts' self.open_in_new_tab = self.preference.register( 'display', 'debugger_new_browser_tab', gettext("Open in new browser tab"), 'boolean', False, @@ -89,7 +90,7 @@ class DebuggerModule(PgAdminModule): 'char': 'c' } }, - category_label=gettext('Keyboard shortcuts'), + category_label=gettext(keyboard_shortcut_label), fields=accesskey_fields ) @@ -102,7 +103,7 @@ class DebuggerModule(PgAdminModule): 'char': 's' } }, - category_label=gettext('Keyboard shortcuts'), + category_label=gettext(keyboard_shortcut_label), fields=accesskey_fields ) @@ -115,7 +116,7 @@ class DebuggerModule(PgAdminModule): 'char': 'i' } }, - category_label=gettext('Keyboard shortcuts'), + category_label=gettext(keyboard_shortcut_label), fields=accesskey_fields ) @@ -128,7 +129,7 @@ class DebuggerModule(PgAdminModule): 'char': 'o' } }, - category_label=gettext('Keyboard shortcuts'), + category_label=gettext(keyboard_shortcut_label), fields=accesskey_fields ) @@ -141,7 +142,7 @@ class DebuggerModule(PgAdminModule): 'char': 't' } }, - category_label=gettext('Keyboard shortcuts'), + category_label=gettext(keyboard_shortcut_label), fields=accesskey_fields ) @@ -154,7 +155,7 @@ class DebuggerModule(PgAdminModule): 'char': 'x' } }, - category_label=gettext('Keyboard shortcuts'), + category_label=gettext(keyboard_shortcut_label), fields=accesskey_fields ) @@ -172,7 +173,7 @@ class DebuggerModule(PgAdminModule): 'char': 'q' } }, - category_label=gettext('Keyboard shortcuts'), + category_label=gettext(keyboard_shortcut_label), fields=shortcut_fields ) @@ -190,7 +191,7 @@ class DebuggerModule(PgAdminModule): 'char': '[' } }, - category_label=gettext('Keyboard shortcuts'), + category_label=gettext(keyboard_shortcut_label), fields=shortcut_fields ) @@ -208,7 +209,7 @@ class DebuggerModule(PgAdminModule): 'char': ']' } }, - category_label=gettext('Keyboard shortcuts'), + category_label=gettext(keyboard_shortcut_label), fields=shortcut_fields ) @@ -226,7 +227,7 @@ class DebuggerModule(PgAdminModule): 'char': 'Tab' } }, - category_label=gettext('Keyboard shortcuts'), + category_label=gettext(keyboard_shortcut_label), fields=shortcut_fields ) @@ -258,6 +259,9 @@ class DebuggerModule(PgAdminModule): blueprint = DebuggerModule(MODULE_NAME, __name__) +mime_type = "application/javascript" +server_connection_error_label = \ + 'Not connected to server or connection with the server has been closed.' @blueprint.route("/", endpoint='index') @@ -275,7 +279,7 @@ def script(): return Response( response=render_template("debugger/js/debugger.js", _=gettext), status=200, - mimetype="application/javascript" + mimetype=mime_type ) @@ -286,7 +290,7 @@ def script_debugger_js(): return Response( response=render_template("debugger/js/debugger_ui.js", _=gettext), status=200, - mimetype="application/javascript" + mimetype=mime_type ) @@ -300,7 +304,7 @@ def script_debugger_direct_js(): return Response( response=render_template("debugger/js/direct.js", _=gettext), status=200, - mimetype="application/javascript" + mimetype=mime_type ) @@ -833,10 +837,7 @@ def restart_debugging(trans_id): return make_json_response( data={ 'status': False, - 'result': gettext( - 'Not connected to server or connection with the server ' - 'has been closed.' - ) + 'result': gettext(server_connection_error_label) } ) @@ -876,10 +877,7 @@ def restart_debugging(trans_id): ) else: status = False - result = gettext( - 'Not connected to server or connection with the server has ' - 'been closed.' - ) + result = gettext(server_connection_error_label) return make_json_response(data={'status': status, 'result': result}) @@ -905,10 +903,7 @@ def start_debugger_listener(trans_id): return make_json_response( data={ 'status': False, - 'result': gettext( - 'Not connected to server or connection with the server ' - 'has been closed.' - ) + 'result': gettext(server_connection_error_label) } ) @@ -1097,19 +1092,13 @@ def start_debugger_listener(trans_id): ) else: status = False - result = gettext( - 'Not connected to server or connection with the server ' - 'has been closed.' - ) + result = gettext(server_connection_error_label) return make_json_response( data={'status': status, 'result': result} ) else: status = False - result = gettext( - 'Not connected to server or connection with the server has ' - 'been closed.' - ) + result = gettext(server_connection_error_label) return make_json_response(data={'status': status, 'result': result}) @@ -1142,10 +1131,7 @@ def execute_debugger_query(trans_id, query_type): return make_json_response( data={ 'status': False, - 'result': gettext( - 'Not connected to server or connection with the server ' - 'has been closed.' - ) + 'result': gettext(server_connection_error_label) } ) @@ -1161,8 +1147,7 @@ def execute_debugger_query(trans_id, query_type): else DEBUGGER_SQL_V2_PATH if not conn.connected(): - result = gettext('Not connected to server or connection ' - 'with the server has been closed.') + result = gettext(server_connection_error_label) return internal_server_error(errormsg=result) sql = render_template( @@ -1219,10 +1204,7 @@ def messages(trans_id): return make_json_response( data={ 'status': 'NotConnected', - 'result': gettext( - 'Not connected to server or connection with the server ' - 'has been closed.' - ) + 'result': gettext(server_connection_error_label) } ) @@ -1257,10 +1239,7 @@ def messages(trans_id): data={'status': status, 'result': port_number} ) else: - result = gettext( - 'Not connected to server or connection with the ' - 'server has been closed.' - ) + result = gettext(server_connection_error_label) return internal_server_error(errormsg=str(result)) @@ -1289,10 +1268,7 @@ def start_execution(trans_id, port_num): return make_json_response( data={ 'status': 'NotConnected', - 'result': gettext( - 'Not connected to server or connection with the server ' - 'has been closed.' - ) + 'result': gettext(server_connection_error_label) } ) @@ -1368,10 +1344,7 @@ def set_clear_breakpoint(trans_id, line_no, set_type): return make_json_response( data={ 'status': False, - 'result': gettext( - 'Not connected to server or connection with the server ' - 'has been closed.' - ) + 'result': gettext(server_connection_error_label) } ) @@ -1425,10 +1398,7 @@ def set_clear_breakpoint(trans_id, line_no, set_type): 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(server_connection_error_label) return make_json_response( data={'status': status, 'result': result['rows']} @@ -1456,10 +1426,7 @@ def clear_all_breakpoint(trans_id): return make_json_response( data={ 'status': False, - 'result': gettext( - 'Not connected to server or connection ' - 'with the server has been closed.' - ) + 'result': gettext(server_connection_error_label) } ) manager = get_driver(PG_DEFAULT_DRIVER).connection_manager( @@ -1494,9 +1461,7 @@ def clear_all_breakpoint(trans_id): return make_json_response(data={'status': False}) else: status = False - result = gettext( - 'Not connected to server or connection with the server has ' - 'been closed.') + result = gettext(server_connection_error_label) return make_json_response( data={'status': status, 'result': result['rows']} @@ -1524,8 +1489,7 @@ def deposit_parameter_value(trans_id): return make_json_response( data={ 'status': False, - 'result': gettext('Not connected to server or connection ' - 'with the server has been closed.') + 'result': gettext(server_connection_error_label) } ) manager = get_driver(PG_DEFAULT_DRIVER).connection_manager( @@ -1572,10 +1536,7 @@ def deposit_parameter_value(trans_id): ) else: status = False - result = gettext( - 'Not connected to server or connection with the server has ' - 'been closed.' - ) + result = gettext(server_connection_error_label) return make_json_response(data={'status': status, 'result': result}) @@ -1602,10 +1563,7 @@ def select_frame(trans_id, frame_id): return make_json_response( data={ 'status': False, - 'result': gettext( - 'Not connected to server or connection ' - 'with the server has been closed.' - ) + 'result': gettext(server_connection_error_label) } ) @@ -1637,10 +1595,7 @@ def select_frame(trans_id, frame_id): 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(server_connection_error_label) return make_json_response( data={'status': status, 'result': result['rows']} @@ -1918,9 +1873,7 @@ def poll_end_execution_result(trans_id): if de_inst.debugger_data is None: return make_json_response( data={'status': 'NotConnected', - 'result': gettext( - 'Not connected to server or connection with the ' - 'server has been closed.') + 'result': gettext(server_connection_error_label) } ) @@ -2019,8 +1972,7 @@ 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(server_connection_error_label) return make_json_response(data={'status': status, 'result': result}) @@ -2046,8 +1998,7 @@ def poll_result(trans_id): return make_json_response( data={ 'status': 'NotConnected', - 'result': gettext('Not connected to server or connection ' - 'with the server has been closed.') + 'result': gettext(server_connection_error_label) } ) @@ -2068,10 +2019,7 @@ def poll_result(trans_id): status = 'Busy' else: status = 'NotConnected' - result = gettext( - 'Not connected to server or connection with the server ' - 'has been closed.' - ) + result = gettext(server_connection_error_label) return make_json_response( data={ diff --git a/web/pgadmin/tools/grant_wizard/__init__.py b/web/pgadmin/tools/grant_wizard/__init__.py index 79c5529c4..995e44856 100644 --- a/web/pgadmin/tools/grant_wizard/__init__.py +++ b/web/pgadmin/tools/grant_wizard/__init__.py @@ -183,6 +183,8 @@ def properties(sid, did, node_id, node_type): """It fetches the properties of object types and render into selection page of wizard """ + function_sql_url = '/sql/function.sql' + get_schema_sql_url = '/sql/get_schemas.sql' # unquote encoded url parameter node_type = unquote(node_type) @@ -202,7 +204,7 @@ def properties(sid, did, node_id, node_type): # Get sys_obj_values and get list of schemas ntype = 'schema' SQL = render_template("/".join( - [server_prop['template_path'], '/sql/get_schemas.sql']), + [server_prop['template_path'], get_schema_sql_url]), show_sysobj=show_sysobj) status, res = conn.execute_dict(SQL) @@ -211,7 +213,7 @@ def properties(sid, did, node_id, node_type): node_types = res['rows'] else: SQL = render_template("/".join( - [server_prop['template_path'], '/sql/get_schemas.sql']), + [server_prop['template_path'], get_schema_sql_url]), nspid=node_id, show_sysobj=False) status, res = conn.execute_dict(SQL) @@ -227,7 +229,7 @@ def properties(sid, did, node_id, node_type): # Fetch functions against schema if ntype in ['schema', 'function']: SQL = render_template("/".join( - [server_prop['template_path'], '/sql/function.sql']), + [server_prop['template_path'], function_sql_url]), node_id=node_id, type='function') status, res = conn.execute_dict(SQL) @@ -244,7 +246,7 @@ def properties(sid, did, node_id, node_type): server_prop['version'] >= 11000)) and ntype in ['schema', 'procedure']): SQL = render_template("/".join( - [server_prop['template_path'], '/sql/function.sql']), + [server_prop['template_path'], function_sql_url]), node_id=node_id, type='procedure') status, res = conn.execute_dict(SQL) @@ -258,7 +260,7 @@ def properties(sid, did, node_id, node_type): # Fetch trigger functions if ntype in ['schema', 'trigger_function']: SQL = render_template("/".join( - [server_prop['template_path'], '/sql/function.sql']), + [server_prop['template_path'], function_sql_url]), node_id=node_id, type='trigger_function') status, res = conn.execute_dict(SQL)