From bfc3903375d3277ef56ea9fbb286d50839b3aa73 Mon Sep 17 00:00:00 2001 From: Cyril Jouve Date: Fri, 28 Aug 2020 19:03:47 +0200 Subject: [PATCH 6/7] Renames unicode to str --- docs/en_US/conf.py | 8 +- web/config.py | 4 +- web/pgAdmin4.py | 2 +- web/pgadmin/__init__.py | 8 +- web/pgadmin/about/__init__.py | 2 +- web/pgadmin/browser/__init__.py | 8 +- web/pgadmin/browser/server_groups/__init__.py | 12 +- .../browser/server_groups/servers/__init__.py | 20 +-- .../servers/databases/__init__.py | 6 +- .../servers/databases/casts/__init__.py | 2 +- .../databases/event_triggers/__init__.py | 2 +- .../foreign_data_wrappers/__init__.py | 2 +- .../foreign_servers/__init__.py | 2 +- .../foreign_servers/user_mappings/__init__.py | 2 +- .../servers/databases/schemas/__init__.py | 4 +- .../databases/schemas/collations/__init__.py | 2 +- .../databases/schemas/domains/__init__.py | 2 +- .../domains/domain_constraints/__init__.py | 2 +- .../schemas/foreign_tables/__init__.py | 10 +- .../schemas/fts_configurations/__init__.py | 2 +- .../schemas/fts_dictionaries/__init__.py | 4 +- .../schemas/fts_templates/__init__.py | 2 +- .../databases/schemas/functions/__init__.py | 6 +- .../databases/schemas/packages/__init__.py | 8 +- .../schemas/packages/edbfuncs/__init__.py | 2 +- .../schemas/packages/edbvars/__init__.py | 6 +- .../databases/schemas/sequences/__init__.py | 10 +- .../databases/schemas/tables/__init__.py | 8 +- .../schemas/tables/columns/__init__.py | 2 +- .../schemas/tables/compound_triggers/utils.py | 2 +- .../constraints/check_constraint/__init__.py | 2 +- .../exclusion_constraint/__init__.py | 2 +- .../constraints/foreign_key/__init__.py | 2 +- .../constraints/index_constraint/__init__.py | 4 +- .../constraints/index_constraint/utils.py | 2 +- .../databases/schemas/tables/indexes/utils.py | 2 +- .../tables/row_security_policies/utils.py | 2 +- .../tests/test_tables_properties_sql.py | 2 +- .../schemas/tables/triggers/utils.py | 2 +- .../servers/databases/schemas/tables/utils.py | 12 +- .../databases/schemas/types/__init__.py | 2 +- .../databases/schemas/views/__init__.py | 4 +- .../server_groups/servers/pgagent/__init__.py | 2 +- .../server_groups/servers/roles/__init__.py | 126 +++++++++--------- .../servers/tablespaces/__init__.py | 2 +- web/pgadmin/misc/bgprocess/processes.py | 26 ++-- web/pgadmin/misc/file_manager/__init__.py | 126 +++++++++--------- web/pgadmin/setup/db_upgrade.py | 2 +- web/pgadmin/setup/user_info.py | 16 +-- web/pgadmin/tools/backup/__init__.py | 2 +- web/pgadmin/tools/import_export/__init__.py | 2 +- web/pgadmin/tools/restore/__init__.py | 2 +- web/pgadmin/tools/sqleditor/__init__.py | 8 +- web/pgadmin/utils/__init__.py | 8 +- web/pgadmin/utils/driver/psycopg2/__init__.py | 28 ++-- .../utils/driver/psycopg2/connection.py | 104 +++++++-------- .../driver/psycopg2/generate_keywords.py | 6 +- .../utils/driver/psycopg2/server_manager.py | 12 +- .../tests/test_javascript_bundler.py | 4 +- web/pgadmin/utils/preferences.py | 2 +- .../utils/sqlautocomplete/autocomplete.py | 2 +- .../utils/sqlautocomplete/parseutils/ctes.py | 2 +- web/setup.py | 4 +- 63 files changed, 338 insertions(+), 338 deletions(-) diff --git a/docs/en_US/conf.py b/docs/en_US/conf.py index 865c04f49..256c62a73 100644 --- a/docs/en_US/conf.py +++ b/docs/en_US/conf.py @@ -208,8 +208,8 @@ htmlhelp_basename = 'pgadmin4' # (source start file, target name, title, author, documentclass # [howto/manual]). latex_documents = [ - ('index', 'pgadmin4.tex', u'pgAdmin 4 Documentation', - u'The pgAdmin Development Team', 'manual'), + ('index', 'pgadmin4.tex', 'pgAdmin 4 Documentation', + 'The pgAdmin Development Team', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of @@ -247,6 +247,6 @@ latex_elements = { # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - ('index', 'pgadmin4', u'pgAdmin 4 Documentation', - [u'The pgAdmin Development Team'], 1) + ('index', 'pgadmin4', 'pgAdmin 4 Documentation', + ['The pgAdmin Development Team'], 1) ] diff --git a/web/config.py b/web/config.py index 893168cc8..92986249f 100644 --- a/web/config.py +++ b/web/config.py @@ -204,13 +204,13 @@ APP_VERSION_EXTN = ('.css', '.js', '.html', '.svg', '.png', '.gif', '.ico') if IS_WIN: # Use the short path on windows DATA_DIR = os.path.realpath( - os.path.join(fs_short_path(env('APPDATA')), u"pgAdmin") + os.path.join(fs_short_path(env('APPDATA')), "pgAdmin") ) else: if SERVER_MODE: DATA_DIR = '/var/lib/pgadmin' else: - DATA_DIR = os.path.realpath(os.path.expanduser(u'~/.pgadmin/')) + DATA_DIR = os.path.realpath(os.path.expanduser('~/.pgadmin/')) # An optional login banner to show security warnings/disclaimers etc. at # login and password recovery etc. HTML may be included for basic formatting, diff --git a/web/pgAdmin4.py b/web/pgAdmin4.py index 04c4ffeaa..8e0eb99d3 100644 --- a/web/pgAdmin4.py +++ b/web/pgAdmin4.py @@ -81,7 +81,7 @@ config.SETTINGS_SCHEMA_VERSION = SCHEMA_VERSION if not os.path.isfile(config.SQLITE_PATH): setup_py = os.path.join( os.path.dirname(os.path.realpath(u_encode(__file__, fs_encoding))), - u'setup.py' + 'setup.py' ) exec(open(file_quote(setup_py), 'r').read()) diff --git a/web/pgadmin/__init__.py b/web/pgadmin/__init__.py index 08ae0ca48..516ba2c4d 100644 --- a/web/pgadmin/__init__.py +++ b/web/pgadmin/__init__.py @@ -309,8 +309,8 @@ def create_app(app_name=None): # Setup authentication ########################################################################## - app.config['SQLALCHEMY_DATABASE_URI'] = u'sqlite:///{0}?timeout={1}' \ - .format(config.SQLITE_PATH.replace(u'\\', u'/'), + app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///{0}?timeout={1}' \ + .format(config.SQLITE_PATH.replace('\\', '/'), getattr(config, 'SQLITE_TIMEOUT', 500) ) @@ -565,8 +565,8 @@ def create_app(app_name=None): svr_discovery_id = section description = registry.get(section, 'Description') data_directory = registry.get(section, 'DataDirectory') - svr_comment = gettext(u"Auto-detected {0} installation " - u"with the data directory at {1}" + svr_comment = gettext("Auto-detected {0} installation " + "with the data directory at {1}" ).format(description, data_directory) add_server(user_id, servergroup_id, svr_name, svr_superuser, svr_port, svr_discovery_id, diff --git a/web/pgadmin/about/__init__.py b/web/pgadmin/about/__init__.py index e56a191ff..083246f2a 100644 --- a/web/pgadmin/about/__init__.py +++ b/web/pgadmin/about/__init__.py @@ -33,7 +33,7 @@ class AboutModule(PgAdminModule): module="pgAdmin.About", callback='about_show', icon='fa fa-info-circle', - label=gettext(u'About %(appname)s', appname=appname) + label=gettext('About %(appname)s', appname=appname) ) ] } diff --git a/web/pgadmin/browser/__init__.py b/web/pgadmin/browser/__init__.py index 90665374a..5375e944f 100644 --- a/web/pgadmin/browser/__init__.py +++ b/web/pgadmin/browser/__init__.py @@ -62,12 +62,12 @@ BROWSER_STATIC = 'browser.static' JQUERY_ACIPLUGIN = 'jquery.aciplugin' BROWSER_INDEX = 'browser.index' PGADMIN_BROWSER = 'pgAdmin.Browser' -PASS_ERROR_MSG = u'Your password has not been changed.' -SMTP_SOCKET_ERROR = u'SMTP Socket error: {error}\n {pass_error}'.format( +PASS_ERROR_MSG = 'Your password has not been changed.' +SMTP_SOCKET_ERROR = 'SMTP Socket error: {error}\n {pass_error}'.format( error={}, pass_error=PASS_ERROR_MSG) -SMTP_ERROR = u'SMTP error: {error}\n {pass_error}'.format( +SMTP_ERROR = 'SMTP error: {error}\n {pass_error}'.format( error={}, pass_error=PASS_ERROR_MSG) -PASS_ERROR = u'Error: {error}\n {pass_error}'.format( +PASS_ERROR = 'Error: {error}\n {pass_error}'.format( error={}, pass_error=PASS_ERROR_MSG) diff --git a/web/pgadmin/browser/server_groups/__init__.py b/web/pgadmin/browser/server_groups/__init__.py index 3c4ec6831..717795bde 100644 --- a/web/pgadmin/browser/server_groups/__init__.py +++ b/web/pgadmin/browser/server_groups/__init__.py @@ -177,8 +177,8 @@ class ServerGroupView(NodeView): ) else: try: - if u'name' in data: - servergroup.name = data[u'name'] + if 'name' in data: + servergroup.name = data['name'] db.session.commit() except exc.IntegrityError: db.session.rollback() @@ -230,16 +230,16 @@ class ServerGroupView(NodeView): data = request.form if request.form else json.loads( request.data, encoding='utf-8' ) - if data[u'name'] != '': + if data['name'] != '': try: sg = ServerGroup( user_id=current_user.id, - name=data[u'name']) + name=data['name']) db.session.add(sg) db.session.commit() - data[u'id'] = sg.id - data[u'name'] = sg.name + data['id'] = sg.id + data['name'] = sg.name return jsonify( node=self.blueprint.generate_browser_node( diff --git a/web/pgadmin/browser/server_groups/servers/__init__.py b/web/pgadmin/browser/server_groups/servers/__init__.py index 566273e57..2eb058a40 100644 --- a/web/pgadmin/browser/server_groups/servers/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/__init__.py @@ -726,9 +726,9 @@ class ServerNode(PGChildNodeView): def create(self, gid): """Add a server node to the settings database""" required_args = [ - u'name', - u'db', - u'sslmode', + 'name', + 'db', + 'sslmode', ] data = request.form if request.form else json.loads( @@ -743,10 +743,10 @@ class ServerNode(PGChildNodeView): # Some fields can be provided with service file so they are optional if 'service' in data and not data['service']: required_args.extend([ - u'host', - u'port', - u'username', - u'role' + 'host', + 'port', + 'username', + 'role' ]) for arg in required_args: if arg not in data: @@ -786,8 +786,8 @@ class ServerNode(PGChildNodeView): ssl_mode=data.get('sslmode'), comment=data.get('comment', None), role=data.get('role', None), - db_res=','.join(data[u'db_res']) - if u'db_res' in data else None, + db_res=','.join(data['db_res']) + if 'db_res' in data else None, sslcert=data.get('sslcert', None), sslkey=data.get('sslkey', None), sslrootcert=data.get('sslrootcert', None), @@ -851,7 +851,7 @@ class ServerNode(PGChildNodeView): status=401, success=0, errormsg=gettext( - u"Unable to connect to server:\n\n{}" + "Unable to connect to server:\n\n{}" ).format(errmsg) ) else: diff --git a/web/pgadmin/browser/server_groups/servers/databases/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/__init__.py index 74f6e1409..e7a69149a 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/__init__.py @@ -574,7 +574,7 @@ class DatabaseView(PGChildNodeView): def create(self, gid, sid): """Create the database.""" required_args = [ - u'name' + 'name' ] data = request.form if request.form else json.loads( @@ -992,7 +992,7 @@ class DatabaseView(PGChildNodeView): Generates sql for creating new database. """ required_args = [ - u'name' + 'name' ] for arg in required_args: @@ -1183,7 +1183,7 @@ class DatabaseView(PGChildNodeView): frmtd_variables = parse_variables_from_db(res1['rows']) result.update(frmtd_variables) - sql_header = u"-- Database: {0}\n\n-- ".format(result['name']) + sql_header = "-- Database: {0}\n\n-- ".format(result['name']) sql_header += render_template( "/".join([self.template_path, self._DELETE_SQL]), diff --git a/web/pgadmin/browser/server_groups/servers/databases/casts/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/casts/__init__.py index fa63c8c15..34e98e103 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/casts/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/casts/__init__.py @@ -606,7 +606,7 @@ class CastView(PGChildNodeView, SchemaDiffObjectCompare): data=data, conn=self.conn ) else: - return u"-- definition incomplete", None + return "-- definition incomplete", None return sql, data['srctyp'] + "->" + data["trgtyp"] @check_precondition diff --git a/web/pgadmin/browser/server_groups/servers/databases/event_triggers/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/event_triggers/__init__.py index 7b396011b..2fa5a351c 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/event_triggers/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/event_triggers/__init__.py @@ -746,7 +746,7 @@ class EventTriggerView(PGChildNodeView, SchemaDiffObjectCompare): if not status: return internal_server_error(errormsg=db_name) - sql_header = u"-- Event Trigger: {0} on database {1}\n\n-- ".format( + sql_header = "-- Event Trigger: {0} on database {1}\n\n-- ".format( result['name'], db_name ) diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/__init__.py index 64ae9974c..94e5e0c4e 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/__init__.py @@ -829,7 +829,7 @@ class ForeignDataWrapperView(PGChildNodeView, SchemaDiffObjectCompare): ) sql += "\n" - sql_header = u"""-- Foreign Data Wrapper: {0}\n\n""".format( + sql_header = """-- Foreign Data Wrapper: {0}\n\n""".format( res['rows'][0]['name']) sql_header += """-- DROP FOREIGN DATA WRAPPER {0} diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/__init__.py index 1aef6aca8..7f2baafb0 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/__init__.py @@ -837,7 +837,7 @@ class ForeignServerView(PGChildNodeView, SchemaDiffObjectCompare): conn=self.conn) sql += "\n" - sql_header = u"""-- Foreign Server: {0} + sql_header = """-- Foreign Server: {0} -- DROP SERVER {0} diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/__init__.py index 63f91ff48..10c6546a8 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/__init__.py @@ -815,7 +815,7 @@ class UserMappingView(PGChildNodeView, SchemaDiffObjectCompare): conn=self.conn) sql += "\n" - sql_header = u"""-- User Mapping : {0} + sql_header = """-- User Mapping : {0} -- DROP USER MAPPING FOR {0} SERVER {1} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/__init__.py index 68ac52fad..69d917d18 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/__init__.py @@ -867,7 +867,7 @@ It may have been removed by another user. _=gettext, data=data, conn=self.conn ) - sql_header = u"-- SCHEMA: {0}\n\n-- ".format(data['name']) + sql_header = "-- SCHEMA: {0}\n\n-- ".format(data['name']) # drop schema sql_header += render_template( @@ -1051,7 +1051,7 @@ It may have been removed by another user. _=gettext, data=old_data, conn=self.conn ) - sql_header = u""" + sql_header = """ -- CATALOG: {0} -- DROP SCHEMA {0}; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/__init__.py index 8ba1001a3..d87f8101b 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/__init__.py @@ -716,7 +716,7 @@ class CollationView(PGChildNodeView, SchemaDiffObjectCompare): self._CREATE_SQL]), data=data, conn=self.conn) - sql_header = u"-- Collation: {0};\n\n-- ".format(data['name']) + sql_header = "-- Collation: {0};\n\n-- ".format(data['name']) sql_header += render_template("/".join([self.template_path, self._DELETE_SQL]), diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/__init__.py index ebc04bb96..3178c06fc 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/__init__.py @@ -753,7 +753,7 @@ AND relkind != 'c'))""" SQL = render_template("/".join([self.template_path, self._CREATE_SQL]), data=data) - sql_header = u"""-- DOMAIN: {0}.{1}\n\n""".format( + sql_header = """-- DOMAIN: {0}.{1}\n\n""".format( data['basensp'], data['name']) sql_header += """-- DROP DOMAIN {0};\n diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/domain_constraints/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/domain_constraints/__init__.py index 95ef28884..071885372 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/domain_constraints/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/domain_constraints/__init__.py @@ -610,7 +610,7 @@ class DomainConstraintView(PGChildNodeView): self._CREATE_SQL]), data=data, domain=domain, schema=schema) - sql_header = u"""-- CHECK: {1}.{0} + sql_header = """-- CHECK: {1}.{0} -- ALTER DOMAIN {1} DROP CONSTRAINT {0}; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/__init__.py index 4686b5caf..807b11e52 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/__init__.py @@ -854,7 +854,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader, if not json_resp: return SQL.strip('\n') - sql_header = u"""-- FOREIGN TABLE: {0}.{1}\n\n""".format( + sql_header = """-- FOREIGN TABLE: {0}.{1}\n\n""".format( data['basensp'], data['name']) sql_header += """-- DROP FOREIGN TABLE {0}; @@ -1337,7 +1337,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader, else: columns = '*' - sql = u"SELECT {0}\n\tFROM {1};".format( + sql = "SELECT {0}\n\tFROM {1};".format( columns, self.qtIdent(self.conn, data['basensp'], data['name']) ) @@ -1377,7 +1377,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader, if len(columns) > 0: columns = ", ".join(columns) values = ", ".join(values) - sql = u"INSERT INTO {0}(\n\t{1})\n\tVALUES ({2});".format( + sql = "INSERT INTO {0}(\n\t{1})\n\tVALUES ({2});".format( self.qtIdent(self.conn, data['basensp'], data['name']), columns, values ) @@ -1422,7 +1422,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader, columns = "=?, ".join(columns) columns += "=?" - sql = u"UPDATE {0}\n\tSET {1}\n\tWHERE ;".format( + sql = "UPDATE {0}\n\tSET {1}\n\tWHERE ;".format( self.qtIdent(self.conn, data['basensp'], data['name']), columns ) @@ -1453,7 +1453,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader, if not data: return gone(self.not_found_error_msg()) - sql = u"DELETE FROM {0}\n\tWHERE ;".format( + sql = "DELETE FROM {0}\n\tWHERE ;".format( self.qtIdent(self.conn, data['basensp'], data['name']) ) diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/__init__.py index e225c8aff..b807107b4 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/__init__.py @@ -661,7 +661,7 @@ class FtsConfigurationView(PGChildNodeView, SchemaDiffObjectCompare): conn=self.conn ) else: - sql = u"-- definition incomplete" + sql = "-- definition incomplete" return sql @staticmethod diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/__init__.py index 23195c62f..c6a1cac2f 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/__init__.py @@ -659,7 +659,7 @@ class FtsDictionaryView(PGChildNodeView, SchemaDiffObjectCompare): conn=self.conn ) else: - sql = u"-- definition incomplete" + sql = "-- definition incomplete" return sql def _check_template_name_and_schema_name(self, data, old_data): @@ -849,7 +849,7 @@ class FtsDictionaryView(PGChildNodeView, SchemaDiffObjectCompare): data=res['rows'][0], conn=self.conn, is_displaying=True) - sql_header = u"""-- Text Search Dictionary: {0}.{1}\n\n""".format( + sql_header = """-- Text Search Dictionary: {0}.{1}\n\n""".format( res['rows'][0]['schema'], res['rows'][0]['name']) sql_header += """-- DROP TEXT SEARCH DICTIONARY {0};\n """.format(self.qtIdent(self.conn, res['rows'][0]['schema'], diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_templates/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_templates/__init__.py index 6b214f32d..d507bf3c3 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_templates/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_templates/__init__.py @@ -586,7 +586,7 @@ class FtsTemplateView(PGChildNodeView, SchemaDiffObjectCompare): conn=self.conn ) else: - sql = u"-- definition incomplete" + sql = "-- definition incomplete" return sql def get_sql(self, gid, sid, did, scid, data, tid=None): diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/__init__.py index 4dd5c1900..1edc46fad 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/__init__.py @@ -1092,7 +1092,7 @@ class FunctionView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare): return resp_data # Fetch the function definition. - args = u'' + args = '' args_without_name = [] args_list = [] @@ -1183,7 +1183,7 @@ class FunctionView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare): func_def=name_with_default_args, query_for="sql_panel") - sql_header = u"""-- {0}: {1}.{2}({3})\n\n""".format( + sql_header = """-- {0}: {1}.{2}({3})\n\n""".format( object_type.upper(), resp_data['pronamespace'], resp_data['proname'], resp_data['proargtypenames'].lstrip('(').rstrip(')')) @@ -1470,7 +1470,7 @@ class FunctionView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare): # Parse Privileges self._parse_privilege_data(data) - args = u'' + args = '' args_without_name = [] args_list = [] diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/__init__.py index a823d1d7a..96522d6a5 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/__init__.py @@ -366,8 +366,8 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare): """ required_args = [ - u'name', - u'pkgheadsrc' + 'name', + 'pkgheadsrc' ] data = request.form if request.form else json.loads( @@ -622,7 +622,7 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare): :return: """ required_args = [ - u'name' + 'name' ] sql = render_template( "/".join([self.template_path, self._PROPERTIES_SQL]), scid=scid, @@ -734,7 +734,7 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare): if not json_resp: return sql - sql_header = u"-- Package: {0}.{1}\n\n-- ".format( + sql_header = "-- Package: {0}.{1}\n\n-- ".format( self.schema, result['name']) sql_header += render_template( diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/edbfuncs/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/edbfuncs/__init__.py index 1ec612d1f..2939fe21f 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/edbfuncs/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/edbfuncs/__init__.py @@ -529,7 +529,7 @@ class EdbFuncView(PGChildNodeView, DataTypeReader): if not status: return internal_server_error(errormsg=res) - sql = u"-- Package {}: {}".format( + sql = "-- Package {}: {}".format( 'Function' if self.node_type == 'edbfunc' else 'Procedure', name) if body != '': diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/edbvars/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/edbvars/__init__.py index 5a201ab3b..ef206e4a2 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/edbvars/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/edbvars/__init__.py @@ -319,9 +319,9 @@ class EdbVarView(PGChildNodeView, DataTypeReader): var = res['rows'][0] - sql = u"-- Package Variable: {}".format(var['name']) - sql += u"\n\n" - sql += u"{} {};".format(var['name'], var['datatype']) + sql = "-- Package Variable: {}".format(var['name']) + sql += "\n\n" + sql += "{} {};".format(var['name'], var['datatype']) return ajax_response(response=sql) diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py index e2cf25123..8c7a378ef 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py @@ -371,9 +371,9 @@ class SequenceView(PGChildNodeView, SchemaDiffObjectCompare): """ required_args = [ - u'name', - u'schema', - u'seqowner', + 'name', + 'schema', + 'seqowner', ] data = request.form if request.form else json.loads( @@ -620,7 +620,7 @@ class SequenceView(PGChildNodeView, SchemaDiffObjectCompare): """ required_args = [ - u'name' + 'name' ] if seid is not None: @@ -737,7 +737,7 @@ class SequenceView(PGChildNodeView, SchemaDiffObjectCompare): if not json_resp: return sql - sql_header = u"""-- SEQUENCE: {0}.{1}\n\n""".format( + sql_header = """-- SEQUENCE: {0}.{1}\n\n""".format( result['schema'], result['name']) sql_header += """-- DROP SEQUENCE {0}; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py index cc3ae604d..9f18525dd 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py @@ -1426,7 +1426,7 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings, else: columns = '*' - sql = u"SELECT {0}\n\tFROM {1};".format( + sql = "SELECT {0}\n\tFROM {1};".format( columns, self.qtIdent(self.conn, data['schema'], data['name']) ) @@ -1474,7 +1474,7 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings, if len(columns) > 0: columns = ", ".join(columns) values = ", ".join(values) - sql = u"INSERT INTO {0}(\n\t{1})\n\tVALUES ({2});".format( + sql = "INSERT INTO {0}(\n\t{1})\n\tVALUES ({2});".format( self.qtIdent(self.conn, data['schema'], data['name']), columns, values ) @@ -1527,7 +1527,7 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings, columns = "=?, ".join(columns) columns += "=?" - sql = u"UPDATE {0}\n\tSET {1}\n\tWHERE ;".format( + sql = "UPDATE {0}\n\tSET {1}\n\tWHERE ;".format( self.qtIdent(self.conn, data['schema'], data['name']), columns ) @@ -1565,7 +1565,7 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings, data = res['rows'][0] - sql = u"DELETE FROM {0}\n\tWHERE ;".format( + sql = "DELETE FROM {0}\n\tWHERE ;".format( self.qtIdent(self.conn, data['schema'], data['name']) ) diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/__init__.py index e1fbeff6c..63e01d822 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/__init__.py @@ -754,7 +754,7 @@ class ColumnsView(PGChildNodeView, DataTypeReader): if not isinstance(SQL, str): return SQL - sql_header = u"-- Column: {0}\n\n-- ".format( + sql_header = "-- Column: {0}\n\n-- ".format( self.qtIdent( self.conn, data['schema'], data['table'], data['name']) ) diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/compound_triggers/utils.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/compound_triggers/utils.py index 7ecc6d5c4..a3c89afe9 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/compound_triggers/utils.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/compound_triggers/utils.py @@ -181,7 +181,7 @@ def get_reverse_engineered_sql(conn, **kwargs): SQL, name = get_sql(conn, data, tid, None, datlastsysoid) - sql_header = u"-- Compound Trigger: {0}\n\n-- ".format(data['name']) + sql_header = "-- Compound Trigger: {0}\n\n-- ".format(data['name']) sql_header += render_template("/".join([template_path, 'delete.sql']), data=data, conn=conn) diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/__init__.py index 9e291a954..6ffa693ff 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/__init__.py @@ -737,7 +737,7 @@ class CheckConstraintView(PGChildNodeView): self._CREATE_SQL]), data=data) - sql_header = u"-- Constraint: {0}\n\n-- ".format(data['name']) + sql_header = "-- Constraint: {0}\n\n-- ".format(data['name']) sql_header += render_template( "/".join([self.template_path, self._DELETE_SQL]), diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/__init__.py index 397d1f297..e5542bb0e 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/__init__.py @@ -832,7 +832,7 @@ class ExclusionConstraintView(PGChildNodeView): SQL = render_template( "/".join([self.template_path, self._CREATE_SQL]), data=data) - sql_header = u"-- Constraint: {0}\n\n-- ".format(data['name']) + sql_header = "-- Constraint: {0}\n\n-- ".format(data['name']) sql_header += render_template( "/".join([self.template_path, self._DELETE_SQL]), diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/__init__.py index 5bd15ddc3..611758194 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/__init__.py @@ -876,7 +876,7 @@ class ForeignKeyConstraintView(PGChildNodeView): SQL = render_template( "/".join([self.template_path, self._CREATE_SQL]), data=data) - sql_header = u"-- Constraint: {0}\n\n-- ".format(data['name']) + sql_header = "-- Constraint: {0}\n\n-- ".format(data['name']) sql_header += render_template( "/".join([self.template_path, self._DELETE_SQL]), 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 4f601306e..1f79e8959 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 @@ -512,7 +512,7 @@ class IndexConstraintView(PGChildNodeView): @staticmethod def _check_required_args(data): required_args = [ - [u'columns', u'index'] # Either of one should be there. + ['columns', 'index'] # Either of one should be there. ] def is_key_list(key, data): @@ -878,7 +878,7 @@ class IndexConstraintView(PGChildNodeView): data=data, constraint_name=self.constraint_name) - sql_header = u"-- Constraint: {0}\n\n-- ".format(data['name']) + sql_header = "-- Constraint: {0}\n\n-- ".format(data['name']) sql_header += render_template( "/".join([self.template_path, self._DELETE_SQL]), diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/utils.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/utils.py index 3f3ceff47..39c1d2d8b 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/utils.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/utils.py @@ -235,7 +235,7 @@ def _check_required_args(data, name): :return: If any error return error. """ required_args = [ - [u'columns', u'index'] # Either of one should be there. + ['columns', 'index'] # Either of one should be there. ] def is_key_list(key, data): diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/utils.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/utils.py index d67f11d4d..87c0fd7b2 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/utils.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/utils.py @@ -311,7 +311,7 @@ def get_reverse_engineered_sql(conn, **kwargs): datlastsysoid=datlastsysoid) if with_header: - sql_header = u"-- Index: {0}\n\n-- ".format(data['name']) + sql_header = "-- Index: {0}\n\n-- ".format(data['name']) sql_header += render_template("/".join([template_path, 'delete.sql']), data=data, conn=conn) diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/utils.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/utils.py index 8cfaa3906..2375ef9f0 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/utils.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/utils.py @@ -133,7 +133,7 @@ def get_reverse_engineered_sql(conn, **kwargs): datlastsysoid=datlastsysoid, schema=schema, table=table) if with_header: - sql_header = u"-- POLICY: {0}\n\n-- ".format(data['name']) + sql_header = "-- POLICY: {0}\n\n-- ".format(data['name']) sql_header += render_template("/".join([template_path, 'delete.sql']), diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_tables_properties_sql.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_tables_properties_sql.py index 7fe3aabc0..1be5d9cdc 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_tables_properties_sql.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_tables_properties_sql.py @@ -52,7 +52,7 @@ class TestTablesPropertiesSql(SQLTemplateTestBase): return sql def test_setup(self, connection, cursor): - cursor.execute(u""" + cursor.execute(""" SELECT db.oid as did, datlastsysoid FROM diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/utils.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/utils.py index 0db7e433b..452551e55 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/utils.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/utils.py @@ -292,7 +292,7 @@ def get_reverse_engineered_sql(conn, **kwargs): show_system_objects=show_system_objects) if with_header: - sql_header = u"-- Trigger: {0}\n\n-- ".format(data['name']) + sql_header = "-- Trigger: {0}\n\n-- ".format(data['name']) sql_header += render_template("/".join([template_path, 'delete.sql']), data=data, conn=conn) diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/utils.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/utils.py index 647a7ba5c..bf3344afa 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/utils.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/utils.py @@ -467,7 +467,7 @@ class BaseTableView(PGChildNodeView, BasePartitionTable): self._format_column_list(data) if json_resp: - sql_header = u"-- Table: {0}.{1}\n\n-- ".format( + sql_header = "-- Table: {0}.{1}\n\n-- ".format( data['schema'], data['name']) sql_header += render_template("/".join([self.table_template_path, @@ -520,7 +520,7 @@ class BaseTableView(PGChildNodeView, BasePartitionTable): self.conn, schema=schema, table=table, did=did, tid=tid, idx=row['oid'], datlastsysoid=self.datlastsysoid, template_path=None, with_header=json_resp) - index_sql = u"\n" + index_sql + index_sql = "\n" + index_sql # Add into main sql index_sql = re.sub('\n{2,}', '\n\n', index_sql) @@ -549,7 +549,7 @@ class BaseTableView(PGChildNodeView, BasePartitionTable): self.conn, schema=schema, table=table, scid=scid, plid=row['oid'], datlastsysoid=self.datlastsysoid, template_path=None, with_header=json_resp) - policy_sql = u"\n" + policy_sql + policy_sql = "\n" + policy_sql # Add into main sql policy_sql = re.sub('\n{2,}', '\n\n', policy_sql) @@ -575,7 +575,7 @@ class BaseTableView(PGChildNodeView, BasePartitionTable): trid=row['oid'], datlastsysoid=self.datlastsysoid, show_system_objects=self.blueprint.show_system_objects, template_path=None, with_header=json_resp) - trigger_sql = u"\n" + trigger_sql + trigger_sql = "\n" + trigger_sql # Add into main sql trigger_sql = re.sub('\n{2,}', '\n\n', trigger_sql) @@ -603,7 +603,7 @@ class BaseTableView(PGChildNodeView, BasePartitionTable): compound_trigger_utils.get_reverse_engineered_sql( self.conn, schema=schema, table=table, tid=tid, trid=row['oid'], datlastsysoid=self.datlastsysoid) - compound_trigger_sql = u"\n" + compound_trigger_sql + compound_trigger_sql = "\n" + compound_trigger_sql # Add into main sql compound_trigger_sql = \ @@ -661,7 +661,7 @@ class BaseTableView(PGChildNodeView, BasePartitionTable): sql_header = '' if len(rset['rows']): if json_resp: - sql_header = u"\n-- Partitions SQL" + sql_header = "\n-- Partitions SQL" partition_sql = '' for row in rset['rows']: part_data = dict() diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/__init__.py index f95355d39..8dc2384e8 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/__init__.py @@ -1424,7 +1424,7 @@ class TypeView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare): if not isinstance(SQL, str): return SQL # We are appending headers here for sql panel - sql_header = u"-- Type: {0}\n\n-- ".format(data['name']) + sql_header = "-- Type: {0}\n\n-- ".format(data['name']) sql_header += render_template("/".join([self.template_path, self._DELETE_SQL]), diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py index 589812923..fa2198cc1 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py @@ -1569,7 +1569,7 @@ class ViewNode(PGChildNodeView, VacuumSettings, SchemaDiffObjectCompare): else: columns = '*' - sql = u"SELECT {0}\n\tFROM {1};".format( + sql = "SELECT {0}\n\tFROM {1};".format( columns, self.qtIdent(self.conn, data_view['schema'], data_view['name']) ) @@ -1629,7 +1629,7 @@ class ViewNode(PGChildNodeView, VacuumSettings, SchemaDiffObjectCompare): if len(columns) > 0: columns = ", ".join(columns) values = ", ".join(values) - sql = u"INSERT INTO {0}(\n\t{1})\n\tVALUES ({2});".format( + sql = "INSERT INTO {0}(\n\t{1})\n\tVALUES ({2});".format( self.qtIdent( self.conn, data_view['schema'], data_view['name'] ), diff --git a/web/pgadmin/browser/server_groups/servers/pgagent/__init__.py b/web/pgadmin/browser/server_groups/servers/pgagent/__init__.py index 4c9550332..be175cda3 100644 --- a/web/pgadmin/browser/server_groups/servers/pgagent/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/pgagent/__init__.py @@ -271,7 +271,7 @@ SELECT EXISTS( def create(self, gid, sid): """Create the pgAgent job.""" required_args = [ - u'jobname' + 'jobname' ] data = request.form if request.form else json.loads( diff --git a/web/pgadmin/browser/server_groups/servers/roles/__init__.py b/web/pgadmin/browser/server_groups/servers/roles/__init__.py index e2f7aa935..c68728430 100644 --- a/web/pgadmin/browser/server_groups/servers/roles/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/roles/__init__.py @@ -145,10 +145,10 @@ class RoleView(PGChildNodeView): if not isinstance(data, dict): return False - for op in [u'added', u'deleted', u'changed']: + for op in ['added', 'deleted', 'changed']: op_data = data.get(op, []) check_keys = req_add_keys \ - if op in [u'added', u'changed'] else req_delete_keys + if op in ['added', 'changed'] else req_delete_keys if not self._validate_input_dict_for_new(op_data, check_keys): return False @@ -160,15 +160,15 @@ class RoleView(PGChildNodeView): :param data: role data :return: valid or invalid message """ - if u'rolvaliduntil' in data: + if 'rolvaliduntil' in data: # Make date explicit so that it works with every # postgres database datestyle format try: - if data[u'rolvaliduntil'] is not None and \ - data[u'rolvaliduntil'] != '' and \ - len(data[u'rolvaliduntil']) > 0: - data[u'rolvaliduntil'] = dateutil_parser.parse( - data[u'rolvaliduntil'] + if data['rolvaliduntil'] is not None and \ + data['rolvaliduntil'] != '' and \ + len(data['rolvaliduntil']) > 0: + data['rolvaliduntil'] = dateutil_parser.parse( + data['rolvaliduntil'] ).isoformat() except Exception: return _("Date format is invalid.") @@ -181,15 +181,15 @@ class RoleView(PGChildNodeView): :param data: role data :return: valid or invalid message """ - if u'rolconnlimit' in data: + if 'rolconnlimit' in data: # If roleconnlimit is empty string then set it to -1 - if data[u'rolconnlimit'] == '': - data[u'rolconnlimit'] = -1 + if data['rolconnlimit'] == '': + data['rolconnlimit'] = -1 - if data[u'rolconnlimit'] is not None: - data[u'rolconnlimit'] = int(data[u'rolconnlimit']) - if not isinstance(data[u'rolconnlimit'], int) or \ - data[u'rolconnlimit'] < -1: + if data['rolconnlimit'] is not None: + data['rolconnlimit'] = int(data['rolconnlimit']) + if not isinstance(data['rolconnlimit'], int) or \ + data['rolconnlimit'] < -1: return _("Connection limit must be an integer value " "or equal to -1.") return None @@ -209,31 +209,31 @@ class RoleView(PGChildNodeView): return ret_val if id == -1: - data[u'members'] = [] - data[u'admins'] = [] + data['members'] = [] + data['admins'] = [] - data[u'admins'] = _part_dict_list( - data[u'rolmembership'], lambda d: d[u'admin'], u'role') - data[u'members'] = _part_dict_list( - data[u'rolmembership'], lambda d: not d[u'admin'], u'role') + data['admins'] = _part_dict_list( + data['rolmembership'], lambda d: d['admin'], 'role') + data['members'] = _part_dict_list( + data['rolmembership'], lambda d: not d['admin'], 'role') else: - data[u'admins'] = _part_dict_list( - data[u'rolmembership'].get(u'added', []), - lambda d: d[u'admin'], u'role') - data[u'members'] = _part_dict_list( - data[u'rolmembership'].get(u'added', []), - lambda d: not d[u'admin'], u'role') - - data[u'admins'].extend(_part_dict_list( - data[u'rolmembership'].get(u'changed', []), - lambda d: d[u'admin'], u'role')) - data[u'revoked_admins'] = _part_dict_list( - data[u'rolmembership'].get(u'changed', []), - lambda d: not d[u'admin'], u'role') - - data[u'revoked'] = _part_dict_list( - data[u'rolmembership'].get(u'deleted', []), - lambda _: True, u'role') + data['admins'] = _part_dict_list( + data['rolmembership'].get('added', []), + lambda d: d['admin'], 'role') + data['members'] = _part_dict_list( + data['rolmembership'].get('added', []), + lambda d: not d['admin'], 'role') + + data['admins'].extend(_part_dict_list( + data['rolmembership'].get('changed', []), + lambda d: d['admin'], 'role')) + data['revoked_admins'] = _part_dict_list( + data['rolmembership'].get('changed', []), + lambda d: not d['admin'], 'role') + + data['revoked'] = _part_dict_list( + data['rolmembership'].get('deleted', []), + lambda _: True, 'role') def _validate_rolemembership(self, id, data): """ @@ -241,7 +241,7 @@ class RoleView(PGChildNodeView): :param data: role data :return: valid or invalid message """ - if u'rolmembership' not in data: + if 'rolmembership' not in data: return None if id == -1: @@ -257,7 +257,7 @@ rolmembership:[{ ]""") if not self._validate_input_dict_for_new( - data[u'rolmembership'], [u'role', u'admin']): + data['rolmembership'], ['role', 'admin']): return msg self._process_rolemembership(id, data) @@ -287,7 +287,7 @@ rolmembership:{ ] """) if not self._validate_input_dict_for_update( - data[u'rolmembership'], [u'role', u'admin'], [u'role']): + data['rolmembership'], ['role', 'admin'], ['role']): return msg self._process_rolemembership(id, data) @@ -299,7 +299,7 @@ rolmembership:{ :param data: role data :return: valid or invalid message """ - if u'seclabels' not in data or self.manager.version < 90200: + if 'seclabels' not in data or self.manager.version < 90200: return None if id == -1: @@ -313,7 +313,7 @@ seclabels:[{ ... ]""") if not self._validate_input_dict_for_new( - data[u'seclabels'], [u'provider', u'label']): + data['seclabels'], ['provider', 'label']): return msg return None @@ -342,7 +342,7 @@ seclabels:{ ] """) if not self._validate_input_dict_for_update( - data[u'seclabels'], [u'provider', u'label'], [u'provider']): + data['seclabels'], ['provider', 'label'], ['provider']): return msg return None @@ -353,7 +353,7 @@ seclabels:{ :param data: role data :return: valid or invalid message """ - if u'variables' not in data: + if 'variables' not in data: return None if id == -1: @@ -368,7 +368,7 @@ value: ... ]""") if not self._validate_input_dict_for_new( - data[u'variables'], [u'name', u'value']): + data['variables'], ['name', 'value']): return msg return None @@ -400,7 +400,7 @@ rolmembership:{ ] """) if not self._validate_input_dict_for_update( - data[u'variables'], [u'name', u'value'], [u'name']): + data['variables'], ['name', 'value'], ['name']): return msg return None @@ -410,7 +410,7 @@ rolmembership:{ :param data: role data :return: valid or invalid message """ - if (id == -1) and u'rolname' not in data: + if (id == -1) and 'rolname' not in data: return precondition_required( _("Name must be specified.") ) @@ -429,10 +429,10 @@ rolmembership:{ val = req[key] if key in [ - u'rolcanlogin', u'rolsuper', u'rolcreatedb', - u'rolcreaterole', u'rolinherit', u'rolreplication', - u'rolcatupdate', u'variables', u'rolmembership', - u'seclabels' + 'rolcanlogin', 'rolsuper', 'rolcreatedb', + 'rolcreaterole', 'rolinherit', 'rolreplication', + 'rolcatupdate', 'variables', 'rolmembership', + 'seclabels' ]: data[key] = json.loads(val, encoding='utf-8') else: @@ -451,17 +451,17 @@ rolmembership:{ return precondition_required(invalid_msg) invalid_msg = self._validate_rolemembership( - kwargs.get(u'rid', -1), data) + kwargs.get('rid', -1), data) if invalid_msg is not None: return precondition_required(invalid_msg) invalid_msg = self._validate_seclabels( - kwargs.get(u'rid', -1), data) + kwargs.get('rid', -1), data) if invalid_msg is not None: return precondition_required(invalid_msg) invalid_msg = self._validate_variables( - kwargs.get(u'rid', -1), data) + kwargs.get('rid', -1), data) if invalid_msg is not None: return precondition_required(invalid_msg) @@ -581,13 +581,13 @@ rolmembership:{ self.sql_path = 'roles/sql/#{0}#'.format(self.manager.version) self.alterKeys = [ - u'rolcanlogin', u'rolsuper', u'rolcreatedb', - u'rolcreaterole', u'rolinherit', u'rolreplication', - u'rolconnlimit', u'rolvaliduntil', u'rolpassword' + 'rolcanlogin', 'rolsuper', 'rolcreatedb', + 'rolcreaterole', 'rolinherit', 'rolreplication', + 'rolconnlimit', 'rolvaliduntil', 'rolpassword' ] if self.manager.version >= 90200 else [ - u'rolcanlogin', u'rolsuper', u'rolcreatedb', - u'rolcreaterole', u'rolinherit', u'rolconnlimit', - u'rolvaliduntil', u'rolpassword' + 'rolcanlogin', 'rolsuper', 'rolcreatedb', + 'rolcreaterole', 'rolinherit', 'rolconnlimit', + 'rolvaliduntil', 'rolpassword' ] fetch_name, check_permission, \ @@ -781,7 +781,7 @@ rolmembership:{ row = res['rows'][0] status, res = self.conn.execute_2darray( - u"DROP ROLE {0};".format(self.qtIdent(self.conn, + "DROP ROLE {0};".format(self.qtIdent(self.conn, row['rolname'])) ) if not status: @@ -836,7 +836,7 @@ rolmembership:{ status, rid = self.conn.execute_scalar( "SELECT oid FROM pg_roles WHERE rolname = %(rolname)s", - {'rolname': self.request[u'rolname']} + {'rolname': self.request['rolname']} ) if not status: diff --git a/web/pgadmin/browser/server_groups/servers/tablespaces/__init__.py b/web/pgadmin/browser/server_groups/servers/tablespaces/__init__.py index cb384c350..83b5a8bc7 100644 --- a/web/pgadmin/browser/server_groups/servers/tablespaces/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/tablespaces/__init__.py @@ -578,7 +578,7 @@ class TablespaceView(PGChildNodeView): data=old_data, conn=self.conn ) - sql_header = u""" + sql_header = """ -- Tablespace: {0} -- DROP TABLESPACE {0}; diff --git a/web/pgadmin/misc/bgprocess/processes.py b/web/pgadmin/misc/bgprocess/processes.py index a635d2a68..c9d629271 100644 --- a/web/pgadmin/misc/bgprocess/processes.py +++ b/web/pgadmin/misc/bgprocess/processes.py @@ -208,26 +208,26 @@ class BatchProcess(object): ) executor = file_quote(os.path.join( - os.path.dirname(u_encode(__file__)), u'process_executor.py' + os.path.dirname(u_encode(__file__)), 'process_executor.py' )) paths = os.environ['PATH'].split(os.pathsep) interpreter = None current_app.logger.info( - u"Process Executor: Operating System Path %s", + "Process Executor: Operating System Path %s", str(paths) ) if os.name == 'nt': - paths.insert(0, os.path.join(u_encode(sys.prefix), u'Scripts')) + paths.insert(0, os.path.join(u_encode(sys.prefix), 'Scripts')) paths.insert(0, u_encode(sys.prefix)) - interpreter = which(u'pythonw.exe', paths) + interpreter = which('pythonw.exe', paths) if interpreter is None: - interpreter = which(u'python.exe', paths) + interpreter = which('python.exe', paths) current_app.logger.info( - u"Process Executor: Interpreter value in path: %s", + "Process Executor: Interpreter value in path: %s", str(interpreter) ) if interpreter is None and current_app.PGADMIN_RUNTIME: @@ -245,16 +245,16 @@ class BatchProcess(object): bin_path = os.path.dirname(sys.executable) venv = os.path.realpath( - os.path.join(bin_path, u'..\\venv') + os.path.join(bin_path, '..\\venv') ) - interpreter = which(u'pythonw.exe', [venv]) + interpreter = which('pythonw.exe', [venv]) if interpreter is None: - interpreter = which(u'python.exe', [venv]) + interpreter = which('python.exe', [venv]) current_app.logger.info( - u"Process Executor: Interpreter value in virtual " - u"environment: %s", str(interpreter) + "Process Executor: Interpreter value in virtual " + "environment: %s", str(interpreter) ) if interpreter is not None: @@ -272,7 +272,7 @@ class BatchProcess(object): # directory in the PATH environment variable. Hence - it will # anyway be the redundant value in paths. if not current_app.PGADMIN_RUNTIME: - paths.insert(0, os.path.join(u_encode(sys.prefix), u'bin')) + paths.insert(0, os.path.join(u_encode(sys.prefix), 'bin')) python_binary_name = 'python{0}'.format(sys.version_info[0]) interpreter = which(u_encode(python_binary_name), paths) @@ -284,7 +284,7 @@ class BatchProcess(object): cmd.extend(self.args) current_app.logger.info( - u"Executing the process executor with the arguments: %s", + "Executing the process executor with the arguments: %s", str(cmd) ) diff --git a/web/pgadmin/misc/file_manager/__init__.py b/web/pgadmin/misc/file_manager/__init__.py index b51f583d8..955f98073 100644 --- a/web/pgadmin/misc/file_manager/__init__.py +++ b/web/pgadmin/misc/file_manager/__init__.py @@ -392,9 +392,9 @@ class Filemanager(object): if last_dir is not None: check_dir_exists = True else: - last_dir = u"/" + last_dir = "/" - if not config.SERVER_MODE and last_dir == u"/" or last_dir == "/": + if not config.SERVER_MODE and last_dir == "/" or last_dir == "/": last_dir = homedir if check_dir_exists: @@ -412,14 +412,14 @@ class Filemanager(object): index = last_dir.rfind('/') last_dir = last_dir[0:index] if not last_dir: - last_dir = u"/" + last_dir = "/" if _platform == 'win32': if not (last_dir.endswith('\\') or last_dir.endswith('/')): - last_dir += u"\\" + last_dir += "\\" else: if not last_dir.endswith('/'): - last_dir += u"/" + last_dir += "/" # create configs using above configs configs = { @@ -516,13 +516,13 @@ class Filemanager(object): bitmask >>= 1 if (drive_name != '' and drive_name is not None and drive_name in drives): - return u"{0}{1}".format(drive_name, ':') + return "{0}{1}".format(drive_name, ':') else: return drives # return drives if no argument is passed except Exception: return ['C:'] else: - return u'/' + return '/' @staticmethod def suspend_windows_warning(): @@ -557,7 +557,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: {0}").format(e) files = { 'Code': 0, 'Error': err_msg @@ -570,7 +570,7 @@ class Filemanager(object): drives = Filemanager._get_drives() for drive in drives: protected = 0 - path = file_name = u"{0}:".format(drive) + path = file_name = "{0}:".format(drive) try: drive_size = getdrivesize(path) drive_size_in_units = sizeof_fmt(drive_size) @@ -597,7 +597,7 @@ class Filemanager(object): Filemanager.resume_windows_warning() return { 'Code': 0, - 'Error': gettext(u"'{0}' file does not exist.").format(path) + 'Error': gettext("'{0}' file does not exist.").format(path) } user_dir = path @@ -634,8 +634,8 @@ class Filemanager(object): if os.path.isdir(system_path): if files_only == 'true': continue - file_extension = u"dir" - user_path = u"{0}/".format(user_path) + file_extension = "dir" + user_path = "{0}/".format(user_path) else: # filter files based on file_type if file_type is not None and file_type != "*" and \ @@ -660,9 +660,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: {0}").format(e.strerror) else: - err_msg = gettext(u"Error: {0}").format(e) + err_msg = gettext("Error: {0}").format(e) files = { 'Code': 0, 'Error': err_msg @@ -694,7 +694,7 @@ class Filemanager(object): # in server mode. if not orig_path.startswith(in_dir): raise InternalServerError( - gettext(u"Access denied ({0})").format(path)) + gettext("Access denied ({0})").format(path)) return True @staticmethod @@ -702,30 +702,30 @@ class Filemanager(object): if (path.startswith('\\\\') and _platform == 'win32')\ or config.SERVER_MODE is False or in_dir is None: - return u"{}".format(path) + return "{}".format(path) if path == '/' or path == '\\': if _platform == 'win32': if in_dir.endswith('\\') or in_dir.endswith('/'): - return u"{}".format(in_dir) + return "{}".format(in_dir) else: - return u"{}{}".format(in_dir, '\\') + return "{}{}".format(in_dir, '\\') else: if in_dir.endswith('/'): - return u"{}".format(in_dir) + return "{}".format(in_dir) else: - return u"{}{}".format(in_dir, '/') + return "{}{}".format(in_dir, '/') if in_dir.endswith('/') or in_dir.endswith('\\'): if path.startswith('/') or path.startswith('\\'): - return u"{}{}".format(in_dir[:-1], path) + return "{}{}".format(in_dir[:-1], path) else: - return u"{}/{}".format(in_dir, path) + return "{}/{}".format(in_dir, path) else: if path.startswith('/') or path.startswith('\\'): - return u"{}{}".format(in_dir, path) + return "{}{}".format(in_dir, path) else: - return u"{}/{}".format(in_dir, path) + return "{}/{}".format(in_dir, path) def validate_request(self, capability): """ @@ -743,7 +743,7 @@ class Filemanager(object): path = unquote(path) if self.dir is None: self.dir = "" - orig_path = u"{0}{1}".format(self.dir, path) + orig_path = "{0}{1}".format(self.dir, path) try: Filemanager.check_access_permission(self.dir, path) @@ -752,7 +752,7 @@ class Filemanager(object): 'Filename': split_path(path)[-1], 'FileType': '', 'Path': path, - 'Error': gettext(u"Error: {0}").format(e), + 'Error': gettext("Error: {0}").format(e), 'Code': 0, 'Info': '', 'Properties': { @@ -784,7 +784,7 @@ class Filemanager(object): if not path_exists(orig_path): thefile['Error'] = gettext( - u"'{0}' file does not exist.").format(path) + "'{0}' file does not exist.").format(path) thefile['Code'] = -1 return thefile @@ -813,7 +813,7 @@ class Filemanager(object): if config.SERVER_MODE: the_dir = self.dir if the_dir is not None and not the_dir.endswith('/'): - the_dir += u'/' + the_dir += '/' filelist = self.list_filesystem( the_dir, path, trans_data, file_type, show_hidden) @@ -836,7 +836,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: {0}").format(e), 'Code': 0 } return res @@ -851,23 +851,23 @@ class Filemanager(object): path = split_path(path)[0] # extract path if not path[-1] == '/': - path += u'/' + path += '/' newname = new newpath = path + newname # make system old path - oldpath_sys = u"{0}{1}".format(the_dir, old) - newpath_sys = u"{0}{1}".format(the_dir, newpath) + oldpath_sys = "{0}{1}".format(the_dir, old) + newpath_sys = "{0}{1}".format(the_dir, newpath) - error_msg = gettext(u'Renamed successfully.') + error_msg = gettext('Renamed successfully.') code = 1 try: os.rename(oldpath_sys, newpath_sys) except Exception as e: code = 0 - error_msg = u"{0} {1}".format( - gettext(u'There was an error renaming the file:'), e) + error_msg = "{0} {1}".format( + gettext('There was an error renaming the file:'), e) result = { 'Old Path': old, @@ -891,13 +891,13 @@ class Filemanager(object): } the_dir = self.dir if self.dir is not None else '' - orig_path = u"{0}{1}".format(the_dir, path) + orig_path = "{0}{1}".format(the_dir, path) try: Filemanager.check_access_permission(the_dir, path) except Exception as e: res = { - 'Error': gettext(u"Error: {0}").format(e), + 'Error': gettext("Error: {0}").format(e), 'Code': 0 } return res @@ -911,7 +911,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: {0}").format(e.strerror) result = { 'Path': path, @@ -939,8 +939,8 @@ class Filemanager(object): file_obj = req.files['newfile'] file_name = file_obj.filename - orig_path = u"{0}{1}".format(the_dir, path) - new_name = u"{0}{1}".format(orig_path, file_name) + orig_path = "{0}{1}".format(the_dir, path) + new_name = "{0}{1}".format(orig_path, file_name) with open(new_name, 'wb') as f: while True: @@ -951,14 +951,14 @@ class Filemanager(object): f.write(data) except Exception as e: code = 0 - err_msg = gettext(u"Error: {0}").format( - e.strerror if hasattr(e, 'strerror') else gettext(u'Unknown')) + err_msg = gettext("Error: {0}").format( + e.strerror if hasattr(e, 'strerror') else gettext('Unknown')) try: Filemanager.check_access_permission(the_dir, path) except Exception as e: res = { - 'Error': gettext(u"Error: {0}").format(e), + 'Error': gettext("Error: {0}").format(e), 'Code': 0 } return res @@ -982,19 +982,19 @@ class Filemanager(object): name = unquote(name) path = unquote(path) try: - orig_path = u"{0}{1}".format(the_dir, path) + orig_path = "{0}{1}".format(the_dir, path) Filemanager.check_access_permission( - the_dir, u"{}{}".format(path, name)) + the_dir, "{}{}".format(path, name)) - new_name = u"{0}{1}".format(orig_path, name) + new_name = "{0}{1}".format(orig_path, name) if not os.path.exists(new_name): code = 0 except Exception as e: code = 0 if hasattr(e, 'strerror'): - err_msg = gettext(u"Error: {0}").format(e.strerror) + err_msg = gettext("Error: {0}").format(e.strerror) else: - err_msg = gettext(u"Error: {0}").format(e) + err_msg = gettext("Error: {0}").format(e) result = { 'Path': path, @@ -1012,12 +1012,12 @@ class Filemanager(object): with same name already exists """ last_char = new_name[-1] - t_new_path = u"{}/{}{}_{}".format(in_dir, path, new_name, count) + t_new_path = "{}/{}{}_{}".format(in_dir, path, new_name, count) if last_char == 'r' and not path_exists(t_new_path): return t_new_path, new_name else: last_char = int(t_new_path[-1]) + 1 - new_path = u"{}/{}{}_{}".format(in_dir, path, new_name, last_char) + new_path = "{}/{}{}_{}".format(in_dir, path, new_name, last_char) if path_exists(new_path): count += 1 return Filemanager.get_new_name(in_dir, path, new_name, count) @@ -1084,13 +1084,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: {0}").format(ex.strerror) else: - err_msg = gettext(u"Error: {0}").format(str(ex)) + err_msg = gettext("Error: {0}").format(str(ex)) except Exception as ex: status = False - err_msg = gettext(u"Error: {0}").format(str(ex)) + err_msg = gettext("Error: {0}").format(str(ex)) # Remove root storage path from error message # when running in Server mode @@ -1114,19 +1114,19 @@ class Filemanager(object): the_dir = self.dir if self.dir is not None else '' try: - Filemanager.check_access_permission(the_dir, u"{}{}".format( + Filemanager.check_access_permission(the_dir, "{}{}".format( path, name)) except Exception as e: res = { - 'Error': gettext(u"Error: {0}").format(e), + 'Error': gettext("Error: {0}").format(e), 'Code': 0 } return res if the_dir != "": - new_path = u"{}/{}{}/".format(the_dir, path, name) + new_path = "{}/{}{}/".format(the_dir, path, name) else: - new_path = u"{}{}/".format(path, name) + new_path = "{}{}/".format(path, name) err_msg = '' code = 1 @@ -1136,14 +1136,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: {0}").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: {0}").format(e.strerror) result = { 'Parent': path, @@ -1165,14 +1165,14 @@ class Filemanager(object): } the_dir = self.dir if self.dir is not None else '' - orig_path = u"{0}{1}".format(the_dir, path) + orig_path = "{0}{1}".format(the_dir, path) try: Filemanager.check_access_permission( - the_dir, u"{}{}".format(path, path) + the_dir, "{}{}".format(path, path) ) except Exception as e: - resp = Response(gettext(u"Error: {0}").format(e)) + resp = Response(gettext("Error: {0}").format(e)) resp.headers['Content-Disposition'] = \ 'attachment; filename=' + name return resp @@ -1189,7 +1189,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: {0}").format(e) res['Code'] = 0 res['Error'] = err_msg return res diff --git a/web/pgadmin/setup/db_upgrade.py b/web/pgadmin/setup/db_upgrade.py index b92591936..f09f50e95 100644 --- a/web/pgadmin/setup/db_upgrade.py +++ b/web/pgadmin/setup/db_upgrade.py @@ -20,6 +20,6 @@ def db_upgrade(app): migration_folder = os.path.join( os.path.dirname(os.path.realpath(u_encode(__file__, fs_encoding))), os.pardir, os.pardir, - u'migrations' + 'migrations' ) flask_migrate.upgrade(migration_folder) diff --git a/web/pgadmin/setup/user_info.py b/web/pgadmin/setup/user_info.py index b439ecbaa..ab38e567a 100644 --- a/web/pgadmin/setup/user_info.py +++ b/web/pgadmin/setup/user_info.py @@ -16,7 +16,7 @@ import getpass def user_info_desktop(): - print(u"NOTE: Configuring authentication for DESKTOP mode.") + print("NOTE: Configuring authentication for DESKTOP mode.") email = config.DESKTOP_USER p1 = ''.join([ random.choice(string.ascii_letters + string.digits) @@ -26,7 +26,7 @@ def user_info_desktop(): def user_info_server(): - print(u"NOTE: Configuring authentication for SERVER mode.\n") + print("NOTE: Configuring authentication for SERVER mode.\n") if all(value in os.environ for value in ['PGADMIN_SETUP_EMAIL', 'PGADMIN_SETUP_PASSWORD']): @@ -39,8 +39,8 @@ def user_info_server(): else: # Prompt the user for their default username and password. print( - u"Enter the email address and password to use for the initial " - u"pgAdmin user account:\n" + "Enter the email address and password to use for the initial " + "pgAdmin user account:\n" ) email_filter = re.compile( @@ -51,7 +51,7 @@ def user_info_server(): email = input("Email address: ") while email == '' or not email_filter.match(email): - print(u'Invalid email address. Please try again.') + print('Invalid email address. Please try again.') email = input("Email address: ") def pprompt(): @@ -60,11 +60,11 @@ def user_info_server(): p1, p2 = pprompt() while p1 != p2 or len(p1) < 6: if p1 != p2: - print(u'Passwords do not match. Please try again.') + print('Passwords do not match. Please try again.') else: print( - u'Password must be at least 6 characters. ' - u'Please try again.' + 'Password must be at least 6 characters. ' + 'Please try again.' ) p1, p2 = pprompt() diff --git a/web/pgadmin/tools/backup/__init__.py b/web/pgadmin/tools/backup/__init__.py index fd726342d..9f2b4ff07 100644 --- a/web/pgadmin/tools/backup/__init__.py +++ b/web/pgadmin/tools/backup/__init__.py @@ -248,7 +248,7 @@ def filename_with_file_manager_path(_file, create_file=True): # Set file manager directory from preference storage_dir = get_storage_directory() if storage_dir: - _file = os.path.join(storage_dir, _file.lstrip(u'/').lstrip(u'\\')) + _file = os.path.join(storage_dir, _file.lstrip('/').lstrip('\\')) elif not os.path.isabs(_file): _file = os.path.join(document_dir(), _file) diff --git a/web/pgadmin/tools/import_export/__init__.py b/web/pgadmin/tools/import_export/__init__.py index 2f2b76700..878fb1636 100644 --- a/web/pgadmin/tools/import_export/__init__.py +++ b/web/pgadmin/tools/import_export/__init__.py @@ -186,7 +186,7 @@ def filename_with_file_manager_path(_file, _present=False): storage_dir = get_storage_directory() if storage_dir: - _file = os.path.join(storage_dir, _file.lstrip(u'/').lstrip(u'\\')) + _file = os.path.join(storage_dir, _file.lstrip('/').lstrip('\\')) elif not os.path.isabs(_file): _file = os.path.join(document_dir(), _file) diff --git a/web/pgadmin/tools/restore/__init__.py b/web/pgadmin/tools/restore/__init__.py index 86ae75c4f..243f5f377 100644 --- a/web/pgadmin/tools/restore/__init__.py +++ b/web/pgadmin/tools/restore/__init__.py @@ -168,7 +168,7 @@ def filename_with_file_manager_path(_file): storage_dir = get_storage_directory() if storage_dir: - _file = os.path.join(storage_dir, _file.lstrip(u'/').lstrip(u'\\')) + _file = os.path.join(storage_dir, _file.lstrip('/').lstrip('\\')) elif not os.path.isabs(_file): _file = os.path.join(document_dir(), _file) diff --git a/web/pgadmin/tools/sqleditor/__init__.py b/web/pgadmin/tools/sqleditor/__init__.py index b96b98846..014192763 100644 --- a/web/pgadmin/tools/sqleditor/__init__.py +++ b/web/pgadmin/tools/sqleditor/__init__.py @@ -223,7 +223,7 @@ def start_view_data(trans_id): status, msg = default_conn.connect() if not status: return make_json_response( - data={'status': status, 'result': u"{}".format(msg)} + data={'status': status, 'result': "{}".format(msg)} ) if status and conn is not None and \ @@ -596,8 +596,8 @@ def fetch_pg_types(columns_info, trans_obj): if oids: status, res = default_conn.execute_dict( - u"SELECT oid, format_type(oid, NULL) AS typname FROM pg_type " - u"WHERE oid IN %s ORDER BY oid;", [tuple(oids)] + "SELECT oid, format_type(oid, NULL) AS typname FROM pg_type " + "WHERE oid IN %s ORDER BY oid;", [tuple(oids)] ) if not status: @@ -701,7 +701,7 @@ def save(trans_id): is_error, errmsg, conn = _check_and_connect(trans_obj) if is_error: return make_json_response( - data={'status': status, 'result': u"{}".format(errmsg)} + data={'status': status, 'result': "{}".format(errmsg)} ) status, res, query_results, _rowid = trans_obj.save( diff --git a/web/pgadmin/utils/__init__.py b/web/pgadmin/utils/__init__.py index 2da8bd0f1..0bc946ea9 100644 --- a/web/pgadmin/utils/__init__.py +++ b/web/pgadmin/utils/__init__.py @@ -235,7 +235,7 @@ else: return _path def document_dir(): - return os.path.realpath(os.path.expanduser(u'~/')) + return os.path.realpath(os.path.expanduser('~/')) def get_complete_file_path(file): @@ -257,7 +257,7 @@ def get_complete_file_path(file): if storage_dir: file = os.path.join( storage_dir, - file.lstrip(u'/').lstrip(u'\\') + file.lstrip('/').lstrip('\\') ) if IS_WIN: file = file.replace('\\', '/') @@ -273,8 +273,8 @@ def does_utility_exist(file): """ error_msg = None if not os.path.exists(file): - error_msg = gettext(u"'%s' file not found. Please correct the Binary" - u" Path in the Preferences dialog" % file) + error_msg = gettext("'%s' file not found. Please correct the Binary" + " Path in the Preferences dialog" % file) return error_msg diff --git a/web/pgadmin/utils/driver/psycopg2/__init__.py b/web/pgadmin/utils/driver/psycopg2/__init__.py index f957c96c8..2edbd64cd 100644 --- a/web/pgadmin/utils/driver/psycopg2/__init__.py +++ b/web/pgadmin/utils/driver/psycopg2/__init__.py @@ -306,20 +306,20 @@ class Driver(BaseDriver): return True # certain types should not be quoted even though it contains a space. # Evilness. - elif for_types and value[-2:] == u"[]": + elif for_types and value[-2:] == "[]": val_noarray = value[:-2] if for_types and val_noarray.lower() in [ - u'bit varying', - u'"char"', - u'character varying', - u'double precision', - u'timestamp without time zone', - u'timestamp with time zone', - u'time without time zone', - u'time with time zone', - u'"trigger"', - u'"unknown"' + 'bit varying', + '"char"', + 'character varying', + 'double precision', + 'timestamp without time zone', + 'timestamp with time zone', + 'time without time zone', + 'time with time zone', + '"trigger"', + '"unknown"' ]: return False @@ -328,12 +328,12 @@ class Driver(BaseDriver): (val_noarray.startswith('"') or val_noarray.endswith('"')): return False - if u'0' <= val_noarray[0] <= u'9': + if '0' <= val_noarray[0] <= '9': return True for c in val_noarray: - if (not (u'a' <= c <= u'z') and c != u'_' and - not (u'0' <= c <= u'9')): + if (not ('a' <= c <= 'z') and c != '_' and + not ('0' <= c <= '9')): return True # check string is keywaord or not diff --git a/web/pgadmin/utils/driver/psycopg2/connection.py b/web/pgadmin/utils/driver/psycopg2/connection.py index 49c87084d..9e9992563 100644 --- a/web/pgadmin/utils/driver/psycopg2/connection.py +++ b/web/pgadmin/utils/driver/psycopg2/connection.py @@ -312,9 +312,9 @@ class Connection(BaseConnection): else: msg = str(e) current_app.logger.info( - u"Failed to connect to the database server(#{server_id}) for " - u"connection ({conn_id}) with error message as below" - u":{msg}".format( + "Failed to connect to the database server(#{server_id}) for " + "connection ({conn_id}) with error message as below" + ":{msg}".format( server_id=self.manager.sid, conn_id=conn_id, msg=msg @@ -407,7 +407,7 @@ class Connection(BaseConnection): return False, status if manager.role: - status = _execute(cur, u"SET ROLE TO %s", [manager.role]) + status = _execute(cur, "SET ROLE TO %s", [manager.role]) if status is not None: self.conn.close() @@ -519,7 +519,7 @@ WHERE raise ConnectionLost( self.manager.sid, self.db, - None if self.conn_id[0:3] == u'DB:' else self.conn_id[5:] + None if self.conn_id[0:3] == 'DB:' else self.conn_id[5:] ) cur = getattr(g, "{0}#{1}".format( self.manager.sid, @@ -547,7 +547,7 @@ WHERE raise ConnectionLost( self.manager.sid, self.db, - None if self.conn_id[0:3] == u'DB:' else self.conn_id[5:] + None if self.conn_id[0:3] == 'DB:' else self.conn_id[5:] ) try: @@ -588,7 +588,7 @@ WHERE raise ConnectionLost( self.manager.sid, self.db, - None if self.conn_id[0:3] == u'DB:' + None if self.conn_id[0:3] == 'DB:' else self.conn_id[5:] ) @@ -667,8 +667,8 @@ WHERE current_app.logger.log( 25, - u"Execute (with server cursor) for server #{server_id} - " - u"{conn_id} (Query-id: {query_id}):\n{query}".format( + "Execute (with server cursor) for server #{server_id} - " + "{conn_id} (Query-id: {query_id}):\n{query}".format( server_id=self.manager.sid, conn_id=self.conn_id, query=query, @@ -683,10 +683,10 @@ WHERE cur.close() errmsg = self._formatted_exception_msg(pe, formatted_exception_msg) current_app.logger.error( - u"failed to execute query ((with server cursor) " - u"for the server #{server_id} - {conn_id} " - u"(query-id: {query_id}):\n" - u"error message:{errmsg}".format( + "failed to execute query ((with server cursor) " + "for the server #{server_id} - {conn_id} " + "(query-id: {query_id}):\n" + "error message:{errmsg}".format( server_id=self.manager.sid, conn_id=self.conn_id, errmsg=errmsg, @@ -805,8 +805,8 @@ WHERE current_app.logger.log( 25, - u"Execute (scalar) for server #{server_id} - {conn_id} (Query-id: " - u"{query_id}):\n{query}".format( + "Execute (scalar) for server #{server_id} - {conn_id} (Query-id: " + "{query_id}):\n{query}".format( server_id=self.manager.sid, conn_id=self.conn_id, query=query, @@ -826,13 +826,13 @@ WHERE raise ConnectionLost( self.manager.sid, self.db, - None if self.conn_id[0:3] == u'DB:' else self.conn_id[5:] + None if self.conn_id[0:3] == 'DB:' else self.conn_id[5:] ) errmsg = self._formatted_exception_msg(pe, formatted_exception_msg) current_app.logger.error( - u"Failed to execute query (execute_scalar) for the server " - u"#{server_id} - {conn_id} (Query-id: {query_id}):\n" - u"Error Message:{errmsg}".format( + "Failed to execute query (execute_scalar) for the server " + "#{server_id} - {conn_id} (Query-id: {query_id}):\n" + "Error Message:{errmsg}".format( server_id=self.manager.sid, conn_id=self.conn_id, errmsg=errmsg, @@ -878,9 +878,9 @@ WHERE dsn = self.conn.get_dsn_parameters() current_app.logger.log( 25, - u"Execute (async) by {pga_user} on {db_user}@{db_host}/{db_name} " - u"#{server_id} - {conn_id} (Query-id: " - u"{query_id}):\n{query}".format( + "Execute (async) by {pga_user} on {db_user}@{db_host}/{db_name} " + "#{server_id} - {conn_id} (Query-id: " + "{query_id}):\n{query}".format( pga_user=current_user.username, db_user=dsn['user'], db_host=dsn['host'], @@ -901,9 +901,9 @@ WHERE except psycopg2.Error as pe: errmsg = self._formatted_exception_msg(pe, formatted_exception_msg) current_app.logger.error( - u"Failed to execute query (execute_async) for the server " - u"#{server_id} - {conn_id}(Query-id: {query_id}):\n" - u"Error Message:{errmsg}".format( + "Failed to execute query (execute_async) for the server " + "#{server_id} - {conn_id}(Query-id: {query_id}):\n" + "Error Message:{errmsg}".format( server_id=self.manager.sid, conn_id=self.conn_id, errmsg=errmsg, @@ -918,7 +918,7 @@ WHERE raise ConnectionLost( self.manager.sid, self.db, - None if self.conn_id[0:3] == u'DB:' else self.conn_id[5:] + None if self.conn_id[0:3] == 'DB:' else self.conn_id[5:] ) return False, errmsg @@ -946,8 +946,8 @@ WHERE current_app.logger.log( 25, - u"Execute (void) for server #{server_id} - {conn_id} (Query-id: " - u"{query_id}):\n{query}".format( + "Execute (void) for server #{server_id} - {conn_id} (Query-id: " + "{query_id}):\n{query}".format( server_id=self.manager.sid, conn_id=self.conn_id, query=query, @@ -968,13 +968,13 @@ WHERE raise ConnectionLost( self.manager.sid, self.db, - None if self.conn_id[0:3] == u'DB:' else self.conn_id[5:] + None if self.conn_id[0:3] == 'DB:' else self.conn_id[5:] ) errmsg = self._formatted_exception_msg(pe, formatted_exception_msg) current_app.logger.error( - u"Failed to execute query (execute_void) for the server " - u"#{server_id} - {conn_id}(Query-id: {query_id}):\n" - u"Error Message:{errmsg}".format( + "Failed to execute query (execute_void) for the server " + "#{server_id} - {conn_id}(Query-id: {query_id}):\n" + "Error Message:{errmsg}".format( server_id=self.manager.sid, conn_id=self.conn_id, errmsg=errmsg, @@ -1015,7 +1015,7 @@ WHERE raise ConnectionLost( self.manager.sid, self.db, - None if self.conn_id[0:3] == u'DB:' else self.conn_id[5:] + None if self.conn_id[0:3] == 'DB:' else self.conn_id[5:] ) def execute_2darray(self, query, params=None, @@ -1029,8 +1029,8 @@ WHERE query_id = random.randint(1, 9999999) current_app.logger.log( 25, - u"Execute (2darray) for server #{server_id} - {conn_id} " - u"(Query-id: {query_id}):\n{query}".format( + "Execute (2darray) for server #{server_id} - {conn_id} " + "(Query-id: {query_id}):\n{query}".format( server_id=self.manager.sid, conn_id=self.conn_id, query=query, @@ -1049,9 +1049,9 @@ WHERE ) errmsg = self._formatted_exception_msg(pe, formatted_exception_msg) current_app.logger.error( - u"Failed to execute query (execute_2darray) for the server " - u"#{server_id} - {conn_id} (Query-id: {query_id}):\n" - u"Error Message:{errmsg}".format( + "Failed to execute query (execute_2darray) for the server " + "#{server_id} - {conn_id} (Query-id: {query_id}):\n" + "Error Message:{errmsg}".format( server_id=self.manager.sid, conn_id=self.conn_id, errmsg=errmsg, @@ -1082,8 +1082,8 @@ WHERE query_id = random.randint(1, 9999999) current_app.logger.log( 25, - u"Execute (dict) for server #{server_id} - {conn_id} (Query-id: " - u"{query_id}):\n{query}".format( + "Execute (dict) for server #{server_id} - {conn_id} (Query-id: " + "{query_id}):\n{query}".format( server_id=self.manager.sid, conn_id=self.conn_id, query=query, @@ -1103,13 +1103,13 @@ WHERE raise ConnectionLost( self.manager.sid, self.db, - None if self.conn_id[0:3] == u'DB:' else self.conn_id[5:] + None if self.conn_id[0:3] == 'DB:' else self.conn_id[5:] ) errmsg = self._formatted_exception_msg(pe, formatted_exception_msg) current_app.logger.error( - u"Failed to execute query (execute_dict) for the server " - u"#{server_id}- {conn_id} (Query-id: {query_id}):\n" - u"Error Message:{errmsg}".format( + "Failed to execute query (execute_dict) for the server " + "#{server_id}- {conn_id} (Query-id: {query_id}):\n" + "Error Message:{errmsg}".format( server_id=self.manager.sid, conn_id=self.conn_id, query_id=query_id, @@ -1626,12 +1626,12 @@ Failed to reset the connection to the server due to following error: # Do not append if error starts with `ERROR:` as most pg related # error starts with `ERROR:` - if not errmsg.startswith(u'ERROR:'): - errmsg = gettext(u'ERROR: ') + errmsg + u'\n\n' + if not errmsg.startswith('ERROR:'): + errmsg = gettext('ERROR: ') + errmsg + '\n\n' if exception_obj.diag.severity is not None \ and exception_obj.diag.message_primary is not None: - ex_diag_message = u"{0}: {1}".format( + ex_diag_message = "{0}: {1}".format( exception_obj.diag.severity, exception_obj.diag.message_primary ) @@ -1796,16 +1796,16 @@ Failed to reset the connection to the server due to following error: ) elif psycopg2.__libpq_version__ < 100000: current_app.logger.warning( - u"To encrypt passwords the required libpq version is " - u"greater than or equal to 100000. Current libpq version " - u"is {curr_ver}".format( + "To encrypt passwords the required libpq version is " + "greater than or equal to 100000. Current libpq version " + "is {curr_ver}".format( curr_ver=psycopg2.__libpq_version__ ) ) elif not hasattr(psycopg2.extensions, 'encrypt_password'): current_app.logger.warning( - u"The psycopg2.extensions module does not have the" - u"'encrypt_password' method." + "The psycopg2.extensions module does not have the" + "'encrypt_password' method." ) return enc_password diff --git a/web/pgadmin/utils/driver/psycopg2/generate_keywords.py b/web/pgadmin/utils/driver/psycopg2/generate_keywords.py index 357cc1800..d0ceb55c5 100644 --- a/web/pgadmin/utils/driver/psycopg2/generate_keywords.py +++ b/web/pgadmin/utils/driver/psycopg2/generate_keywords.py @@ -41,8 +41,8 @@ if __name__ == '__main__': pattern = re.compile(r'"([^"]+)",\s*[^,]*\s*,\s*(.*)$') keyword_types = [ - u'UNRESERVED_KEYWORD', u'COL_NAME_KEYWORD', - u'TYPE_FUNC_NAME_KEYWORD', u'RESERVED_KEYWORD' + 'UNRESERVED_KEYWORD', 'COL_NAME_KEYWORD', + 'TYPE_FUNC_NAME_KEYWORD', 'RESERVED_KEYWORD' ] for line in ins: @@ -54,7 +54,7 @@ if __name__ == '__main__': else: keywords_file.write(" ") keywords_file.write( - '"' + match.group(1) + u'": ' + + '"' + match.group(1) + '": ' + str(keyword_types.index(match.group(2))) ) idx += 1 diff --git a/web/pgadmin/utils/driver/psycopg2/server_manager.py b/web/pgadmin/utils/driver/psycopg2/server_manager.py index ea1d9efe1..c35a3726f 100644 --- a/web/pgadmin/utils/driver/psycopg2/server_manager.py +++ b/web/pgadmin/utils/driver/psycopg2/server_manager.py @@ -185,7 +185,7 @@ class ServerManager(object): elif did in self.db_info: database = self.db_info[did]['datname'] else: - maintenance_db_id = u'DB:{0}'.format(self.db) + maintenance_db_id = 'DB:{0}'.format(self.db) if maintenance_db_id in self.connections: conn = self.connections[maintenance_db_id] # try to connect maintenance db if not connected @@ -193,7 +193,7 @@ class ServerManager(object): conn.connect() if conn.connected(): - status, res = conn.execute_dict(u""" + status, res = conn.execute_dict(""" SELECT db.oid as did, db.datname, db.datallowconn, pg_encoding_to_char(db.encoding) AS serverencoding, @@ -223,8 +223,8 @@ WHERE db.oid = {0}""".format(did)) else: raise ConnectionLost(self.sid, None, None) - my_id = (u'CONN:{0}'.format(conn_id)) if conn_id is not None else \ - (u'DB:{0}'.format(database)) + my_id = ('CONN:{0}'.format(conn_id)) if conn_id is not None else \ + ('DB:{0}'.format(database)) self.pinged = datetime.datetime.now() @@ -373,9 +373,9 @@ WHERE db.oid = {0}""".format(did)) my_id = None if conn_id is not None: - my_id = u'CONN:{0}'.format(conn_id) + my_id = 'CONN:{0}'.format(conn_id) elif database is not None: - my_id = u'DB:{0}'.format(database) + my_id = 'DB:{0}'.format(database) if my_id is not None: if my_id in self.connections: diff --git a/web/pgadmin/utils/javascript/tests/test_javascript_bundler.py b/web/pgadmin/utils/javascript/tests/test_javascript_bundler.py index 5648e9cf1..9be9b20b0 100644 --- a/web/pgadmin/utils/javascript/tests/test_javascript_bundler.py +++ b/web/pgadmin/utils/javascript/tests/test_javascript_bundler.py @@ -54,7 +54,7 @@ class JavascriptBundlerTestCase(BaseTestGenerator): self.mockSubprocessCall.return_value = 0 self.mockOs.listdir.return_value = [ - u'history.js', u'reactComponents.js'] + 'history.js', 'reactComponents.js'] javascript_bundler.bundle() self.mockSubprocessCall.assert_called_once_with( @@ -100,7 +100,7 @@ class JavascriptBundlerTestCase(BaseTestGenerator): "mock exception behavior") self.mockOs.path.exists.return_value = True self.mockOs.listdir.return_value = [ - u'history.js', u'reactComponents.js'] + 'history.js', 'reactComponents.js'] javascript_bundler.bundle() self.mockSubprocessCall.assert_called_once_with( diff --git a/web/pgadmin/utils/preferences.py b/web/pgadmin/utils/preferences.py index 5495f019c..d4858ff0b 100644 --- a/web/pgadmin/utils/preferences.py +++ b/web/pgadmin/utils/preferences.py @@ -190,7 +190,7 @@ class _Preference(object): pid=self.pid ).filter_by(uid=current_user.id).first() - value = u"{}".format(value) + value = "{}".format(value) if pref is None: pref = UserPrefTable( uid=current_user.id, pid=self.pid, value=value diff --git a/web/pgadmin/utils/sqlautocomplete/autocomplete.py b/web/pgadmin/utils/sqlautocomplete/autocomplete.py index 1031330aa..848ae8595 100644 --- a/web/pgadmin/utils/sqlautocomplete/autocomplete.py +++ b/web/pgadmin/utils/sqlautocomplete/autocomplete.py @@ -466,7 +466,7 @@ class SQLAutoComplete(object): if sort_key: if display_meta and len(display_meta) > 50: # Truncate meta-text to 50 characters, if necessary - display_meta = display_meta[:47] + u'...' + display_meta = display_meta[:47] + '...' # Lexical order of items in the collection, used for # tiebreaking items with the same match group length and start diff --git a/web/pgadmin/utils/sqlautocomplete/parseutils/ctes.py b/web/pgadmin/utils/sqlautocomplete/parseutils/ctes.py index ec8838934..3d446d6a0 100644 --- a/web/pgadmin/utils/sqlautocomplete/parseutils/ctes.py +++ b/web/pgadmin/utils/sqlautocomplete/parseutils/ctes.py @@ -87,7 +87,7 @@ def extract_ctes(sql): idx = p.token_index(tok) + 1 # Collapse everything after the ctes into a remainder query - remainder = u''.join(str(tok) for tok in p.tokens[idx:]) + remainder = ''.join(str(tok) for tok in p.tokens[idx:]) return ctes, remainder diff --git a/web/setup.py b/web/setup.py index 14bd5f9cc..9a78f1b59 100644 --- a/web/setup.py +++ b/web/setup.py @@ -362,8 +362,8 @@ def setup_db(): app = create_app() - print(u"pgAdmin 4 - Application Initialisation") - print(u"======================================\n") + print("pgAdmin 4 - Application Initialisation") + print("======================================\n") with app.app_context(): # Run migration for the first time i.e. create database -- 2.28.0