mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Remove Python2 references from the source code.
refs #5443 Initial patch: Neel Patel
This commit is contained in:
parent
7dd00a1494
commit
ad80217593
@ -1,11 +1,7 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import inspect
|
import inspect
|
||||||
|
import builtins
|
||||||
if sys.version_info[0] >= 3:
|
|
||||||
import builtins
|
|
||||||
else:
|
|
||||||
import __builtin__ as builtins
|
|
||||||
|
|
||||||
# Ensure the global server mode is set.
|
# Ensure the global server mode is set.
|
||||||
builtins.SERVER_MODE = None
|
builtins.SERVER_MODE = None
|
||||||
|
@ -14,11 +14,7 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import builtins
|
||||||
if sys.version_info[0] >= 3:
|
|
||||||
import builtins
|
|
||||||
else:
|
|
||||||
import __builtin__ as builtins
|
|
||||||
|
|
||||||
# Ensure the global server mode is set.
|
# Ensure the global server mode is set.
|
||||||
builtins.SERVER_MODE = None
|
builtins.SERVER_MODE = None
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
To generate a pgAdmin 4 installer for Windows bit, the following packages must be installed:
|
To generate a pgAdmin 4 installer for Windows bit, the following packages must be installed:
|
||||||
|
|
||||||
1. Python installation
|
1. Python installation
|
||||||
- Python 2.7 or 3.4+ or above from https://www.python.org/
|
- Python 3.4+ or above from https://www.python.org/
|
||||||
|
|
||||||
2. QT installation
|
2. QT installation
|
||||||
- Qt 4.6 through 5.5 from http://www.qt.io/
|
- Qt 4.6 through 5.5 from http://www.qt.io/
|
||||||
@ -21,8 +21,8 @@ Building: Depending upon the archicture of the OS(x86|amd64) set then environmen
|
|||||||
|
|
||||||
1. Set the PYTHON environment variable to the Python root installation directory, e.g. for x86
|
1. Set the PYTHON environment variable to the Python root installation directory, e.g. for x86
|
||||||
|
|
||||||
SET "PYTHON_HOME=C:\Python27"
|
SET "PYTHON_HOME=C:\Python38"
|
||||||
SET "PYTHON_DLL=C:\Windows\System32\python27.dll"
|
SET "PYTHON_DLL=C:\Windows\System32\python38.dll"
|
||||||
|
|
||||||
2. Set the QTDIR environment variable to the QT root installation directory, e.g. for x86
|
2. Set the QTDIR environment variable to the QT root installation directory, e.g. for x86
|
||||||
|
|
||||||
|
@ -52,10 +52,7 @@ def get_python_deps():
|
|||||||
"/../requirements.txt")
|
"/../requirements.txt")
|
||||||
|
|
||||||
with open(req_file, 'r') as req_file_p:
|
with open(req_file, 'r') as req_file_p:
|
||||||
if sys.version_info[0] >= 3:
|
required = req_file_p.read().splitlines()
|
||||||
required = req_file_p.read().splitlines()
|
|
||||||
else:
|
|
||||||
required = req_file_p.read().decode("utf-8").splitlines()
|
|
||||||
|
|
||||||
# Get the package info from the requirements file
|
# Get the package info from the requirements file
|
||||||
requirements = pkg_resources.parse_requirements(required)
|
requirements = pkg_resources.parse_requirements(required)
|
||||||
|
@ -9,16 +9,12 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import builtins
|
||||||
|
|
||||||
root = os.path.dirname(os.path.realpath(__file__))
|
root = os.path.dirname(os.path.realpath(__file__))
|
||||||
if sys.path[0] != root:
|
if sys.path[0] != root:
|
||||||
sys.path.insert(0, root)
|
sys.path.insert(0, root)
|
||||||
|
|
||||||
if sys.version_info[0] >= 3:
|
|
||||||
import builtins
|
|
||||||
else:
|
|
||||||
import __builtin__ as builtins
|
|
||||||
|
|
||||||
# Ensure the global server mode is set.
|
# Ensure the global server mode is set.
|
||||||
builtins.SERVER_MODE = True
|
builtins.SERVER_MODE = True
|
||||||
|
|
||||||
|
@ -43,12 +43,9 @@ from pgadmin import authenticate
|
|||||||
# If script is running under python3, it will not have the xrange function
|
# If script is running under python3, it will not have the xrange function
|
||||||
# defined
|
# defined
|
||||||
winreg = None
|
winreg = None
|
||||||
if sys.version_info[0] >= 3:
|
xrange = range
|
||||||
xrange = range
|
if os.name == 'nt':
|
||||||
if os.name == 'nt':
|
import winreg
|
||||||
import winreg
|
|
||||||
elif os.name == 'nt':
|
|
||||||
import _winreg as winreg
|
|
||||||
|
|
||||||
|
|
||||||
class PgAdmin(Flask):
|
class PgAdmin(Flask):
|
||||||
|
@ -21,10 +21,6 @@ from pgadmin.utils.ajax import make_json_response, internal_server_error, \
|
|||||||
make_response as ajax_response, gone
|
make_response as ajax_response, gone
|
||||||
from pgadmin.utils.driver import get_driver
|
from pgadmin.utils.driver import get_driver
|
||||||
from config import PG_DEFAULT_DRIVER
|
from config import PG_DEFAULT_DRIVER
|
||||||
from pgadmin.utils import IS_PY2
|
|
||||||
# If we are in Python3
|
|
||||||
if not IS_PY2:
|
|
||||||
unicode = str
|
|
||||||
|
|
||||||
|
|
||||||
class CastModule(CollectionNodeModule):
|
class CastModule(CollectionNodeModule):
|
||||||
@ -424,7 +420,7 @@ class CastView(PGChildNodeView):
|
|||||||
try:
|
try:
|
||||||
sql, name = self.get_sql(gid, sid, did, data, cid)
|
sql, name = self.get_sql(gid, sid, did, data, cid)
|
||||||
# Most probably this is due to error
|
# Most probably this is due to error
|
||||||
if not isinstance(sql, (str, unicode)):
|
if not isinstance(sql, str):
|
||||||
return sql
|
return sql
|
||||||
status, res = self.conn.execute_scalar(sql)
|
status, res = self.conn.execute_scalar(sql)
|
||||||
if not status:
|
if not status:
|
||||||
@ -521,7 +517,7 @@ class CastView(PGChildNodeView):
|
|||||||
data = request.args
|
data = request.args
|
||||||
sql, name = self.get_sql(gid, sid, did, data, cid)
|
sql, name = self.get_sql(gid, sid, did, data, cid)
|
||||||
# Most probably this is due to error
|
# Most probably this is due to error
|
||||||
if not isinstance(sql, (str, unicode)):
|
if not isinstance(sql, str):
|
||||||
return sql
|
return sql
|
||||||
sql = sql.strip('\n').strip(' ')
|
sql = sql.strip('\n').strip(' ')
|
||||||
if sql == '':
|
if sql == '':
|
||||||
|
@ -20,10 +20,6 @@ from pgadmin.utils.ajax import make_json_response, internal_server_error, \
|
|||||||
make_response as ajax_response, gone
|
make_response as ajax_response, gone
|
||||||
from pgadmin.utils.driver import get_driver
|
from pgadmin.utils.driver import get_driver
|
||||||
from config import PG_DEFAULT_DRIVER
|
from config import PG_DEFAULT_DRIVER
|
||||||
from pgadmin.utils import IS_PY2
|
|
||||||
# If we are in Python3
|
|
||||||
if not IS_PY2:
|
|
||||||
unicode = str
|
|
||||||
|
|
||||||
|
|
||||||
class EventTriggerModule(CollectionNodeModule):
|
class EventTriggerModule(CollectionNodeModule):
|
||||||
@ -446,7 +442,7 @@ class EventTriggerView(PGChildNodeView):
|
|||||||
try:
|
try:
|
||||||
sql = self.get_sql(data, etid)
|
sql = self.get_sql(data, etid)
|
||||||
# Most probably this is due to error
|
# Most probably this is due to error
|
||||||
if not isinstance(sql, (str, unicode)):
|
if not isinstance(sql, str):
|
||||||
return sql
|
return sql
|
||||||
sql = sql.strip('\n').strip(' ')
|
sql = sql.strip('\n').strip(' ')
|
||||||
if sql != "":
|
if sql != "":
|
||||||
@ -573,7 +569,7 @@ class EventTriggerView(PGChildNodeView):
|
|||||||
try:
|
try:
|
||||||
sql = self.get_sql(data, etid)
|
sql = self.get_sql(data, etid)
|
||||||
# Most probably this is due to error
|
# Most probably this is due to error
|
||||||
if not isinstance(sql, (str, unicode)):
|
if not isinstance(sql, str):
|
||||||
return sql
|
return sql
|
||||||
sql = sql.strip('\n').strip(' ')
|
sql = sql.strip('\n').strip(' ')
|
||||||
sql = re.sub('\n{2,}', '\n\n', sql)
|
sql = re.sub('\n{2,}', '\n\n', sql)
|
||||||
|
@ -22,27 +22,6 @@ from pgadmin.utils.ajax import make_json_response, \
|
|||||||
from pgadmin.utils.driver import get_driver
|
from pgadmin.utils.driver import get_driver
|
||||||
from config import PG_DEFAULT_DRIVER
|
from config import PG_DEFAULT_DRIVER
|
||||||
|
|
||||||
# As unicode type is not available in python3
|
|
||||||
# If we check a variable is "isinstance(variable, str)
|
|
||||||
# it breaks in python 3 as variable type is not string its unicode.
|
|
||||||
# We assign basestring as str type if it is python3, unicode
|
|
||||||
# if it is python2.
|
|
||||||
|
|
||||||
try:
|
|
||||||
unicode = unicode
|
|
||||||
except NameError:
|
|
||||||
# 'unicode' is undefined, must be Python 3
|
|
||||||
str = str
|
|
||||||
unicode = str
|
|
||||||
bytes = bytes
|
|
||||||
basestring = (str, bytes)
|
|
||||||
else:
|
|
||||||
# 'unicode' exists, must be Python 2
|
|
||||||
str = str
|
|
||||||
unicode = unicode
|
|
||||||
bytes = str
|
|
||||||
basestring = basestring
|
|
||||||
|
|
||||||
|
|
||||||
class ExtensionModule(CollectionNodeModule):
|
class ExtensionModule(CollectionNodeModule):
|
||||||
"""
|
"""
|
||||||
@ -315,7 +294,7 @@ class ExtensionView(PGChildNodeView):
|
|||||||
try:
|
try:
|
||||||
SQL, name = self.getSQL(gid, sid, data, did, eid)
|
SQL, name = self.getSQL(gid, sid, data, did, eid)
|
||||||
# Most probably this is due to error
|
# Most probably this is due to error
|
||||||
if not isinstance(SQL, (str, unicode)):
|
if not isinstance(SQL, str):
|
||||||
return SQL
|
return SQL
|
||||||
SQL = SQL.strip('\n').strip(' ')
|
SQL = SQL.strip('\n').strip(' ')
|
||||||
status, res = self.conn.execute_dict(SQL)
|
status, res = self.conn.execute_dict(SQL)
|
||||||
@ -393,7 +372,7 @@ class ExtensionView(PGChildNodeView):
|
|||||||
try:
|
try:
|
||||||
SQL, name = self.getSQL(gid, sid, data, did, eid)
|
SQL, name = self.getSQL(gid, sid, data, did, eid)
|
||||||
# Most probably this is due to error
|
# Most probably this is due to error
|
||||||
if not isinstance(SQL, (str, unicode)):
|
if not isinstance(SQL, str):
|
||||||
return SQL
|
return SQL
|
||||||
SQL = SQL.strip('\n').strip(' ')
|
SQL = SQL.strip('\n').strip(' ')
|
||||||
if SQL == '':
|
if SQL == '':
|
||||||
|
@ -23,10 +23,6 @@ from pgadmin.utils.ajax import make_json_response, internal_server_error, \
|
|||||||
make_response as ajax_response, gone
|
make_response as ajax_response, gone
|
||||||
from pgadmin.utils.driver import get_driver
|
from pgadmin.utils.driver import get_driver
|
||||||
from config import PG_DEFAULT_DRIVER
|
from config import PG_DEFAULT_DRIVER
|
||||||
from pgadmin.utils import IS_PY2
|
|
||||||
# If we are in Python3
|
|
||||||
if not IS_PY2:
|
|
||||||
unicode = str
|
|
||||||
|
|
||||||
|
|
||||||
class ForeignDataWrapperModule(CollectionNodeModule):
|
class ForeignDataWrapperModule(CollectionNodeModule):
|
||||||
@ -467,7 +463,7 @@ class ForeignDataWrapperView(PGChildNodeView):
|
|||||||
try:
|
try:
|
||||||
sql, name = self.get_sql(gid, sid, data, did, fid)
|
sql, name = self.get_sql(gid, sid, data, did, fid)
|
||||||
# Most probably this is due to error
|
# Most probably this is due to error
|
||||||
if not isinstance(sql, (str, unicode)):
|
if not isinstance(sql, str):
|
||||||
return sql
|
return sql
|
||||||
status, res = self.conn.execute_scalar(sql)
|
status, res = self.conn.execute_scalar(sql)
|
||||||
if not status:
|
if not status:
|
||||||
@ -575,7 +571,7 @@ class ForeignDataWrapperView(PGChildNodeView):
|
|||||||
try:
|
try:
|
||||||
sql, name = self.get_sql(gid, sid, data, did, fid)
|
sql, name = self.get_sql(gid, sid, data, did, fid)
|
||||||
# Most probably this is due to error
|
# Most probably this is due to error
|
||||||
if not isinstance(sql, (str, unicode)):
|
if not isinstance(sql, str):
|
||||||
return sql
|
return sql
|
||||||
if sql == '':
|
if sql == '':
|
||||||
sql = "--modified SQL"
|
sql = "--modified SQL"
|
||||||
|
@ -23,10 +23,6 @@ from pgadmin.utils.ajax import make_json_response, internal_server_error, \
|
|||||||
make_response as ajax_response, gone
|
make_response as ajax_response, gone
|
||||||
from pgadmin.utils.driver import get_driver
|
from pgadmin.utils.driver import get_driver
|
||||||
from config import PG_DEFAULT_DRIVER
|
from config import PG_DEFAULT_DRIVER
|
||||||
from pgadmin.utils import IS_PY2
|
|
||||||
# If we are in Python3
|
|
||||||
if not IS_PY2:
|
|
||||||
unicode = str
|
|
||||||
|
|
||||||
|
|
||||||
class ForeignServerModule(CollectionNodeModule):
|
class ForeignServerModule(CollectionNodeModule):
|
||||||
@ -466,7 +462,7 @@ class ForeignServerView(PGChildNodeView):
|
|||||||
try:
|
try:
|
||||||
sql, name = self.get_sql(gid, sid, data, did, fid, fsid)
|
sql, name = self.get_sql(gid, sid, data, did, fid, fsid)
|
||||||
# Most probably this is due to error
|
# Most probably this is due to error
|
||||||
if not isinstance(sql, (str, unicode)):
|
if not isinstance(sql, str):
|
||||||
return sql
|
return sql
|
||||||
sql = sql.strip('\n').strip(' ')
|
sql = sql.strip('\n').strip(' ')
|
||||||
status, res = self.conn.execute_scalar(sql)
|
status, res = self.conn.execute_scalar(sql)
|
||||||
@ -579,7 +575,7 @@ class ForeignServerView(PGChildNodeView):
|
|||||||
try:
|
try:
|
||||||
sql, name = self.get_sql(gid, sid, data, did, fid, fsid)
|
sql, name = self.get_sql(gid, sid, data, did, fid, fsid)
|
||||||
# Most probably this is due to error
|
# Most probably this is due to error
|
||||||
if not isinstance(sql, (str, unicode)):
|
if not isinstance(sql, str):
|
||||||
return sql
|
return sql
|
||||||
if sql == '':
|
if sql == '':
|
||||||
sql = "--modified SQL"
|
sql = "--modified SQL"
|
||||||
|
@ -23,10 +23,6 @@ from pgadmin.utils.ajax import make_json_response, internal_server_error, \
|
|||||||
make_response as ajax_response, gone
|
make_response as ajax_response, gone
|
||||||
from pgadmin.utils.driver import get_driver
|
from pgadmin.utils.driver import get_driver
|
||||||
from config import PG_DEFAULT_DRIVER
|
from config import PG_DEFAULT_DRIVER
|
||||||
from pgadmin.utils import IS_PY2
|
|
||||||
# If we are in Python3
|
|
||||||
if not IS_PY2:
|
|
||||||
unicode = str
|
|
||||||
|
|
||||||
|
|
||||||
class UserMappingModule(CollectionNodeModule):
|
class UserMappingModule(CollectionNodeModule):
|
||||||
@ -473,7 +469,7 @@ class UserMappingView(PGChildNodeView):
|
|||||||
try:
|
try:
|
||||||
sql, name = self.get_sql(gid, sid, data, did, fid, fsid, umid)
|
sql, name = self.get_sql(gid, sid, data, did, fid, fsid, umid)
|
||||||
# Most probably this is due to error
|
# Most probably this is due to error
|
||||||
if not isinstance(sql, (str, unicode)):
|
if not isinstance(sql, str):
|
||||||
return sql
|
return sql
|
||||||
sql = sql.strip('\n').strip(' ')
|
sql = sql.strip('\n').strip(' ')
|
||||||
status, res = self.conn.execute_scalar(sql)
|
status, res = self.conn.execute_scalar(sql)
|
||||||
@ -599,7 +595,7 @@ class UserMappingView(PGChildNodeView):
|
|||||||
try:
|
try:
|
||||||
sql, name = self.get_sql(gid, sid, data, did, fid, fsid, umid)
|
sql, name = self.get_sql(gid, sid, data, did, fid, fsid, umid)
|
||||||
# Most probably this is due to error
|
# Most probably this is due to error
|
||||||
if not isinstance(sql, (str, unicode)):
|
if not isinstance(sql, str):
|
||||||
return sql
|
return sql
|
||||||
if sql == '':
|
if sql == '':
|
||||||
sql = "--modified SQL"
|
sql = "--modified SQL"
|
||||||
|
@ -23,10 +23,6 @@ from pgadmin.utils.ajax import make_json_response, internal_server_error, \
|
|||||||
make_response as ajax_response, gone
|
make_response as ajax_response, gone
|
||||||
from pgadmin.utils.driver import get_driver
|
from pgadmin.utils.driver import get_driver
|
||||||
from config import PG_DEFAULT_DRIVER
|
from config import PG_DEFAULT_DRIVER
|
||||||
from pgadmin.utils import IS_PY2
|
|
||||||
# If we are in Python3
|
|
||||||
if not IS_PY2:
|
|
||||||
unicode = str
|
|
||||||
|
|
||||||
|
|
||||||
class LanguageModule(CollectionNodeModule):
|
class LanguageModule(CollectionNodeModule):
|
||||||
@ -420,7 +416,7 @@ class LanguageView(PGChildNodeView):
|
|||||||
try:
|
try:
|
||||||
sql, name = self.get_sql(data, lid)
|
sql, name = self.get_sql(data, lid)
|
||||||
# Most probably this is due to error
|
# Most probably this is due to error
|
||||||
if not isinstance(sql, (str, unicode)):
|
if not isinstance(sql, str):
|
||||||
return sql
|
return sql
|
||||||
sql = sql.strip('\n').strip(' ')
|
sql = sql.strip('\n').strip(' ')
|
||||||
status, res = self.conn.execute_dict(sql)
|
status, res = self.conn.execute_dict(sql)
|
||||||
@ -577,7 +573,7 @@ class LanguageView(PGChildNodeView):
|
|||||||
try:
|
try:
|
||||||
sql, name = self.get_sql(data, lid)
|
sql, name = self.get_sql(data, lid)
|
||||||
# Most probably this is due to error
|
# Most probably this is due to error
|
||||||
if not isinstance(sql, (str, unicode)):
|
if not isinstance(sql, str):
|
||||||
return sql
|
return sql
|
||||||
if sql == '':
|
if sql == '':
|
||||||
sql = "--modified SQL"
|
sql = "--modified SQL"
|
||||||
|
@ -20,7 +20,6 @@ from config import PG_DEFAULT_DRIVER
|
|||||||
from pgadmin.browser.server_groups.servers.databases.schemas.utils \
|
from pgadmin.browser.server_groups.servers.databases.schemas.utils \
|
||||||
import SchemaChildModule
|
import SchemaChildModule
|
||||||
from pgadmin.browser.utils import PGChildNodeView
|
from pgadmin.browser.utils import PGChildNodeView
|
||||||
from pgadmin.utils import IS_PY2
|
|
||||||
from pgadmin.utils.ajax import make_json_response, internal_server_error, \
|
from pgadmin.utils.ajax import make_json_response, internal_server_error, \
|
||||||
make_response as ajax_response, gone
|
make_response as ajax_response, gone
|
||||||
from pgadmin.utils.compile_template_name import compile_template_path
|
from pgadmin.utils.compile_template_name import compile_template_path
|
||||||
@ -28,10 +27,6 @@ from pgadmin.utils.driver import get_driver
|
|||||||
from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry
|
from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry
|
||||||
from pgadmin.tools.schema_diff.compare import SchemaDiffObjectCompare
|
from pgadmin.tools.schema_diff.compare import SchemaDiffObjectCompare
|
||||||
|
|
||||||
# If we are in Python3
|
|
||||||
if not IS_PY2:
|
|
||||||
unicode = str
|
|
||||||
|
|
||||||
|
|
||||||
class CollationModule(SchemaChildModule):
|
class CollationModule(SchemaChildModule):
|
||||||
"""
|
"""
|
||||||
@ -597,7 +592,7 @@ class CollationView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
)
|
)
|
||||||
SQL, name = self.get_sql(gid, sid, data, scid, coid)
|
SQL, name = self.get_sql(gid, sid, data, scid, coid)
|
||||||
# Most probably this is due to error
|
# Most probably this is due to error
|
||||||
if not isinstance(SQL, (str, unicode)):
|
if not isinstance(SQL, str):
|
||||||
return SQL
|
return SQL
|
||||||
SQL = SQL.strip('\n').strip(' ')
|
SQL = SQL.strip('\n').strip(' ')
|
||||||
status, res = self.conn.execute_scalar(SQL)
|
status, res = self.conn.execute_scalar(SQL)
|
||||||
@ -651,7 +646,7 @@ class CollationView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
try:
|
try:
|
||||||
SQL, name = self.get_sql(gid, sid, data, scid, coid)
|
SQL, name = self.get_sql(gid, sid, data, scid, coid)
|
||||||
# Most probably this is due to error
|
# Most probably this is due to error
|
||||||
if not isinstance(SQL, (str, unicode)):
|
if not isinstance(SQL, str):
|
||||||
return SQL
|
return SQL
|
||||||
if SQL == '':
|
if SQL == '':
|
||||||
SQL = "--modified SQL"
|
SQL = "--modified SQL"
|
||||||
|
@ -22,7 +22,6 @@ from pgadmin.browser.server_groups.servers.databases.schemas.utils import \
|
|||||||
from pgadmin.browser.server_groups.servers.databases.utils import \
|
from pgadmin.browser.server_groups.servers.databases.utils import \
|
||||||
parse_sec_labels_from_db
|
parse_sec_labels_from_db
|
||||||
from pgadmin.browser.utils import PGChildNodeView
|
from pgadmin.browser.utils import PGChildNodeView
|
||||||
from pgadmin.utils import IS_PY2
|
|
||||||
from pgadmin.utils.ajax import make_json_response, internal_server_error, \
|
from pgadmin.utils.ajax import make_json_response, internal_server_error, \
|
||||||
make_response as ajax_response, gone
|
make_response as ajax_response, gone
|
||||||
from pgadmin.utils.compile_template_name import compile_template_path
|
from pgadmin.utils.compile_template_name import compile_template_path
|
||||||
@ -30,10 +29,6 @@ from pgadmin.utils.driver import get_driver
|
|||||||
from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry
|
from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry
|
||||||
from pgadmin.tools.schema_diff.compare import SchemaDiffObjectCompare
|
from pgadmin.tools.schema_diff.compare import SchemaDiffObjectCompare
|
||||||
|
|
||||||
# If we are in Python3
|
|
||||||
if not IS_PY2:
|
|
||||||
unicode = str
|
|
||||||
|
|
||||||
|
|
||||||
class DomainModule(SchemaChildModule):
|
class DomainModule(SchemaChildModule):
|
||||||
"""
|
"""
|
||||||
@ -554,7 +549,7 @@ AND relkind != 'c'))"""
|
|||||||
data = self.request
|
data = self.request
|
||||||
SQL, name = self.get_sql(gid, sid, data, scid)
|
SQL, name = self.get_sql(gid, sid, data, scid)
|
||||||
# Most probably this is due to error
|
# Most probably this is due to error
|
||||||
if not isinstance(SQL, (str, unicode)):
|
if not isinstance(SQL, str):
|
||||||
return SQL
|
return SQL
|
||||||
|
|
||||||
status, res = self.conn.execute_scalar(SQL)
|
status, res = self.conn.execute_scalar(SQL)
|
||||||
@ -670,7 +665,7 @@ AND relkind != 'c'))"""
|
|||||||
|
|
||||||
SQL, name = self.get_sql(gid, sid, self.request, scid, doid)
|
SQL, name = self.get_sql(gid, sid, self.request, scid, doid)
|
||||||
# Most probably this is due to error
|
# Most probably this is due to error
|
||||||
if not isinstance(SQL, (str, unicode)):
|
if not isinstance(SQL, str):
|
||||||
return SQL
|
return SQL
|
||||||
|
|
||||||
status, res = self.conn.execute_scalar(SQL)
|
status, res = self.conn.execute_scalar(SQL)
|
||||||
@ -784,7 +779,7 @@ AND relkind != 'c'))"""
|
|||||||
try:
|
try:
|
||||||
SQL, name = self.get_sql(gid, sid, self.request, scid, doid)
|
SQL, name = self.get_sql(gid, sid, self.request, scid, doid)
|
||||||
# Most probably this is due to error
|
# Most probably this is due to error
|
||||||
if not isinstance(SQL, (str, unicode)):
|
if not isinstance(SQL, str):
|
||||||
return SQL
|
return SQL
|
||||||
if SQL == '':
|
if SQL == '':
|
||||||
SQL = "--modified SQL"
|
SQL = "--modified SQL"
|
||||||
|
@ -27,7 +27,6 @@ from pgadmin.browser.server_groups.servers.databases.utils import \
|
|||||||
from pgadmin.browser.server_groups.servers.utils import parse_priv_from_db, \
|
from pgadmin.browser.server_groups.servers.utils import parse_priv_from_db, \
|
||||||
parse_priv_to_db
|
parse_priv_to_db
|
||||||
from pgadmin.browser.utils import PGChildNodeView
|
from pgadmin.browser.utils import PGChildNodeView
|
||||||
from pgadmin.utils import IS_PY2
|
|
||||||
from pgadmin.utils.ajax import make_json_response, internal_server_error, \
|
from pgadmin.utils.ajax import make_json_response, internal_server_error, \
|
||||||
make_response as ajax_response, gone
|
make_response as ajax_response, gone
|
||||||
from pgadmin.utils.compile_template_name import compile_template_path
|
from pgadmin.utils.compile_template_name import compile_template_path
|
||||||
@ -35,10 +34,6 @@ from pgadmin.utils.driver import get_driver
|
|||||||
from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry
|
from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry
|
||||||
from pgadmin.tools.schema_diff.compare import SchemaDiffObjectCompare
|
from pgadmin.tools.schema_diff.compare import SchemaDiffObjectCompare
|
||||||
|
|
||||||
# If we are in Python3
|
|
||||||
if not IS_PY2:
|
|
||||||
unicode = str
|
|
||||||
|
|
||||||
|
|
||||||
class ForeignTableModule(SchemaChildModule):
|
class ForeignTableModule(SchemaChildModule):
|
||||||
"""
|
"""
|
||||||
@ -670,7 +665,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
|
|||||||
# Get SQL to create Foreign Table
|
# Get SQL to create Foreign Table
|
||||||
SQL, name = self.get_sql(gid, sid, did, scid, self.request)
|
SQL, name = self.get_sql(gid, sid, did, scid, self.request)
|
||||||
# Most probably this is due to error
|
# Most probably this is due to error
|
||||||
if not isinstance(SQL, (str, unicode)):
|
if not isinstance(SQL, str):
|
||||||
return SQL
|
return SQL
|
||||||
|
|
||||||
status, res = self.conn.execute_scalar(SQL)
|
status, res = self.conn.execute_scalar(SQL)
|
||||||
@ -791,7 +786,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
|
|||||||
try:
|
try:
|
||||||
SQL, name = self.get_sql(gid, sid, did, scid, self.request, foid)
|
SQL, name = self.get_sql(gid, sid, did, scid, self.request, foid)
|
||||||
# Most probably this is due to error
|
# Most probably this is due to error
|
||||||
if not isinstance(SQL, (str, unicode)):
|
if not isinstance(SQL, str):
|
||||||
return SQL
|
return SQL
|
||||||
|
|
||||||
SQL = SQL.strip('\n').strip(' ')
|
SQL = SQL.strip('\n').strip(' ')
|
||||||
@ -892,7 +887,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
|
|||||||
try:
|
try:
|
||||||
SQL, name = self.get_sql(gid, sid, did, scid, self.request, foid)
|
SQL, name = self.get_sql(gid, sid, did, scid, self.request, foid)
|
||||||
# Most probably this is due to error
|
# Most probably this is due to error
|
||||||
if not isinstance(SQL, (str, unicode)):
|
if not isinstance(SQL, str):
|
||||||
return SQL
|
return SQL
|
||||||
|
|
||||||
if SQL == '':
|
if SQL == '':
|
||||||
|
@ -20,17 +20,12 @@ from config import PG_DEFAULT_DRIVER
|
|||||||
from pgadmin.browser.server_groups.servers.databases.schemas.utils \
|
from pgadmin.browser.server_groups.servers.databases.schemas.utils \
|
||||||
import SchemaChildModule
|
import SchemaChildModule
|
||||||
from pgadmin.browser.utils import PGChildNodeView
|
from pgadmin.browser.utils import PGChildNodeView
|
||||||
from pgadmin.utils import IS_PY2
|
|
||||||
from pgadmin.utils.ajax import make_json_response, internal_server_error, \
|
from pgadmin.utils.ajax import make_json_response, internal_server_error, \
|
||||||
make_response as ajax_response, gone
|
make_response as ajax_response, gone
|
||||||
from pgadmin.utils.driver import get_driver
|
from pgadmin.utils.driver import get_driver
|
||||||
from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry
|
from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry
|
||||||
from pgadmin.tools.schema_diff.compare import SchemaDiffObjectCompare
|
from pgadmin.tools.schema_diff.compare import SchemaDiffObjectCompare
|
||||||
|
|
||||||
# If we are in Python3
|
|
||||||
if not IS_PY2:
|
|
||||||
unicode = str
|
|
||||||
|
|
||||||
|
|
||||||
class FtsConfigurationModule(SchemaChildModule):
|
class FtsConfigurationModule(SchemaChildModule):
|
||||||
"""
|
"""
|
||||||
@ -506,7 +501,7 @@ class FtsConfigurationView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
# Fetch sql query to update fts Configuration
|
# Fetch sql query to update fts Configuration
|
||||||
sql, name = self.get_sql(gid, sid, did, scid, data, cfgid)
|
sql, name = self.get_sql(gid, sid, did, scid, data, cfgid)
|
||||||
# Most probably this is due to error
|
# Most probably this is due to error
|
||||||
if not isinstance(sql, (str, unicode)):
|
if not isinstance(sql, str):
|
||||||
return sql
|
return sql
|
||||||
sql = sql.strip('\n').strip(' ')
|
sql = sql.strip('\n').strip(' ')
|
||||||
status, res = self.conn.execute_scalar(sql)
|
status, res = self.conn.execute_scalar(sql)
|
||||||
@ -637,7 +632,7 @@ class FtsConfigurationView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
# Fetch sql query for modified data
|
# Fetch sql query for modified data
|
||||||
SQL, name = self.get_sql(gid, sid, did, scid, data, cfgid)
|
SQL, name = self.get_sql(gid, sid, did, scid, data, cfgid)
|
||||||
# Most probably this is due to error
|
# Most probably this is due to error
|
||||||
if not isinstance(SQL, (str, unicode)):
|
if not isinstance(SQL, str):
|
||||||
return SQL
|
return SQL
|
||||||
|
|
||||||
if SQL == '':
|
if SQL == '':
|
||||||
|
@ -20,17 +20,12 @@ from config import PG_DEFAULT_DRIVER
|
|||||||
from pgadmin.browser.server_groups.servers.databases.schemas.utils \
|
from pgadmin.browser.server_groups.servers.databases.schemas.utils \
|
||||||
import SchemaChildModule
|
import SchemaChildModule
|
||||||
from pgadmin.browser.utils import PGChildNodeView
|
from pgadmin.browser.utils import PGChildNodeView
|
||||||
from pgadmin.utils import IS_PY2
|
|
||||||
from pgadmin.utils.ajax import make_json_response, internal_server_error, \
|
from pgadmin.utils.ajax import make_json_response, internal_server_error, \
|
||||||
make_response as ajax_response, gone
|
make_response as ajax_response, gone
|
||||||
from pgadmin.utils.driver import get_driver
|
from pgadmin.utils.driver import get_driver
|
||||||
from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry
|
from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry
|
||||||
from pgadmin.tools.schema_diff.compare import SchemaDiffObjectCompare
|
from pgadmin.tools.schema_diff.compare import SchemaDiffObjectCompare
|
||||||
|
|
||||||
# If we are in Python3
|
|
||||||
if not IS_PY2:
|
|
||||||
unicode = str
|
|
||||||
|
|
||||||
|
|
||||||
class FtsDictionaryModule(SchemaChildModule):
|
class FtsDictionaryModule(SchemaChildModule):
|
||||||
"""
|
"""
|
||||||
@ -503,7 +498,7 @@ class FtsDictionaryView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
# Fetch sql query to update fts dictionary
|
# Fetch sql query to update fts dictionary
|
||||||
sql, name = self.get_sql(gid, sid, did, scid, data, dcid)
|
sql, name = self.get_sql(gid, sid, did, scid, data, dcid)
|
||||||
# Most probably this is due to error
|
# Most probably this is due to error
|
||||||
if not isinstance(sql, (str, unicode)):
|
if not isinstance(sql, str):
|
||||||
return sql
|
return sql
|
||||||
|
|
||||||
sql = sql.strip('\n').strip(' ')
|
sql = sql.strip('\n').strip(' ')
|
||||||
@ -634,7 +629,7 @@ class FtsDictionaryView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
# Fetch sql query for modified data
|
# Fetch sql query for modified data
|
||||||
SQL, name = self.get_sql(gid, sid, did, scid, data, dcid)
|
SQL, name = self.get_sql(gid, sid, did, scid, data, dcid)
|
||||||
# Most probably this is due to error
|
# Most probably this is due to error
|
||||||
if not isinstance(SQL, (str, unicode)):
|
if not isinstance(SQL, str):
|
||||||
return SQL
|
return SQL
|
||||||
|
|
||||||
if SQL == '':
|
if SQL == '':
|
||||||
|
@ -20,17 +20,12 @@ from pgadmin.browser.server_groups.servers.databases import DatabaseModule
|
|||||||
from pgadmin.browser.server_groups.servers.databases.schemas.utils import \
|
from pgadmin.browser.server_groups.servers.databases.schemas.utils import \
|
||||||
SchemaChildModule
|
SchemaChildModule
|
||||||
from pgadmin.browser.utils import PGChildNodeView
|
from pgadmin.browser.utils import PGChildNodeView
|
||||||
from pgadmin.utils import IS_PY2
|
|
||||||
from pgadmin.utils.ajax import make_json_response, internal_server_error, \
|
from pgadmin.utils.ajax import make_json_response, internal_server_error, \
|
||||||
make_response as ajax_response, gone
|
make_response as ajax_response, gone
|
||||||
from pgadmin.utils.driver import get_driver
|
from pgadmin.utils.driver import get_driver
|
||||||
from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry
|
from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry
|
||||||
from pgadmin.tools.schema_diff.compare import SchemaDiffObjectCompare
|
from pgadmin.tools.schema_diff.compare import SchemaDiffObjectCompare
|
||||||
|
|
||||||
# If we are in Python3
|
|
||||||
if not IS_PY2:
|
|
||||||
unicode = str
|
|
||||||
|
|
||||||
|
|
||||||
class FtsParserModule(SchemaChildModule):
|
class FtsParserModule(SchemaChildModule):
|
||||||
"""
|
"""
|
||||||
@ -448,7 +443,7 @@ class FtsParserView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
# Fetch sql query to update fts parser
|
# Fetch sql query to update fts parser
|
||||||
sql, name = self.get_sql(gid, sid, did, scid, data, pid)
|
sql, name = self.get_sql(gid, sid, did, scid, data, pid)
|
||||||
# Most probably this is due to error
|
# Most probably this is due to error
|
||||||
if not isinstance(sql, (str, unicode)):
|
if not isinstance(sql, str):
|
||||||
return sql
|
return sql
|
||||||
|
|
||||||
sql = sql.strip('\n').strip(' ')
|
sql = sql.strip('\n').strip(' ')
|
||||||
@ -580,7 +575,7 @@ class FtsParserView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
# Fetch sql query for modified data
|
# Fetch sql query for modified data
|
||||||
SQL, name = self.get_sql(gid, sid, did, scid, data, pid)
|
SQL, name = self.get_sql(gid, sid, did, scid, data, pid)
|
||||||
# Most probably this is due to error
|
# Most probably this is due to error
|
||||||
if not isinstance(SQL, (str, unicode)):
|
if not isinstance(SQL, str):
|
||||||
return SQL
|
return SQL
|
||||||
if SQL == '':
|
if SQL == '':
|
||||||
SQL = "--modified SQL"
|
SQL = "--modified SQL"
|
||||||
|
@ -20,17 +20,12 @@ from pgadmin.browser.server_groups.servers.databases import DatabaseModule
|
|||||||
from pgadmin.browser.server_groups.servers.databases.schemas.utils import \
|
from pgadmin.browser.server_groups.servers.databases.schemas.utils import \
|
||||||
SchemaChildModule
|
SchemaChildModule
|
||||||
from pgadmin.browser.utils import PGChildNodeView
|
from pgadmin.browser.utils import PGChildNodeView
|
||||||
from pgadmin.utils import IS_PY2
|
|
||||||
from pgadmin.utils.ajax import make_json_response, internal_server_error, \
|
from pgadmin.utils.ajax import make_json_response, internal_server_error, \
|
||||||
make_response as ajax_response, gone
|
make_response as ajax_response, gone
|
||||||
from pgadmin.utils.driver import get_driver
|
from pgadmin.utils.driver import get_driver
|
||||||
from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry
|
from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry
|
||||||
from pgadmin.tools.schema_diff.compare import SchemaDiffObjectCompare
|
from pgadmin.tools.schema_diff.compare import SchemaDiffObjectCompare
|
||||||
|
|
||||||
# If we are in Python3
|
|
||||||
if not IS_PY2:
|
|
||||||
unicode = str
|
|
||||||
|
|
||||||
|
|
||||||
class FtsTemplateModule(SchemaChildModule):
|
class FtsTemplateModule(SchemaChildModule):
|
||||||
"""
|
"""
|
||||||
@ -421,7 +416,7 @@ class FtsTemplateView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
# Fetch sql query to update fts template
|
# Fetch sql query to update fts template
|
||||||
sql, name = self.get_sql(gid, sid, did, scid, data, tid)
|
sql, name = self.get_sql(gid, sid, did, scid, data, tid)
|
||||||
# Most probably this is due to error
|
# Most probably this is due to error
|
||||||
if not isinstance(sql, (str, unicode)):
|
if not isinstance(sql, str):
|
||||||
return sql
|
return sql
|
||||||
sql = sql.strip('\n').strip(' ')
|
sql = sql.strip('\n').strip(' ')
|
||||||
status, res = self.conn.execute_scalar(sql)
|
status, res = self.conn.execute_scalar(sql)
|
||||||
@ -539,7 +534,7 @@ class FtsTemplateView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
# Fetch sql query for modified data
|
# Fetch sql query for modified data
|
||||||
SQL, name = self.get_sql(gid, sid, did, scid, data, tid)
|
SQL, name = self.get_sql(gid, sid, did, scid, data, tid)
|
||||||
# Most probably this is due to error
|
# Most probably this is due to error
|
||||||
if not isinstance(SQL, (str, unicode)):
|
if not isinstance(SQL, str):
|
||||||
return SQL
|
return SQL
|
||||||
|
|
||||||
if SQL == '':
|
if SQL == '':
|
||||||
|
@ -22,7 +22,6 @@ from pgadmin.browser.server_groups.servers.databases.schemas.utils \
|
|||||||
from pgadmin.browser.server_groups.servers.utils import parse_priv_from_db, \
|
from pgadmin.browser.server_groups.servers.utils import parse_priv_from_db, \
|
||||||
parse_priv_to_db
|
parse_priv_to_db
|
||||||
from pgadmin.browser.utils import PGChildNodeView
|
from pgadmin.browser.utils import PGChildNodeView
|
||||||
from pgadmin.utils import IS_PY2
|
|
||||||
from pgadmin.utils.ajax import make_json_response, \
|
from pgadmin.utils.ajax import make_json_response, \
|
||||||
make_response as ajax_response, internal_server_error, \
|
make_response as ajax_response, internal_server_error, \
|
||||||
precondition_required, gone
|
precondition_required, gone
|
||||||
@ -30,10 +29,6 @@ from pgadmin.utils.driver import get_driver
|
|||||||
from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry
|
from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry
|
||||||
from pgadmin.tools.schema_diff.compare import SchemaDiffObjectCompare
|
from pgadmin.tools.schema_diff.compare import SchemaDiffObjectCompare
|
||||||
|
|
||||||
# If we are in Python3
|
|
||||||
if not IS_PY2:
|
|
||||||
unicode = str
|
|
||||||
|
|
||||||
|
|
||||||
class PackageModule(SchemaChildModule):
|
class PackageModule(SchemaChildModule):
|
||||||
"""
|
"""
|
||||||
@ -510,7 +505,7 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
|
|
||||||
SQL, name = self.getSQL(gid, sid, did, data, scid, pkgid)
|
SQL, name = self.getSQL(gid, sid, did, data, scid, pkgid)
|
||||||
# Most probably this is due to error
|
# Most probably this is due to error
|
||||||
if not isinstance(SQL, (str, unicode)):
|
if not isinstance(SQL, str):
|
||||||
return SQL
|
return SQL
|
||||||
|
|
||||||
SQL = SQL.strip('\n').strip(' ')
|
SQL = SQL.strip('\n').strip(' ')
|
||||||
@ -565,7 +560,7 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
|
|
||||||
SQL, name = self.getSQL(gid, sid, did, data, scid, pkgid)
|
SQL, name = self.getSQL(gid, sid, did, data, scid, pkgid)
|
||||||
# Most probably this is due to error
|
# Most probably this is due to error
|
||||||
if not isinstance(SQL, (str, unicode)):
|
if not isinstance(SQL, str):
|
||||||
return SQL
|
return SQL
|
||||||
|
|
||||||
SQL = SQL.strip('\n').strip(' ')
|
SQL = SQL.strip('\n').strip(' ')
|
||||||
@ -714,7 +709,7 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
sql, name = self.getSQL(gid, sid, did, result, scid, pkgid, True,
|
sql, name = self.getSQL(gid, sid, did, result, scid, pkgid, True,
|
||||||
diff_schema)
|
diff_schema)
|
||||||
# Most probably this is due to error
|
# Most probably this is due to error
|
||||||
if not isinstance(sql, (str, unicode)):
|
if not isinstance(sql, str):
|
||||||
return sql
|
return sql
|
||||||
|
|
||||||
sql = sql.strip('\n').strip(' ')
|
sql = sql.strip('\n').strip(' ')
|
||||||
|
@ -23,14 +23,9 @@ from pgadmin.utils.ajax import make_json_response, internal_server_error, \
|
|||||||
make_response as ajax_response, gone
|
make_response as ajax_response, gone
|
||||||
from pgadmin.utils.driver import get_driver
|
from pgadmin.utils.driver import get_driver
|
||||||
from config import PG_DEFAULT_DRIVER
|
from config import PG_DEFAULT_DRIVER
|
||||||
from pgadmin.utils import IS_PY2
|
|
||||||
from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry
|
from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry
|
||||||
from pgadmin.tools.schema_diff.compare import SchemaDiffObjectCompare
|
from pgadmin.tools.schema_diff.compare import SchemaDiffObjectCompare
|
||||||
|
|
||||||
# If we are in Python3
|
|
||||||
if not IS_PY2:
|
|
||||||
unicode = str
|
|
||||||
|
|
||||||
|
|
||||||
class SequenceModule(SchemaChildModule):
|
class SequenceModule(SchemaChildModule):
|
||||||
"""
|
"""
|
||||||
@ -533,7 +528,7 @@ class SequenceView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
)
|
)
|
||||||
SQL, name = self.getSQL(gid, sid, did, data, scid, seid)
|
SQL, name = self.getSQL(gid, sid, did, data, scid, seid)
|
||||||
# Most probably this is due to error
|
# Most probably this is due to error
|
||||||
if not isinstance(SQL, (str, unicode)):
|
if not isinstance(SQL, str):
|
||||||
return SQL
|
return SQL
|
||||||
|
|
||||||
SQL = SQL.strip('\n').strip(' ')
|
SQL = SQL.strip('\n').strip(' ')
|
||||||
@ -602,7 +597,7 @@ class SequenceView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
)
|
)
|
||||||
SQL, name = self.getSQL(gid, sid, did, data, scid, seid)
|
SQL, name = self.getSQL(gid, sid, did, data, scid, seid)
|
||||||
# Most probably this is due to error
|
# Most probably this is due to error
|
||||||
if not isinstance(SQL, (str, unicode)):
|
if not isinstance(SQL, str):
|
||||||
return SQL
|
return SQL
|
||||||
|
|
||||||
SQL = SQL.strip('\n').strip(' ')
|
SQL = SQL.strip('\n').strip(' ')
|
||||||
@ -737,7 +732,7 @@ class SequenceView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
result = self._formatter(result, scid, seid)
|
result = self._formatter(result, scid, seid)
|
||||||
SQL, name = self.getSQL(gid, sid, did, result, scid)
|
SQL, name = self.getSQL(gid, sid, did, result, scid)
|
||||||
# Most probably this is due to error
|
# Most probably this is due to error
|
||||||
if not isinstance(SQL, (str, unicode)):
|
if not isinstance(SQL, str):
|
||||||
return SQL
|
return SQL
|
||||||
SQL = SQL.strip('\n').strip(' ')
|
SQL = SQL.strip('\n').strip(' ')
|
||||||
|
|
||||||
|
@ -23,14 +23,9 @@ from pgadmin.utils.ajax import make_json_response, \
|
|||||||
from pgadmin.utils.ajax import precondition_required
|
from pgadmin.utils.ajax import precondition_required
|
||||||
from pgadmin.utils.driver import get_driver
|
from pgadmin.utils.driver import get_driver
|
||||||
from config import PG_DEFAULT_DRIVER
|
from config import PG_DEFAULT_DRIVER
|
||||||
from pgadmin.utils import IS_PY2
|
|
||||||
from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry
|
from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry
|
||||||
from pgadmin.tools.schema_diff.compare import SchemaDiffObjectCompare
|
from pgadmin.tools.schema_diff.compare import SchemaDiffObjectCompare
|
||||||
|
|
||||||
# If we are in Python3
|
|
||||||
if not IS_PY2:
|
|
||||||
unicode = str
|
|
||||||
|
|
||||||
|
|
||||||
class SynonymModule(SchemaChildModule):
|
class SynonymModule(SchemaChildModule):
|
||||||
"""
|
"""
|
||||||
@ -568,7 +563,7 @@ class SynonymView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
)
|
)
|
||||||
SQL, name = self.get_sql(gid, sid, data, scid, syid)
|
SQL, name = self.get_sql(gid, sid, data, scid, syid)
|
||||||
# Most probably this is due to error
|
# Most probably this is due to error
|
||||||
if not isinstance(SQL, (str, unicode)):
|
if not isinstance(SQL, str):
|
||||||
return SQL
|
return SQL
|
||||||
try:
|
try:
|
||||||
if SQL and SQL.strip('\n') and SQL.strip(' '):
|
if SQL and SQL.strip('\n') and SQL.strip(' '):
|
||||||
@ -610,7 +605,7 @@ class SynonymView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
try:
|
try:
|
||||||
SQL, name = self.get_sql(gid, sid, data, scid, syid)
|
SQL, name = self.get_sql(gid, sid, data, scid, syid)
|
||||||
# Most probably this is due to error
|
# Most probably this is due to error
|
||||||
if not isinstance(SQL, (str, unicode)):
|
if not isinstance(SQL, str):
|
||||||
return SQL
|
return SQL
|
||||||
if SQL and SQL.strip('\n') and SQL.strip(' '):
|
if SQL and SQL.strip('\n') and SQL.strip(' '):
|
||||||
return make_json_response(
|
return make_json_response(
|
||||||
|
@ -27,13 +27,8 @@ from pgadmin.browser.server_groups.servers.databases.schemas.tables.\
|
|||||||
columns import utils as column_utils
|
columns import utils as column_utils
|
||||||
from pgadmin.utils.driver import get_driver
|
from pgadmin.utils.driver import get_driver
|
||||||
from config import PG_DEFAULT_DRIVER
|
from config import PG_DEFAULT_DRIVER
|
||||||
from pgadmin.utils import IS_PY2
|
|
||||||
from pgadmin.utils.ajax import ColParamsJSONDecoder
|
from pgadmin.utils.ajax import ColParamsJSONDecoder
|
||||||
|
|
||||||
# If we are in Python3
|
|
||||||
if not IS_PY2:
|
|
||||||
unicode = str
|
|
||||||
|
|
||||||
|
|
||||||
class ColumnsModule(CollectionNodeModule):
|
class ColumnsModule(CollectionNodeModule):
|
||||||
"""
|
"""
|
||||||
@ -530,7 +525,7 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
|
|||||||
column_utils.type_formatter(data['cltype'])
|
column_utils.type_formatter(data['cltype'])
|
||||||
|
|
||||||
SQL, name = self.get_sql(scid, tid, clid, data)
|
SQL, name = self.get_sql(scid, tid, clid, data)
|
||||||
if not isinstance(SQL, (str, unicode)):
|
if not isinstance(SQL, str):
|
||||||
return SQL
|
return SQL
|
||||||
SQL = SQL.strip('\n').strip(' ')
|
SQL = SQL.strip('\n').strip(' ')
|
||||||
status, res = self.conn.execute_scalar(SQL)
|
status, res = self.conn.execute_scalar(SQL)
|
||||||
@ -574,7 +569,7 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
SQL, name = self.get_sql(scid, tid, clid, data)
|
SQL, name = self.get_sql(scid, tid, clid, data)
|
||||||
if not isinstance(SQL, (str, unicode)):
|
if not isinstance(SQL, str):
|
||||||
return SQL
|
return SQL
|
||||||
|
|
||||||
SQL = SQL.strip('\n').strip(' ')
|
SQL = SQL.strip('\n').strip(' ')
|
||||||
@ -723,7 +718,7 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
|
|||||||
data, [])
|
data, [])
|
||||||
|
|
||||||
SQL, name = self.get_sql(scid, tid, None, data, is_sql=True)
|
SQL, name = self.get_sql(scid, tid, None, data, is_sql=True)
|
||||||
if not isinstance(SQL, (str, unicode)):
|
if not isinstance(SQL, str):
|
||||||
return SQL
|
return SQL
|
||||||
|
|
||||||
sql_header = u"-- Column: {0}\n\n-- ".format(
|
sql_header = u"-- Column: {0}\n\n-- ".format(
|
||||||
|
@ -25,7 +25,6 @@ from pgadmin.browser.server_groups.servers.databases.schemas.utils \
|
|||||||
import trigger_definition
|
import trigger_definition
|
||||||
from pgadmin.utils.driver import get_driver
|
from pgadmin.utils.driver import get_driver
|
||||||
from config import PG_DEFAULT_DRIVER
|
from config import PG_DEFAULT_DRIVER
|
||||||
from pgadmin.utils import IS_PY2
|
|
||||||
from pgadmin.utils.compile_template_name import compile_template_path
|
from pgadmin.utils.compile_template_name import compile_template_path
|
||||||
from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry
|
from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry
|
||||||
from pgadmin.tools.schema_diff.compare import SchemaDiffObjectCompare
|
from pgadmin.tools.schema_diff.compare import SchemaDiffObjectCompare
|
||||||
@ -33,11 +32,6 @@ from pgadmin.tools.schema_diff.directory_compare import directory_diff,\
|
|||||||
parse_acl
|
parse_acl
|
||||||
|
|
||||||
|
|
||||||
# If we are in Python3
|
|
||||||
if not IS_PY2:
|
|
||||||
unicode = str
|
|
||||||
|
|
||||||
|
|
||||||
class CompoundTriggerModule(CollectionNodeModule):
|
class CompoundTriggerModule(CollectionNodeModule):
|
||||||
"""
|
"""
|
||||||
class CompoundTriggerModule(CollectionNodeModule)
|
class CompoundTriggerModule(CollectionNodeModule)
|
||||||
@ -645,7 +639,7 @@ class CompoundTriggerView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
|
|
||||||
SQL, name = compound_trigger_utils.get_sql(
|
SQL, name = compound_trigger_utils.get_sql(
|
||||||
self.conn, data, tid, trid, self.datlastsysoid)
|
self.conn, data, tid, trid, self.datlastsysoid)
|
||||||
if not isinstance(SQL, (str, unicode)):
|
if not isinstance(SQL, str):
|
||||||
return SQL
|
return SQL
|
||||||
SQL = SQL.strip('\n').strip(' ')
|
SQL = SQL.strip('\n').strip(' ')
|
||||||
status, res = self.conn.execute_scalar(SQL)
|
status, res = self.conn.execute_scalar(SQL)
|
||||||
@ -725,7 +719,7 @@ class CompoundTriggerView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
try:
|
try:
|
||||||
sql, name = compound_trigger_utils.get_sql(
|
sql, name = compound_trigger_utils.get_sql(
|
||||||
self.conn, data, tid, trid, self.datlastsysoid)
|
self.conn, data, tid, trid, self.datlastsysoid)
|
||||||
if not isinstance(sql, (str, unicode)):
|
if not isinstance(sql, str):
|
||||||
return sql
|
return sql
|
||||||
sql = sql.strip('\n').strip(' ')
|
sql = sql.strip('\n').strip(' ')
|
||||||
|
|
||||||
@ -885,7 +879,7 @@ class CompoundTriggerView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
data,
|
data,
|
||||||
tid, oid,
|
tid, oid,
|
||||||
self.datlastsysoid)
|
self.datlastsysoid)
|
||||||
if not isinstance(sql, (str, unicode)):
|
if not isinstance(sql, str):
|
||||||
return sql
|
return sql
|
||||||
sql = sql.strip('\n').strip(' ')
|
sql = sql.strip('\n').strip(' ')
|
||||||
else:
|
else:
|
||||||
|
@ -24,10 +24,6 @@ from pgadmin.browser.server_groups.servers.databases.schemas.tables.\
|
|||||||
constraints.exclusion_constraint import utils as exclusion_utils
|
constraints.exclusion_constraint import utils as exclusion_utils
|
||||||
from pgadmin.utils.driver import get_driver
|
from pgadmin.utils.driver import get_driver
|
||||||
from config import PG_DEFAULT_DRIVER
|
from config import PG_DEFAULT_DRIVER
|
||||||
from pgadmin.utils import IS_PY2
|
|
||||||
# If we are in Python3
|
|
||||||
if not IS_PY2:
|
|
||||||
unicode = str
|
|
||||||
|
|
||||||
|
|
||||||
class ExclusionConstraintModule(ConstraintTypeModule):
|
class ExclusionConstraintModule(ConstraintTypeModule):
|
||||||
@ -608,7 +604,7 @@ class ExclusionConstraintView(PGChildNodeView):
|
|||||||
data['table'] = self.table
|
data['table'] = self.table
|
||||||
sql, name = \
|
sql, name = \
|
||||||
exclusion_utils.get_sql(self.conn, data, did, tid, exid)
|
exclusion_utils.get_sql(self.conn, data, did, tid, exid)
|
||||||
if not isinstance(sql, (str, unicode)):
|
if not isinstance(sql, str):
|
||||||
return sql
|
return sql
|
||||||
sql = sql.strip('\n').strip(' ')
|
sql = sql.strip('\n').strip(' ')
|
||||||
status, res = self.conn.execute_scalar(sql)
|
status, res = self.conn.execute_scalar(sql)
|
||||||
@ -740,7 +736,7 @@ class ExclusionConstraintView(PGChildNodeView):
|
|||||||
try:
|
try:
|
||||||
sql, name = \
|
sql, name = \
|
||||||
exclusion_utils.get_sql(self.conn, data, did, tid, exid)
|
exclusion_utils.get_sql(self.conn, data, did, tid, exid)
|
||||||
if not isinstance(sql, (str, unicode)):
|
if not isinstance(sql, str):
|
||||||
return sql
|
return sql
|
||||||
sql = sql.strip('\n').strip(' ')
|
sql = sql.strip('\n').strip(' ')
|
||||||
if sql == '':
|
if sql == '':
|
||||||
|
@ -24,11 +24,6 @@ from pgadmin.browser.server_groups.servers.databases.schemas.tables.\
|
|||||||
constraints.foreign_key import utils as fkey_utils
|
constraints.foreign_key import utils as fkey_utils
|
||||||
from pgadmin.utils.driver import get_driver
|
from pgadmin.utils.driver import get_driver
|
||||||
from config import PG_DEFAULT_DRIVER
|
from config import PG_DEFAULT_DRIVER
|
||||||
from pgadmin.utils import IS_PY2
|
|
||||||
|
|
||||||
# If we are in Python3
|
|
||||||
if not IS_PY2:
|
|
||||||
unicode = str
|
|
||||||
|
|
||||||
FOREIGN_KEY_NOT_FOUND = gettext("Could not find the foreign key.")
|
FOREIGN_KEY_NOT_FOUND = gettext("Could not find the foreign key.")
|
||||||
|
|
||||||
@ -650,7 +645,7 @@ class ForeignKeyConstraintView(PGChildNodeView):
|
|||||||
data['schema'] = self.schema
|
data['schema'] = self.schema
|
||||||
data['table'] = self.table
|
data['table'] = self.table
|
||||||
sql, name = fkey_utils.get_sql(self.conn, data, tid, fkid)
|
sql, name = fkey_utils.get_sql(self.conn, data, tid, fkid)
|
||||||
if not isinstance(sql, (str, unicode)):
|
if not isinstance(sql, str):
|
||||||
return sql
|
return sql
|
||||||
sql = sql.strip('\n').strip(' ')
|
sql = sql.strip('\n').strip(' ')
|
||||||
|
|
||||||
@ -786,7 +781,7 @@ class ForeignKeyConstraintView(PGChildNodeView):
|
|||||||
data['table'] = self.table
|
data['table'] = self.table
|
||||||
try:
|
try:
|
||||||
sql, name = fkey_utils.get_sql(self.conn, data, tid, fkid)
|
sql, name = fkey_utils.get_sql(self.conn, data, tid, fkid)
|
||||||
if not isinstance(sql, (str, unicode)):
|
if not isinstance(sql, str):
|
||||||
return sql
|
return sql
|
||||||
sql = sql.strip('\n').strip(' ')
|
sql = sql.strip('\n').strip(' ')
|
||||||
if sql == '':
|
if sql == '':
|
||||||
|
@ -24,10 +24,6 @@ from pgadmin.browser.server_groups.servers.databases.schemas.tables.\
|
|||||||
constraints.index_constraint import utils as idxcons_utils
|
constraints.index_constraint import utils as idxcons_utils
|
||||||
from pgadmin.utils.driver import get_driver
|
from pgadmin.utils.driver import get_driver
|
||||||
from config import PG_DEFAULT_DRIVER
|
from config import PG_DEFAULT_DRIVER
|
||||||
from pgadmin.utils import IS_PY2
|
|
||||||
# If we are in Python3
|
|
||||||
if not IS_PY2:
|
|
||||||
unicode = str
|
|
||||||
|
|
||||||
|
|
||||||
class IndexConstraintModule(ConstraintTypeModule):
|
class IndexConstraintModule(ConstraintTypeModule):
|
||||||
@ -651,7 +647,7 @@ class IndexConstraintView(PGChildNodeView):
|
|||||||
data['table'] = self.table
|
data['table'] = self.table
|
||||||
sql, name = idxcons_utils.get_sql(self.conn, data, did, tid,
|
sql, name = idxcons_utils.get_sql(self.conn, data, did, tid,
|
||||||
self.constraint_type, cid)
|
self.constraint_type, cid)
|
||||||
if not isinstance(sql, (str, unicode)):
|
if not isinstance(sql, str):
|
||||||
return sql
|
return sql
|
||||||
sql = sql.strip('\n').strip(' ')
|
sql = sql.strip('\n').strip(' ')
|
||||||
|
|
||||||
@ -792,7 +788,7 @@ class IndexConstraintView(PGChildNodeView):
|
|||||||
try:
|
try:
|
||||||
sql, name = idxcons_utils.get_sql(self.conn, data, did, tid,
|
sql, name = idxcons_utils.get_sql(self.conn, data, did, tid,
|
||||||
self.constraint_type, cid)
|
self.constraint_type, cid)
|
||||||
if not isinstance(sql, (str, unicode)):
|
if not isinstance(sql, str):
|
||||||
return sql
|
return sql
|
||||||
sql = sql.strip('\n').strip(' ')
|
sql = sql.strip('\n').strip(' ')
|
||||||
if sql == '':
|
if sql == '':
|
||||||
|
@ -14,10 +14,6 @@ from flask_babelex import gettext as _
|
|||||||
from pgadmin.utils.ajax import internal_server_error
|
from pgadmin.utils.ajax import internal_server_error
|
||||||
from pgadmin.utils.exception import ObjectGone
|
from pgadmin.utils.exception import ObjectGone
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
from pgadmin.utils import IS_PY2
|
|
||||||
# If we are in Python3
|
|
||||||
if not IS_PY2:
|
|
||||||
unicode = str
|
|
||||||
|
|
||||||
|
|
||||||
def get_template_path(f):
|
def get_template_path(f):
|
||||||
@ -218,7 +214,7 @@ def get_sql(conn, data, did, tid, ctype, cid=None, template_path=None):
|
|||||||
]
|
]
|
||||||
|
|
||||||
def is_key_str(key, data):
|
def is_key_str(key, data):
|
||||||
return isinstance(data[key], (str, unicode)) and data[key] != ""
|
return isinstance(data[key], str) and data[key] != ""
|
||||||
|
|
||||||
def is_key_list(key, data):
|
def is_key_list(key, data):
|
||||||
return isinstance(data[key], list) and len(data[param]) > 0
|
return isinstance(data[key], list) and len(data[param]) > 0
|
||||||
|
@ -24,17 +24,12 @@ from pgadmin.utils.ajax import make_json_response, internal_server_error, \
|
|||||||
from pgadmin.utils.compile_template_name import compile_template_path
|
from pgadmin.utils.compile_template_name import compile_template_path
|
||||||
from pgadmin.utils.driver import get_driver
|
from pgadmin.utils.driver import get_driver
|
||||||
from config import PG_DEFAULT_DRIVER
|
from config import PG_DEFAULT_DRIVER
|
||||||
from pgadmin.utils import IS_PY2
|
|
||||||
from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry
|
from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry
|
||||||
from pgadmin.tools.schema_diff.directory_compare import directory_diff
|
from pgadmin.tools.schema_diff.directory_compare import directory_diff
|
||||||
from pgadmin.tools.schema_diff.compare import SchemaDiffObjectCompare
|
from pgadmin.tools.schema_diff.compare import SchemaDiffObjectCompare
|
||||||
from pgadmin.browser.server_groups.servers.databases.schemas. \
|
from pgadmin.browser.server_groups.servers.databases.schemas. \
|
||||||
tables.indexes import utils as index_utils
|
tables.indexes import utils as index_utils
|
||||||
|
|
||||||
# If we are in Python3
|
|
||||||
if not IS_PY2:
|
|
||||||
unicode = str
|
|
||||||
|
|
||||||
|
|
||||||
class IndexesModule(CollectionNodeModule):
|
class IndexesModule(CollectionNodeModule):
|
||||||
"""
|
"""
|
||||||
@ -741,7 +736,7 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
try:
|
try:
|
||||||
SQL, name = index_utils.get_sql(
|
SQL, name = index_utils.get_sql(
|
||||||
self.conn, data, did, tid, idx, self.datlastsysoid)
|
self.conn, data, did, tid, idx, self.datlastsysoid)
|
||||||
if not isinstance(SQL, (str, unicode)):
|
if not isinstance(SQL, str):
|
||||||
return SQL
|
return SQL
|
||||||
SQL = SQL.strip('\n').strip(' ')
|
SQL = SQL.strip('\n').strip(' ')
|
||||||
status, res = self.conn.execute_scalar(SQL)
|
status, res = self.conn.execute_scalar(SQL)
|
||||||
@ -792,7 +787,7 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
sql, name = index_utils.get_sql(
|
sql, name = index_utils.get_sql(
|
||||||
self.conn, data, did, tid, idx, self.datlastsysoid,
|
self.conn, data, did, tid, idx, self.datlastsysoid,
|
||||||
mode='create')
|
mode='create')
|
||||||
if not isinstance(sql, (str, unicode)):
|
if not isinstance(sql, str):
|
||||||
return sql
|
return sql
|
||||||
sql = sql.strip('\n').strip(' ')
|
sql = sql.strip('\n').strip(' ')
|
||||||
if sql == '':
|
if sql == '':
|
||||||
|
@ -25,16 +25,11 @@ from pgadmin.utils.ajax import make_json_response, internal_server_error, \
|
|||||||
from pgadmin.utils.driver import get_driver
|
from pgadmin.utils.driver import get_driver
|
||||||
from config import PG_DEFAULT_DRIVER
|
from config import PG_DEFAULT_DRIVER
|
||||||
from pgadmin.utils.compile_template_name import compile_template_path
|
from pgadmin.utils.compile_template_name import compile_template_path
|
||||||
from pgadmin.utils import IS_PY2
|
|
||||||
from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry
|
from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry
|
||||||
from pgadmin.tools.schema_diff.compare import SchemaDiffObjectCompare
|
from pgadmin.tools.schema_diff.compare import SchemaDiffObjectCompare
|
||||||
from pgadmin.tools.schema_diff.directory_compare import directory_diff,\
|
from pgadmin.tools.schema_diff.directory_compare import directory_diff,\
|
||||||
parse_acl
|
parse_acl
|
||||||
|
|
||||||
# If we are in Python3
|
|
||||||
if not IS_PY2:
|
|
||||||
unicode = str
|
|
||||||
|
|
||||||
|
|
||||||
class RuleModule(CollectionNodeModule):
|
class RuleModule(CollectionNodeModule):
|
||||||
"""
|
"""
|
||||||
@ -379,7 +374,7 @@ class RuleView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
SQL, name = self.getSQL(gid, sid, data, tid, rid)
|
SQL, name = self.getSQL(gid, sid, data, tid, rid)
|
||||||
if not isinstance(SQL, (str, unicode)):
|
if not isinstance(SQL, str):
|
||||||
return SQL
|
return SQL
|
||||||
SQL = SQL.strip('\n').strip(' ')
|
SQL = SQL.strip('\n').strip(' ')
|
||||||
status, res = self.conn.execute_scalar(SQL)
|
status, res = self.conn.execute_scalar(SQL)
|
||||||
@ -461,7 +456,7 @@ class RuleView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
"""
|
"""
|
||||||
data = request.args
|
data = request.args
|
||||||
sql, name = self.getSQL(gid, sid, data, tid, rid)
|
sql, name = self.getSQL(gid, sid, data, tid, rid)
|
||||||
if not isinstance(sql, (str, unicode)):
|
if not isinstance(sql, str):
|
||||||
return sql
|
return sql
|
||||||
sql = sql.strip('\n').strip(' ')
|
sql = sql.strip('\n').strip(' ')
|
||||||
|
|
||||||
|
@ -26,16 +26,11 @@ from pgadmin.browser.server_groups.servers.databases.schemas.utils \
|
|||||||
from pgadmin.utils.driver import get_driver
|
from pgadmin.utils.driver import get_driver
|
||||||
from config import PG_DEFAULT_DRIVER
|
from config import PG_DEFAULT_DRIVER
|
||||||
from pgadmin.utils.compile_template_name import compile_template_path
|
from pgadmin.utils.compile_template_name import compile_template_path
|
||||||
from pgadmin.utils import IS_PY2
|
|
||||||
from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry
|
from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry
|
||||||
from pgadmin.tools.schema_diff.compare import SchemaDiffObjectCompare
|
from pgadmin.tools.schema_diff.compare import SchemaDiffObjectCompare
|
||||||
from pgadmin.tools.schema_diff.directory_compare import directory_diff,\
|
from pgadmin.tools.schema_diff.directory_compare import directory_diff,\
|
||||||
parse_acl
|
parse_acl
|
||||||
|
|
||||||
# If we are in Python3
|
|
||||||
if not IS_PY2:
|
|
||||||
unicode = str
|
|
||||||
|
|
||||||
|
|
||||||
class TriggerModule(CollectionNodeModule):
|
class TriggerModule(CollectionNodeModule):
|
||||||
"""
|
"""
|
||||||
@ -675,7 +670,7 @@ class TriggerView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
self.conn, data, tid, trid, self.datlastsysoid,
|
self.conn, data, tid, trid, self.datlastsysoid,
|
||||||
self.blueprint.show_system_objects)
|
self.blueprint.show_system_objects)
|
||||||
|
|
||||||
if not isinstance(SQL, (str, unicode)):
|
if not isinstance(SQL, str):
|
||||||
return SQL
|
return SQL
|
||||||
SQL = SQL.strip('\n').strip(' ')
|
SQL = SQL.strip('\n').strip(' ')
|
||||||
status, res = self.conn.execute_scalar(SQL)
|
status, res = self.conn.execute_scalar(SQL)
|
||||||
@ -756,7 +751,7 @@ class TriggerView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
sql, name = trigger_utils.get_sql(
|
sql, name = trigger_utils.get_sql(
|
||||||
self.conn, data, tid, trid, self.datlastsysoid,
|
self.conn, data, tid, trid, self.datlastsysoid,
|
||||||
self.blueprint.show_system_objects)
|
self.blueprint.show_system_objects)
|
||||||
if not isinstance(sql, (str, unicode)):
|
if not isinstance(sql, str):
|
||||||
return sql
|
return sql
|
||||||
sql = sql.strip('\n').strip(' ')
|
sql = sql.strip('\n').strip(' ')
|
||||||
|
|
||||||
@ -798,7 +793,7 @@ class TriggerView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
self.datlastsysoid,
|
self.datlastsysoid,
|
||||||
self.blueprint.show_system_objects, True)
|
self.blueprint.show_system_objects, True)
|
||||||
|
|
||||||
if not isinstance(SQL, (str, unicode)):
|
if not isinstance(SQL, str):
|
||||||
return SQL
|
return SQL
|
||||||
SQL = SQL.strip('\n').strip(' ')
|
SQL = SQL.strip('\n').strip(' ')
|
||||||
else:
|
else:
|
||||||
|
@ -25,7 +25,6 @@ from pgadmin.browser.server_groups.servers.databases.schemas.utils \
|
|||||||
from pgadmin.browser.server_groups.servers.utils import parse_priv_from_db, \
|
from pgadmin.browser.server_groups.servers.utils import parse_priv_from_db, \
|
||||||
parse_priv_to_db
|
parse_priv_to_db
|
||||||
from pgadmin.browser.utils import PGChildNodeView
|
from pgadmin.browser.utils import PGChildNodeView
|
||||||
from pgadmin.utils import IS_PY2
|
|
||||||
from pgadmin.utils.compile_template_name import compile_template_path
|
from pgadmin.utils.compile_template_name import compile_template_path
|
||||||
from pgadmin.utils.driver import get_driver
|
from pgadmin.utils.driver import get_driver
|
||||||
from config import PG_DEFAULT_DRIVER
|
from config import PG_DEFAULT_DRIVER
|
||||||
@ -753,14 +752,9 @@ class BaseTableView(PGChildNodeView, BasePartitionTable):
|
|||||||
Returns:
|
Returns:
|
||||||
Updated data dict
|
Updated data dict
|
||||||
"""
|
"""
|
||||||
# For Python2, it can be int, long, float
|
if isinstance(data['name'], (int, float)):
|
||||||
if IS_PY2 and hasattr(str, 'decode'):
|
data['name'] = str(data['name'])
|
||||||
if isinstance(data['name'], (int, long, float)):
|
|
||||||
data['name'] = str(data['name'])
|
|
||||||
else:
|
|
||||||
# For Python3, it can be int, float
|
|
||||||
if isinstance(data['name'], (int, float)):
|
|
||||||
data['name'] = str(data['name'])
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def get_sql(self, did, scid, tid, data, res):
|
def get_sql(self, did, scid, tid, data, res):
|
||||||
|
@ -22,17 +22,12 @@ from pgadmin.browser.server_groups.servers.databases.schemas.utils \
|
|||||||
from pgadmin.browser.server_groups.servers.utils import parse_priv_from_db, \
|
from pgadmin.browser.server_groups.servers.utils import parse_priv_from_db, \
|
||||||
parse_priv_to_db
|
parse_priv_to_db
|
||||||
from pgadmin.browser.utils import PGChildNodeView
|
from pgadmin.browser.utils import PGChildNodeView
|
||||||
from pgadmin.utils import IS_PY2
|
|
||||||
from pgadmin.utils.ajax import make_json_response, internal_server_error, \
|
from pgadmin.utils.ajax import make_json_response, internal_server_error, \
|
||||||
make_response as ajax_response, gone
|
make_response as ajax_response, gone
|
||||||
from pgadmin.utils.driver import get_driver
|
from pgadmin.utils.driver import get_driver
|
||||||
from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry
|
from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry
|
||||||
from pgadmin.tools.schema_diff.compare import SchemaDiffObjectCompare
|
from pgadmin.tools.schema_diff.compare import SchemaDiffObjectCompare
|
||||||
|
|
||||||
# If we are in Python3
|
|
||||||
if not IS_PY2:
|
|
||||||
unicode = str
|
|
||||||
|
|
||||||
|
|
||||||
class TypeModule(SchemaChildModule):
|
class TypeModule(SchemaChildModule):
|
||||||
"""
|
"""
|
||||||
@ -1046,7 +1041,7 @@ class TypeView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
|
|||||||
try:
|
try:
|
||||||
SQL, name = self.get_sql(gid, sid, data, scid, tid)
|
SQL, name = self.get_sql(gid, sid, data, scid, tid)
|
||||||
# Most probably this is due to error
|
# Most probably this is due to error
|
||||||
if not isinstance(SQL, (str, unicode)):
|
if not isinstance(SQL, str):
|
||||||
return SQL
|
return SQL
|
||||||
SQL = SQL.strip('\n').strip(' ')
|
SQL = SQL.strip('\n').strip(' ')
|
||||||
status, res = self.conn.execute_scalar(SQL)
|
status, res = self.conn.execute_scalar(SQL)
|
||||||
@ -1177,7 +1172,7 @@ class TypeView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
|
|||||||
try:
|
try:
|
||||||
sql, name = self.get_sql(gid, sid, data, scid, tid)
|
sql, name = self.get_sql(gid, sid, data, scid, tid)
|
||||||
# Most probably this is due to error
|
# Most probably this is due to error
|
||||||
if not isinstance(sql, (str, unicode)):
|
if not isinstance(sql, str):
|
||||||
return sql
|
return sql
|
||||||
sql = sql.strip('\n').strip(' ')
|
sql = sql.strip('\n').strip(' ')
|
||||||
|
|
||||||
@ -1414,7 +1409,7 @@ class TypeView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
|
|||||||
|
|
||||||
SQL, name = self.get_sql(gid, sid, data, scid, tid=None, is_sql=True)
|
SQL, name = self.get_sql(gid, sid, data, scid, tid=None, is_sql=True)
|
||||||
# Most probably this is due to error
|
# Most probably this is due to error
|
||||||
if not isinstance(SQL, (str, unicode)):
|
if not isinstance(SQL, str):
|
||||||
return SQL
|
return SQL
|
||||||
# We are appending headers here for sql panel
|
# We are appending headers here for sql panel
|
||||||
sql_header = u"-- Type: {0}\n\n-- ".format(data['name'])
|
sql_header = u"-- Type: {0}\n\n-- ".format(data['name'])
|
||||||
|
@ -22,10 +22,6 @@ from pgadmin.utils.ajax import make_json_response, \
|
|||||||
from pgadmin.utils.ajax import precondition_required
|
from pgadmin.utils.ajax import precondition_required
|
||||||
from pgadmin.utils.driver import get_driver
|
from pgadmin.utils.driver import get_driver
|
||||||
from config import PG_DEFAULT_DRIVER
|
from config import PG_DEFAULT_DRIVER
|
||||||
from pgadmin.utils import IS_PY2
|
|
||||||
# If we are in Python3
|
|
||||||
if not IS_PY2:
|
|
||||||
unicode = str
|
|
||||||
|
|
||||||
|
|
||||||
class ResourceGroupModule(CollectionNodeModule):
|
class ResourceGroupModule(CollectionNodeModule):
|
||||||
@ -563,7 +559,7 @@ class ResourceGroupView(NodeView):
|
|||||||
|
|
||||||
sql, name = self.get_sql(data, rg_id)
|
sql, name = self.get_sql(data, rg_id)
|
||||||
# Most probably this is due to error
|
# Most probably this is due to error
|
||||||
if not isinstance(sql, (str, unicode)):
|
if not isinstance(sql, str):
|
||||||
return sql
|
return sql
|
||||||
|
|
||||||
sql = sql.strip('\n').strip(' ')
|
sql = sql.strip('\n').strip(' ')
|
||||||
|
@ -22,10 +22,6 @@ from pgadmin.utils.ajax import make_json_response, \
|
|||||||
from pgadmin.utils.ajax import precondition_required
|
from pgadmin.utils.ajax import precondition_required
|
||||||
from pgadmin.utils.driver import get_driver
|
from pgadmin.utils.driver import get_driver
|
||||||
from config import PG_DEFAULT_DRIVER
|
from config import PG_DEFAULT_DRIVER
|
||||||
from pgadmin.utils import IS_PY2
|
|
||||||
# If we are in Python3
|
|
||||||
if not IS_PY2:
|
|
||||||
unicode = str
|
|
||||||
|
|
||||||
|
|
||||||
class TablespaceModule(CollectionNodeModule):
|
class TablespaceModule(CollectionNodeModule):
|
||||||
@ -365,7 +361,7 @@ class TablespaceView(PGChildNodeView):
|
|||||||
try:
|
try:
|
||||||
SQL, name = self.get_sql(gid, sid, data, tsid)
|
SQL, name = self.get_sql(gid, sid, data, tsid)
|
||||||
# Most probably this is due to error
|
# Most probably this is due to error
|
||||||
if not isinstance(SQL, (str, unicode)):
|
if not isinstance(SQL, str):
|
||||||
return SQL
|
return SQL
|
||||||
|
|
||||||
SQL = SQL.strip('\n').strip(' ')
|
SQL = SQL.strip('\n').strip(' ')
|
||||||
@ -460,7 +456,7 @@ class TablespaceView(PGChildNodeView):
|
|||||||
|
|
||||||
sql, name = self.get_sql(gid, sid, data, tsid)
|
sql, name = self.get_sql(gid, sid, data, tsid)
|
||||||
# Most probably this is due to error
|
# Most probably this is due to error
|
||||||
if not isinstance(sql, (str, unicode)):
|
if not isinstance(sql, str):
|
||||||
return sql
|
return sql
|
||||||
|
|
||||||
sql = sql.strip('\n').strip(' ')
|
sql = sql.strip('\n').strip(' ')
|
||||||
|
@ -40,7 +40,6 @@ from threading import Thread
|
|||||||
import signal
|
import signal
|
||||||
|
|
||||||
_IS_WIN = (os.name == 'nt')
|
_IS_WIN = (os.name == 'nt')
|
||||||
_IS_PY2 = (sys.version_info[0] == 2)
|
|
||||||
_ZERO = timedelta(0)
|
_ZERO = timedelta(0)
|
||||||
_sys_encoding = None
|
_sys_encoding = None
|
||||||
_fs_encoding = None
|
_fs_encoding = None
|
||||||
@ -48,16 +47,12 @@ _u = None
|
|||||||
_out_dir = None
|
_out_dir = None
|
||||||
_log_file = None
|
_log_file = None
|
||||||
|
|
||||||
if _IS_PY2:
|
|
||||||
def _log(msg):
|
def _log(msg):
|
||||||
with open(_log_file, 'a') as fp:
|
with open(_log_file, 'a') as fp:
|
||||||
fp.write(('INFO:: %s\n' % str(msg)))
|
fp.write(
|
||||||
else:
|
('INFO:: %s\n' % msg.encode('ascii', 'xmlcharrefreplace'))
|
||||||
def _log(msg):
|
)
|
||||||
with open(_log_file, 'a') as fp:
|
|
||||||
fp.write(
|
|
||||||
('INFO:: %s\n' % msg.encode('ascii', 'xmlcharrefreplace'))
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def unescape_dquotes_process_arg(arg):
|
def unescape_dquotes_process_arg(arg):
|
||||||
@ -193,61 +188,32 @@ class ProcessLogger(Thread):
|
|||||||
self.process = process
|
self.process = process
|
||||||
self.stream = stream
|
self.stream = stream
|
||||||
|
|
||||||
if not _IS_PY2:
|
def log(self, msg):
|
||||||
def log(self, msg):
|
"""
|
||||||
"""
|
This function will update log file
|
||||||
This function will update log file
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
msg: message
|
msg: message
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
None
|
None
|
||||||
"""
|
"""
|
||||||
# Write into log file
|
# Write into log file
|
||||||
if self.logger:
|
if self.logger:
|
||||||
if msg:
|
if msg:
|
||||||
self.logger.write(
|
self.logger.write(
|
||||||
get_current_time(
|
get_current_time(
|
||||||
format='%y%m%d%H%M%S%f'
|
format='%y%m%d%H%M%S%f'
|
||||||
).encode('utf-8')
|
).encode('utf-8')
|
||||||
)
|
)
|
||||||
self.logger.write(b',')
|
self.logger.write(b',')
|
||||||
self.logger.write(
|
self.logger.write(
|
||||||
msg.lstrip(b'\r\n' if _IS_WIN else b'\n')
|
msg.lstrip(b'\r\n' if _IS_WIN else b'\n')
|
||||||
)
|
)
|
||||||
self.logger.write(os.linesep.encode('utf-8'))
|
self.logger.write(os.linesep.encode('utf-8'))
|
||||||
|
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
else:
|
|
||||||
def log(self, msg):
|
|
||||||
"""
|
|
||||||
This function will update log file
|
|
||||||
|
|
||||||
Args:
|
|
||||||
msg: message
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
None
|
|
||||||
"""
|
|
||||||
# Write into log file
|
|
||||||
if self.logger:
|
|
||||||
if msg:
|
|
||||||
self.logger.write(
|
|
||||||
b'{0},{1}{2}'.format(
|
|
||||||
get_current_time(
|
|
||||||
format='%y%m%d%H%M%S%f'
|
|
||||||
),
|
|
||||||
msg.lstrip(
|
|
||||||
b'\r\n' if _IS_WIN else b'\n'
|
|
||||||
),
|
|
||||||
os.linesep
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
if self.process and self.stream:
|
if self.process and self.stream:
|
||||||
@ -327,11 +293,7 @@ def execute(argv):
|
|||||||
kwargs['shell'] = True if _IS_WIN else False
|
kwargs['shell'] = True if _IS_WIN else False
|
||||||
|
|
||||||
# We need environment variables & values in string
|
# We need environment variables & values in string
|
||||||
if _IS_PY2:
|
kwargs['env'] = os.environ.copy()
|
||||||
_log('Converting the environment variable in the bytes format...')
|
|
||||||
kwargs['env'] = convert_environment_variables(os.environ.copy())
|
|
||||||
else:
|
|
||||||
kwargs['env'] = os.environ.copy()
|
|
||||||
|
|
||||||
_log('Starting the command execution...')
|
_log('Starting the command execution...')
|
||||||
process = Popen(
|
process = Popen(
|
||||||
@ -454,9 +416,6 @@ if __name__ == '__main__':
|
|||||||
_fs_encoding = 'utf-8'
|
_fs_encoding = 'utf-8'
|
||||||
|
|
||||||
def u(_s, _encoding=_sys_encoding):
|
def u(_s, _encoding=_sys_encoding):
|
||||||
if _IS_PY2:
|
|
||||||
if isinstance(_s, str):
|
|
||||||
return unicode(_s, _encoding)
|
|
||||||
return _s
|
return _s
|
||||||
_u = u
|
_u = u
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ from pickle import dumps, loads
|
|||||||
from subprocess import Popen, PIPE
|
from subprocess import Popen, PIPE
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from pgadmin.utils import IS_PY2, u, file_quote, fs_encoding, \
|
from pgadmin.utils import u, file_quote, fs_encoding, \
|
||||||
get_complete_file_path
|
get_complete_file_path
|
||||||
|
|
||||||
import pytz
|
import pytz
|
||||||
@ -32,10 +32,7 @@ from flask_security import current_user
|
|||||||
|
|
||||||
import config
|
import config
|
||||||
from pgadmin.model import Process, db
|
from pgadmin.model import Process, db
|
||||||
if IS_PY2:
|
from io import StringIO
|
||||||
from StringIO import StringIO
|
|
||||||
else:
|
|
||||||
from io import StringIO
|
|
||||||
|
|
||||||
PROCESS_NOT_STARTED = 0
|
PROCESS_NOT_STARTED = 0
|
||||||
PROCESS_STARTED = 1
|
PROCESS_STARTED = 1
|
||||||
@ -87,15 +84,7 @@ class BatchProcess(object):
|
|||||||
_("Could not find a process with the specified ID.")
|
_("Could not find a process with the specified ID.")
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
tmp_desc = loads(p.desc)
|
||||||
tmp_desc = loads(p.desc.encode('latin-1')) if \
|
|
||||||
IS_PY2 and hasattr(p.desc, 'encode') else loads(p.desc)
|
|
||||||
except UnicodeDecodeError:
|
|
||||||
tmp_desc = loads(p.desc.encode('utf-8')) if \
|
|
||||||
IS_PY2 and hasattr(p.desc, 'encode') else loads(p.desc)
|
|
||||||
except Exception as e:
|
|
||||||
tmp_desc = loads(p.desc.encode('utf-8', 'ignore')) if \
|
|
||||||
IS_PY2 and hasattr(p.desc, 'encode') else loads(p.desc)
|
|
||||||
|
|
||||||
# ID
|
# ID
|
||||||
self.id = _id
|
self.id = _id
|
||||||
@ -183,33 +172,15 @@ class BatchProcess(object):
|
|||||||
csv_writer = csv.writer(
|
csv_writer = csv.writer(
|
||||||
args_csv_io, delimiter=str(','), quoting=csv.QUOTE_MINIMAL
|
args_csv_io, delimiter=str(','), quoting=csv.QUOTE_MINIMAL
|
||||||
)
|
)
|
||||||
if sys.version_info[0] == 2:
|
csv_writer.writerow(_args)
|
||||||
csv_writer.writerow(
|
|
||||||
[
|
|
||||||
a.encode('utf-8')
|
|
||||||
if isinstance(a, unicode) else a for a in _args
|
|
||||||
]
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
csv_writer.writerow(_args)
|
|
||||||
|
|
||||||
args_val = args_csv_io.getvalue().strip(str('\r\n'))
|
args_val = args_csv_io.getvalue().strip(str('\r\n'))
|
||||||
tmp_desc = dumps(self.desc)
|
tmp_desc = dumps(self.desc)
|
||||||
try:
|
|
||||||
tmp_desc = tmp_desc.decode('utf-8') if \
|
|
||||||
IS_PY2 and hasattr(tmp_desc, 'decode') else tmp_desc
|
|
||||||
except UnicodeDecodeError:
|
|
||||||
tmp_desc = tmp_desc.decode('latin-1') if \
|
|
||||||
IS_PY2 and hasattr(tmp_desc, 'decode') else tmp_desc
|
|
||||||
except Exception:
|
|
||||||
tmp_desc = tmp_desc.decode('utf-8', 'ignore') if \
|
|
||||||
IS_PY2 and hasattr(tmp_desc, 'decode') else tmp_desc
|
|
||||||
|
|
||||||
j = Process(
|
j = Process(
|
||||||
pid=int(id),
|
pid=int(id),
|
||||||
command=_cmd,
|
command=_cmd,
|
||||||
arguments=args_val.decode('utf-8', 'replace')
|
arguments=args_val,
|
||||||
if IS_PY2 and hasattr(args_val, 'decode') else args_val,
|
|
||||||
logdir=log_dir,
|
logdir=log_dir,
|
||||||
desc=tmp_desc,
|
desc=tmp_desc,
|
||||||
user_id=current_user.id
|
user_id=current_user.id
|
||||||
@ -318,24 +289,10 @@ class BatchProcess(object):
|
|||||||
]
|
]
|
||||||
cmd.extend(self.args)
|
cmd.extend(self.args)
|
||||||
|
|
||||||
if os.name == 'nt' and IS_PY2:
|
current_app.logger.info(
|
||||||
command = []
|
u"Executing the process executor with the arguments: %s",
|
||||||
for c in cmd:
|
str(cmd)
|
||||||
command.append(
|
)
|
||||||
c.encode('utf-8') if isinstance(c, unicode) else str(c)
|
|
||||||
)
|
|
||||||
|
|
||||||
current_app.logger.info(
|
|
||||||
u"Executing the process executor with the arguments: %s",
|
|
||||||
''.join(command)
|
|
||||||
)
|
|
||||||
|
|
||||||
cmd = command
|
|
||||||
else:
|
|
||||||
current_app.logger.info(
|
|
||||||
u"Executing the process executor with the arguments: %s",
|
|
||||||
str(cmd)
|
|
||||||
)
|
|
||||||
|
|
||||||
# Make a copy of environment, and add new variables to support
|
# Make a copy of environment, and add new variables to support
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
@ -349,10 +306,6 @@ class BatchProcess(object):
|
|||||||
if cb is not None:
|
if cb is not None:
|
||||||
cb(env)
|
cb(env)
|
||||||
|
|
||||||
if IS_PY2:
|
|
||||||
# We need environment variables & values in string
|
|
||||||
env = convert_environment_variables(env)
|
|
||||||
|
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
DETACHED_PROCESS = 0x00000008
|
DETACHED_PROCESS = 0x00000008
|
||||||
from subprocess import CREATE_NEW_PROCESS_GROUP
|
from subprocess import CREATE_NEW_PROCESS_GROUP
|
||||||
@ -602,17 +555,7 @@ class BatchProcess(object):
|
|||||||
etime = parser.parse(p.end_time or get_current_time())
|
etime = parser.parse(p.end_time or get_current_time())
|
||||||
|
|
||||||
execution_time = BatchProcess.total_seconds(etime - stime)
|
execution_time = BatchProcess.total_seconds(etime - stime)
|
||||||
desc = ""
|
desc = loads(p.desc)
|
||||||
try:
|
|
||||||
desc = loads(p.desc.encode('latin-1')) if \
|
|
||||||
IS_PY2 and hasattr(p.desc, 'encode') else loads(p.desc)
|
|
||||||
except UnicodeDecodeError:
|
|
||||||
desc = loads(p.desc.encode('utf-8')) if \
|
|
||||||
IS_PY2 and hasattr(p.desc, 'encode') else loads(p.desc)
|
|
||||||
except Exception:
|
|
||||||
desc = loads(p.desc.encode('utf-8', 'ignore')) if \
|
|
||||||
IS_PY2 and hasattr(p.desc, 'encode') else loads(p.desc)
|
|
||||||
|
|
||||||
details = desc
|
details = desc
|
||||||
|
|
||||||
if isinstance(desc, IProcessDesc):
|
if isinstance(desc, IProcessDesc):
|
||||||
|
@ -98,9 +98,7 @@ def splitext(path):
|
|||||||
def is_folder_hidden(filepath):
|
def is_folder_hidden(filepath):
|
||||||
if _platform == "win32":
|
if _platform == "win32":
|
||||||
try:
|
try:
|
||||||
attrs = ctypes.windll.kernel32.GetFileAttributesW(
|
attrs = ctypes.windll.kernel32.GetFileAttributesW(filepath)
|
||||||
unicode(filepath) if sys.version_info[0] < 3 else filepath
|
|
||||||
)
|
|
||||||
assert attrs != -1
|
assert attrs != -1
|
||||||
result = bool(attrs & 2)
|
result = bool(attrs & 2)
|
||||||
except (AttributeError, AssertionError):
|
except (AttributeError, AssertionError):
|
||||||
|
@ -52,11 +52,6 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
from urllib.parse import unquote
|
from urllib.parse import unquote
|
||||||
|
|
||||||
if sys.version_info[0:2] <= (2, 7):
|
|
||||||
IS_PY2 = True
|
|
||||||
else:
|
|
||||||
IS_PY2 = False
|
|
||||||
|
|
||||||
|
|
||||||
class SqlEditorModule(PgAdminModule):
|
class SqlEditorModule(PgAdminModule):
|
||||||
"""
|
"""
|
||||||
@ -321,8 +316,7 @@ def extract_sql_from_network_parameters(request_data, request_arguments,
|
|||||||
if request_data:
|
if request_data:
|
||||||
sql_parameters = json.loads(request_data, encoding='utf-8')
|
sql_parameters = json.loads(request_data, encoding='utf-8')
|
||||||
|
|
||||||
if (IS_PY2 and type(sql_parameters) is unicode) \
|
if type(sql_parameters) is str:
|
||||||
or type(sql_parameters) is str:
|
|
||||||
return dict(sql=str(sql_parameters), explain_plan=None)
|
return dict(sql=str(sql_parameters), explain_plan=None)
|
||||||
return sql_parameters
|
return sql_parameters
|
||||||
else:
|
else:
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
from pgadmin.utils.ajax import make_json_response
|
from pgadmin.utils.ajax import make_json_response
|
||||||
from pgadmin.model import db, QueryHistoryModel
|
from pgadmin.model import db, QueryHistoryModel
|
||||||
from config import MAX_QUERY_HIST_STORED
|
from config import MAX_QUERY_HIST_STORED
|
||||||
from pgadmin.utils import IS_PY2
|
|
||||||
|
|
||||||
|
|
||||||
class QueryHistory:
|
class QueryHistory:
|
||||||
@ -15,11 +14,7 @@ class QueryHistory:
|
|||||||
QueryHistoryModel.dbname == dbname) \
|
QueryHistoryModel.dbname == dbname) \
|
||||||
.all()
|
.all()
|
||||||
|
|
||||||
# In Python 2.7, rec.query_info has buffer data type. Cast it.
|
result = [rec.query_info for rec in list(result)]
|
||||||
if IS_PY2:
|
|
||||||
result = [bytes(rec.query_info) for rec in list(result)]
|
|
||||||
else:
|
|
||||||
result = [rec.query_info for rec in list(result)]
|
|
||||||
|
|
||||||
return make_json_response(
|
return make_json_response(
|
||||||
data={
|
data={
|
||||||
|
@ -158,7 +158,6 @@ class PgAdminModule(Blueprint):
|
|||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
||||||
IS_PY2 = (sys.version_info[0] == 2)
|
|
||||||
IS_WIN = (os.name == 'nt')
|
IS_WIN = (os.name == 'nt')
|
||||||
|
|
||||||
sys_encoding = sys.getdefaultencoding()
|
sys_encoding = sys.getdefaultencoding()
|
||||||
@ -175,16 +174,10 @@ if not fs_encoding or fs_encoding == 'ascii':
|
|||||||
|
|
||||||
|
|
||||||
def u(_s, _encoding=sys_encoding):
|
def u(_s, _encoding=sys_encoding):
|
||||||
if IS_PY2:
|
|
||||||
if isinstance(_s, str):
|
|
||||||
return unicode(_s, _encoding)
|
|
||||||
return _s
|
return _s
|
||||||
|
|
||||||
|
|
||||||
def file_quote(_p):
|
def file_quote(_p):
|
||||||
if IS_PY2:
|
|
||||||
if isinstance(_p, unicode):
|
|
||||||
return _p.encode(fs_encoding)
|
|
||||||
return _p
|
return _p
|
||||||
|
|
||||||
|
|
||||||
@ -192,25 +185,10 @@ if IS_WIN:
|
|||||||
import ctypes
|
import ctypes
|
||||||
from ctypes import wintypes
|
from ctypes import wintypes
|
||||||
|
|
||||||
if IS_PY2:
|
def env(name):
|
||||||
def env(name):
|
if name in os.environ:
|
||||||
if IS_PY2:
|
return os.environ[name]
|
||||||
# Make sure string argument is unicode
|
return None
|
||||||
name = unicode(name)
|
|
||||||
n = ctypes.windll.kernel32.GetEnvironmentVariableW(name, None, 0)
|
|
||||||
|
|
||||||
if n == 0:
|
|
||||||
return None
|
|
||||||
|
|
||||||
buf = ctypes.create_unicode_buffer(u'\0' * n)
|
|
||||||
ctypes.windll.kernel32.GetEnvironmentVariableW(name, buf, n)
|
|
||||||
|
|
||||||
return buf.value
|
|
||||||
else:
|
|
||||||
def env(name):
|
|
||||||
if name in os.environ:
|
|
||||||
return os.environ[name]
|
|
||||||
return None
|
|
||||||
|
|
||||||
_GetShortPathNameW = ctypes.windll.kernel32.GetShortPathNameW
|
_GetShortPathNameW = ctypes.windll.kernel32.GetShortPathNameW
|
||||||
_GetShortPathNameW.argtypes = [
|
_GetShortPathNameW.argtypes = [
|
||||||
|
@ -75,17 +75,10 @@ from csv import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Stuff needed from six
|
# Stuff needed from six
|
||||||
import sys
|
string_types = str
|
||||||
PY3 = sys.version_info[0] == 3
|
text_type = str
|
||||||
if PY3:
|
binary_type = bytes
|
||||||
string_types = str
|
unichr = chr
|
||||||
text_type = str
|
|
||||||
binary_type = bytes
|
|
||||||
unichr = chr
|
|
||||||
else:
|
|
||||||
string_types = basestring
|
|
||||||
text_type = unicode
|
|
||||||
binary_type = str
|
|
||||||
|
|
||||||
|
|
||||||
class QuoteStrategy(object):
|
class QuoteStrategy(object):
|
||||||
|
@ -15,7 +15,6 @@ object.
|
|||||||
|
|
||||||
import random
|
import random
|
||||||
import select
|
import select
|
||||||
import sys
|
|
||||||
import six
|
import six
|
||||||
import datetime
|
import datetime
|
||||||
from collections import deque
|
from collections import deque
|
||||||
@ -39,13 +38,7 @@ from .typecast import register_global_typecasters, \
|
|||||||
from .encoding import getEncoding, configureDriverEncodings
|
from .encoding import getEncoding, configureDriverEncodings
|
||||||
from pgadmin.utils import csv
|
from pgadmin.utils import csv
|
||||||
from pgadmin.utils.master_password import get_crypt_key
|
from pgadmin.utils.master_password import get_crypt_key
|
||||||
|
from io import StringIO
|
||||||
if sys.version_info < (3,):
|
|
||||||
from StringIO import StringIO
|
|
||||||
IS_PY2 = True
|
|
||||||
else:
|
|
||||||
from io import StringIO
|
|
||||||
IS_PY2 = False
|
|
||||||
|
|
||||||
_ = gettext
|
_ = gettext
|
||||||
|
|
||||||
@ -692,8 +685,7 @@ WHERE
|
|||||||
u"{conn_id} (Query-id: {query_id}):\n{query}".format(
|
u"{conn_id} (Query-id: {query_id}):\n{query}".format(
|
||||||
server_id=self.manager.sid,
|
server_id=self.manager.sid,
|
||||||
conn_id=self.conn_id,
|
conn_id=self.conn_id,
|
||||||
query=query.decode(self.python_encoding) if
|
query=query,
|
||||||
sys.version_info < (3,) else query,
|
|
||||||
query_id=query_id
|
query_id=query_id
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -721,33 +713,6 @@ WHERE
|
|||||||
return False, \
|
return False, \
|
||||||
gettext('The query executed did not return any data.')
|
gettext('The query executed did not return any data.')
|
||||||
|
|
||||||
def handle_json_data(json_columns, results):
|
|
||||||
"""
|
|
||||||
[ This is only for Python2.x]
|
|
||||||
This function will be useful to handle json data types.
|
|
||||||
We will dump json data as proper json instead of unicode values
|
|
||||||
|
|
||||||
Args:
|
|
||||||
json_columns: Columns which contains json data
|
|
||||||
results: Query result
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
results
|
|
||||||
"""
|
|
||||||
# Only if Python2 and there are columns with JSON type
|
|
||||||
if IS_PY2 and len(json_columns) > 0:
|
|
||||||
temp_results = []
|
|
||||||
for row in results:
|
|
||||||
res = dict()
|
|
||||||
for k, v in row.items():
|
|
||||||
if k in json_columns:
|
|
||||||
res[k] = json.dumps(v)
|
|
||||||
else:
|
|
||||||
res[k] = v
|
|
||||||
temp_results.append(res)
|
|
||||||
results = temp_results
|
|
||||||
return results
|
|
||||||
|
|
||||||
def convert_keys_to_unicode(results, conn_encoding):
|
def convert_keys_to_unicode(results, conn_encoding):
|
||||||
"""
|
"""
|
||||||
[ This is only for Python2.x]
|
[ This is only for Python2.x]
|
||||||
@ -809,15 +774,10 @@ WHERE
|
|||||||
for c in cur.ordered_description():
|
for c in cur.ordered_description():
|
||||||
# This is to handle the case in which column name is non-ascii
|
# This is to handle the case in which column name is non-ascii
|
||||||
column_name = c.to_dict()['name']
|
column_name = c.to_dict()['name']
|
||||||
if IS_PY2:
|
|
||||||
column_name = column_name.decode(conn_encoding)
|
|
||||||
header.append(column_name)
|
header.append(column_name)
|
||||||
if c.to_dict()['type_code'] in ALL_JSON_TYPES:
|
if c.to_dict()['type_code'] in ALL_JSON_TYPES:
|
||||||
json_columns.append(column_name)
|
json_columns.append(column_name)
|
||||||
|
|
||||||
if IS_PY2:
|
|
||||||
results = convert_keys_to_unicode(results, conn_encoding)
|
|
||||||
|
|
||||||
res_io = StringIO()
|
res_io = StringIO()
|
||||||
|
|
||||||
if quote == 'strings':
|
if quote == 'strings':
|
||||||
@ -848,7 +808,6 @@ WHERE
|
|||||||
)
|
)
|
||||||
|
|
||||||
csv_writer.writeheader()
|
csv_writer.writeheader()
|
||||||
results = handle_json_data(json_columns, results)
|
|
||||||
# Replace the null values with given string if configured.
|
# Replace the null values with given string if configured.
|
||||||
if replace_nulls_with is not None:
|
if replace_nulls_with is not None:
|
||||||
results = handle_null_values(results, replace_nulls_with)
|
results = handle_null_values(results, replace_nulls_with)
|
||||||
@ -872,10 +831,6 @@ WHERE
|
|||||||
replace_nulls_with=replace_nulls_with
|
replace_nulls_with=replace_nulls_with
|
||||||
)
|
)
|
||||||
|
|
||||||
if IS_PY2:
|
|
||||||
results = convert_keys_to_unicode(results, conn_encoding)
|
|
||||||
|
|
||||||
results = handle_json_data(json_columns, results)
|
|
||||||
# Replace the null values with given string if configured.
|
# Replace the null values with given string if configured.
|
||||||
if replace_nulls_with is not None:
|
if replace_nulls_with is not None:
|
||||||
results = handle_null_values(results, replace_nulls_with)
|
results = handle_null_values(results, replace_nulls_with)
|
||||||
|
@ -12,8 +12,6 @@ Typecast various data types so that they can be compatible with Javascript
|
|||||||
data types.
|
data types.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import sys
|
|
||||||
|
|
||||||
from psycopg2 import STRING as _STRING
|
from psycopg2 import STRING as _STRING
|
||||||
import psycopg2
|
import psycopg2
|
||||||
from psycopg2.extensions import encodings
|
from psycopg2.extensions import encodings
|
||||||
@ -124,10 +122,6 @@ PSYCOPG_SUPPORTED_RANGE_ARRAY_TYPES = (3905, 3927, 3907, 3913, 3909, 3911)
|
|||||||
|
|
||||||
|
|
||||||
def register_global_typecasters():
|
def register_global_typecasters():
|
||||||
if sys.version_info < (3,):
|
|
||||||
psycopg2.extensions.register_type(psycopg2.extensions.UNICODE)
|
|
||||||
psycopg2.extensions.register_type(psycopg2.extensions.UNICODEARRAY)
|
|
||||||
|
|
||||||
unicode_type_for_record = psycopg2.extensions.new_type(
|
unicode_type_for_record = psycopg2.extensions.new_type(
|
||||||
(2249,),
|
(2249,),
|
||||||
"RECORD",
|
"RECORD",
|
||||||
@ -186,19 +180,12 @@ def register_string_typecasters(connection):
|
|||||||
postgres_encoding, python_encoding, typecast_encoding = \
|
postgres_encoding, python_encoding, typecast_encoding = \
|
||||||
getEncoding(connection.encoding)
|
getEncoding(connection.encoding)
|
||||||
if postgres_encoding != 'UNICODE':
|
if postgres_encoding != 'UNICODE':
|
||||||
if sys.version_info >= (3,):
|
def non_ascii_escape(value, cursor):
|
||||||
def non_ascii_escape(value, cursor):
|
if value is None:
|
||||||
if value is None:
|
return None
|
||||||
return None
|
return bytes(
|
||||||
return bytes(
|
value, encodings[cursor.connection.encoding]
|
||||||
value, encodings[cursor.connection.encoding]
|
).decode(typecast_encoding, errors='replace')
|
||||||
).decode(typecast_encoding, errors='replace')
|
|
||||||
else:
|
|
||||||
def non_ascii_escape(value, cursor):
|
|
||||||
if value is None:
|
|
||||||
return None
|
|
||||||
return value.decode(typecast_encoding, errors='replace')
|
|
||||||
# return value
|
|
||||||
|
|
||||||
unicode_type = psycopg2.extensions.new_type(
|
unicode_type = psycopg2.extensions.new_type(
|
||||||
# "char", name, text, character, character varying
|
# "char", name, text, character, character varying
|
||||||
|
@ -9,31 +9,20 @@
|
|||||||
|
|
||||||
"""Utilities for HTML"""
|
"""Utilities for HTML"""
|
||||||
|
|
||||||
from pgadmin.utils import IS_PY2
|
from html import escape as html_escape
|
||||||
|
|
||||||
if IS_PY2:
|
|
||||||
from cgi import escape as html_escape
|
|
||||||
else:
|
|
||||||
from html import escape as html_escape
|
|
||||||
|
|
||||||
|
|
||||||
def safe_str(x):
|
def safe_str(x):
|
||||||
try:
|
try:
|
||||||
# For Python2, it can be int, long, float
|
# For Python3, it can be int, float
|
||||||
if IS_PY2:
|
if isinstance(x, (int, float)):
|
||||||
if isinstance(x, (int, long, float)):
|
x = str(x)
|
||||||
x = str(x)
|
|
||||||
else:
|
|
||||||
# For Python3, it can be int, float
|
|
||||||
if isinstance(x, (int, float)):
|
|
||||||
x = str(x)
|
|
||||||
|
|
||||||
x = x.encode(
|
x = x.encode(
|
||||||
'ascii', 'xmlcharrefreplace'
|
'ascii', 'xmlcharrefreplace'
|
||||||
) if hasattr(x, 'encode') else x
|
) if hasattr(x, 'encode') else x
|
||||||
|
|
||||||
if not IS_PY2:
|
x = x.decode('utf-8')
|
||||||
x = x.decode('utf-8')
|
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
return html_escape(x, False)
|
return html_escape(x, False)
|
||||||
|
@ -9,13 +9,7 @@ from .parseutils.utils import (
|
|||||||
from .parseutils.tables import extract_tables
|
from .parseutils.tables import extract_tables
|
||||||
from .parseutils.ctes import isolate_query_ctes
|
from .parseutils.ctes import isolate_query_ctes
|
||||||
|
|
||||||
PY2 = sys.version_info[0] == 2
|
string_types = str
|
||||||
PY3 = sys.version_info[0] == 3
|
|
||||||
|
|
||||||
if PY3:
|
|
||||||
string_types = str
|
|
||||||
else:
|
|
||||||
string_types = basestring
|
|
||||||
|
|
||||||
|
|
||||||
Special = namedtuple('Special', [])
|
Special = namedtuple('Special', [])
|
||||||
|
@ -14,14 +14,10 @@ import argparse
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import builtins
|
||||||
from pgadmin.model import db, User, Version, ServerGroup, Server, \
|
from pgadmin.model import db, User, Version, ServerGroup, Server, \
|
||||||
SCHEMA_VERSION as CURRENT_SCHEMA_VERSION
|
SCHEMA_VERSION as CURRENT_SCHEMA_VERSION
|
||||||
|
|
||||||
if sys.version_info[0] >= 3:
|
|
||||||
import builtins
|
|
||||||
else:
|
|
||||||
import __builtin__ as builtins
|
|
||||||
|
|
||||||
# Grab the SERVER_MODE if it's been set by the runtime
|
# Grab the SERVER_MODE if it's been set by the runtime
|
||||||
if 'SERVER_MODE' in globals():
|
if 'SERVER_MODE' in globals():
|
||||||
builtins.SERVER_MODE = globals()['SERVER_MODE']
|
builtins.SERVER_MODE = globals()['SERVER_MODE']
|
||||||
|
Loading…
Reference in New Issue
Block a user