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..0b9ccfab5 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 @@ -25,6 +25,9 @@ from pgadmin.browser.server_groups.servers.databases.schemas.tables.\ from pgadmin.utils.driver import get_driver from config import PG_DEFAULT_DRIVER +index_constraint_sql = 'index_constraint/sql/#{0}#' +icon_sign = "icon-%s" + class IndexConstraintModule(ConstraintTypeModule): """ @@ -232,7 +235,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 +247,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.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 +265,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 +295,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: @@ -347,8 +352,7 @@ class IndexConstraintView(PGChildNodeView): """ 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) + self.template_path = index_constraint_sql.format(self.manager.version) # We need parent's name eg table name and schema name schema, table = idxcons_utils.get_parent(self.conn, tid) @@ -392,16 +396,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=icon_sign % self.node_type ) return make_json_response( data=res, @@ -441,7 +442,7 @@ class IndexConstraintView(PGChildNodeView): row['oid'], tid, row['name'], - icon="icon-%s" % self.node_type + icon=icon_sign % self.node_type ) ) return make_json_response( @@ -466,8 +467,7 @@ class IndexConstraintView(PGChildNodeView): """ 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) + self.template_path = index_constraint_sql.format(self.manager.version) # We need parent's name eg table name and schema name schema, table = idxcons_utils.get_parent(self.conn, tid) @@ -486,7 +486,7 @@ class IndexConstraintView(PGChildNodeView): row['oid'], tid, row['name'], - icon="icon-%s" % self.node_type + icon=icon_sign % self.node_type )) return res @@ -627,7 +627,7 @@ class IndexConstraintView(PGChildNodeView): res['rows'][0]['oid'], tid, data['name'], - icon="icon-%s" % self.node_type + icon=icon_sign % self.node_type ) ) @@ -688,7 +688,7 @@ class IndexConstraintView(PGChildNodeView): cid, tid, name, - icon="icon-%s" % self.node_type + icon=icon_sign % self.node_type ) ) except Exception as e: @@ -848,10 +848,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 +937,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 78a24c24a..606c4519d 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 @@ -46,6 +47,8 @@ global transid path_exists = os.path.exists split_path = os.path.split encode_json = json.JSONEncoder().encode +error_msg_label = u"Error: {0}" +not_allowed_error_label = 'Not allowed' # utility functions @@ -178,6 +181,7 @@ class FileManagerModule(PgAdminModule): # Initialise the module blueprint = FileManagerModule(MODULE_NAME, __name__) +mime_type = "application/javascript" @blueprint.route("/", endpoint='index') @@ -195,7 +199,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 +209,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 +228,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") @@ -337,7 +341,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() @@ -555,7 +558,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(error_msg_label).format(e) files = { 'Code': 0, 'Error': err_msg @@ -563,7 +566,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: @@ -639,7 +642,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 @@ -658,9 +661,9 @@ 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(error_msg_label).format(e.strerror) else: - err_msg = gettext(u"Error: {0}").format(e) + err_msg = gettext(error_msg_label).format(e) files = { 'Code': 0, 'Error': err_msg @@ -699,7 +702,7 @@ class Filemanager(object): @staticmethod def get_abs_path(in_dir, path): - if (path.startswith('\\\\') and _platform == 'win32')\ + if (path.startswith('\\\\') and _platform == 'win32') \ or config.SERVER_MODE is False or in_dir is None: return u"{}".format(path) @@ -740,37 +743,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': '', @@ -782,6 +759,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(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( @@ -789,7 +786,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: @@ -826,7 +823,7 @@ class Filemanager(object): """ if not self.validate_request('rename'): return { - 'Error': gettext('Not allowed'), + 'Error': gettext(not_allowed_error_label), 'Code': 0 } @@ -837,7 +834,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(error_msg_label).format(e), 'Code': 0 } return res @@ -891,7 +888,7 @@ class Filemanager(object): """ if not self.validate_request('delete'): return { - 'Error': gettext('Not allowed'), + 'Error': gettext(not_allowed_error_label), 'Code': 0 } @@ -904,7 +901,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(error_msg_label).format(e), 'Code': 0 } return res @@ -918,7 +915,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(error_msg_label).format(e.strerror) result = { 'Path': path, @@ -934,7 +931,7 @@ class Filemanager(object): """ if not self.validate_request('upload'): return { - 'Error': gettext('Not allowed'), + 'Error': gettext(not_allowed_error_label), 'Code': 0 } @@ -962,14 +959,14 @@ class Filemanager(object): f.write(data) except Exception as e: code = 0 - err_msg = gettext(u"Error: {0}").format( + err_msg = gettext(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(error_msg_label).format(e), 'Code': 0 } return res @@ -1006,9 +1003,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(error_msg_label).format(e.strerror) else: - err_msg = gettext(u"Error: {0}").format(e) + err_msg = gettext(error_msg_label).format(e) result = { 'Path': path, @@ -1059,8 +1056,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""" @@ -1094,13 +1090,13 @@ 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(error_msg_label).format(ex.strerror) else: - err_msg = gettext(u"Error: {0}").format(str(ex)) + err_msg = gettext(error_msg_label).format(str(ex)) except Exception as ex: status = False - err_msg = gettext(u"Error: {0}").format(str(ex)) + err_msg = gettext(error_msg_label).format(str(ex)) # Remove root storage path from error message # when running in Server mode @@ -1117,7 +1113,7 @@ class Filemanager(object): """ if not self.validate_request('create'): return { - 'Error': gettext('Not allowed'), + 'Error': gettext(not_allowed_error_label), 'Code': 0 } @@ -1128,7 +1124,7 @@ class Filemanager(object): path, name)) except Exception as e: res = { - 'Error': gettext(u"Error: {0}").format(e), + 'Error': gettext(error_msg_label).format(e), 'Code': 0 } return res @@ -1146,14 +1142,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(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(error_msg_label).format(e.strerror) result = { 'Parent': path, @@ -1170,7 +1166,7 @@ class Filemanager(object): """ if not self.validate_request('download'): return { - 'Error': gettext('Not allowed'), + 'Error': gettext(not_allowed_error_label), 'Code': 0 } @@ -1187,7 +1183,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(error_msg_label).format(e)) resp.headers['Content-Disposition'] = \ 'attachment; filename=' + name return resp @@ -1204,7 +1200,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(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 9b5bf5ddd..bd3bb9ba9 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 ) @@ -834,10 +838,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) } ) @@ -877,10 +878,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}) @@ -906,10 +904,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) } ) @@ -1098,19 +1093,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}) @@ -1143,10 +1132,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) } ) @@ -1162,8 +1148,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( @@ -1220,10 +1205,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) } ) @@ -1258,10 +1240,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)) @@ -1290,10 +1269,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) } ) @@ -1369,10 +1345,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) } ) @@ -1426,10 +1399,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']} @@ -1457,10 +1427,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( @@ -1495,9 +1462,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']} @@ -1525,8 +1490,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( @@ -1573,10 +1537,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}) @@ -1603,10 +1564,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) } ) @@ -1638,10 +1596,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']} @@ -1919,9 +1874,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) } ) @@ -2020,8 +1973,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}) @@ -2047,8 +1999,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) } ) @@ -2069,10 +2020,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)