PEP8 fixes.
parent
51811a451d
commit
43d3e0ca64
|
@ -291,10 +291,10 @@ def create_app(app_name=None):
|
||||||
# Setup authentication
|
# Setup authentication
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
app.config['SQLALCHEMY_DATABASE_URI'] = u'sqlite:///{0}?timeout={1}'.format(
|
app.config['SQLALCHEMY_DATABASE_URI'] = u'sqlite:///{0}?timeout={1}'\
|
||||||
config.SQLITE_PATH.replace(u'\\', u'/'),
|
.format(config.SQLITE_PATH.replace(u'\\', u'/'),
|
||||||
getattr(config, 'SQLITE_TIMEOUT', 500)
|
getattr(config, 'SQLITE_TIMEOUT', 500)
|
||||||
)
|
)
|
||||||
|
|
||||||
# Create database connection object and mailer
|
# Create database connection object and mailer
|
||||||
db.init_app(app)
|
db.init_app(app)
|
||||||
|
@ -406,7 +406,8 @@ def create_app(app_name=None):
|
||||||
servergroup_id = servergroup.id
|
servergroup_id = servergroup.id
|
||||||
|
|
||||||
'''Add a server to the config database'''
|
'''Add a server to the config database'''
|
||||||
def add_server(user_id, servergroup_id, name, superuser, port, discovery_id, comment):
|
def add_server(user_id, servergroup_id, name, superuser, port,
|
||||||
|
discovery_id, comment):
|
||||||
# Create a server object if needed, and store it.
|
# Create a server object if needed, and store it.
|
||||||
servers = Server.query.filter_by(
|
servers = Server.query.filter_by(
|
||||||
user_id=user_id,
|
user_id=user_id,
|
||||||
|
@ -437,7 +438,7 @@ def create_app(app_name=None):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
proc_arch64 = os.environ['PROCESSOR_ARCHITEW6432'].lower()
|
proc_arch64 = os.environ['PROCESSOR_ARCHITEW6432'].lower()
|
||||||
except:
|
except Exception as e:
|
||||||
proc_arch64 = None
|
proc_arch64 = None
|
||||||
|
|
||||||
if proc_arch == 'x86' and not proc_arch64:
|
if proc_arch == 'x86' and not proc_arch64:
|
||||||
|
@ -467,7 +468,8 @@ def create_app(app_name=None):
|
||||||
svr_port = winreg.QueryValueEx(inst_key, 'Port')[0]
|
svr_port = winreg.QueryValueEx(inst_key, 'Port')[0]
|
||||||
svr_discovery_id = inst_id
|
svr_discovery_id = inst_id
|
||||||
svr_comment = gettext(
|
svr_comment = gettext(
|
||||||
"Auto-detected %s installation with the data directory at %s" % (
|
"Auto-detected %s installation with the data "
|
||||||
|
"directory at %s" % (
|
||||||
winreg.QueryValueEx(
|
winreg.QueryValueEx(
|
||||||
inst_key, 'Display Name'
|
inst_key, 'Display Name'
|
||||||
)[0],
|
)[0],
|
||||||
|
@ -484,7 +486,7 @@ def create_app(app_name=None):
|
||||||
)
|
)
|
||||||
|
|
||||||
inst_key.Close()
|
inst_key.Close()
|
||||||
except:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
# We use the postgres-winreg.ini file on non-Windows
|
# We use the postgres-winreg.ini file on non-Windows
|
||||||
|
@ -501,7 +503,8 @@ def create_app(app_name=None):
|
||||||
|
|
||||||
# Loop the sections, and get the data from any that are PG or PPAS
|
# Loop the sections, and get the data from any that are PG or PPAS
|
||||||
for section in sections:
|
for section in sections:
|
||||||
if section.startswith('PostgreSQL/') or section.startswith('EnterpriseDB/'):
|
if section.startswith('PostgreSQL/') \
|
||||||
|
or section.startswith('EnterpriseDB/'):
|
||||||
svr_name = registry.get(section, 'Description')
|
svr_name = registry.get(section, 'Description')
|
||||||
svr_superuser = registry.get(section, 'Superuser')
|
svr_superuser = registry.get(section, 'Superuser')
|
||||||
svr_port = registry.getint(section, 'Port')
|
svr_port = registry.getint(section, 'Port')
|
||||||
|
@ -511,14 +514,17 @@ def create_app(app_name=None):
|
||||||
if hasattr(str, 'decode'):
|
if hasattr(str, 'decode'):
|
||||||
description = description.decode('utf-8')
|
description = description.decode('utf-8')
|
||||||
data_directory = data_directory.decode('utf-8')
|
data_directory = data_directory.decode('utf-8')
|
||||||
svr_comment = gettext(u"Auto-detected %s installation with the data directory at %s" % (
|
svr_comment = gettext(u"Auto-detected %s installation "
|
||||||
description,
|
u"with the data directory at %s" % (
|
||||||
data_directory
|
description,
|
||||||
))
|
data_directory
|
||||||
|
)
|
||||||
|
)
|
||||||
add_server(user_id, servergroup_id, svr_name,
|
add_server(user_id, servergroup_id, svr_name,
|
||||||
svr_superuser, svr_port, svr_discovery_id, svr_comment)
|
svr_superuser, svr_port, svr_discovery_id,
|
||||||
|
svr_comment)
|
||||||
|
|
||||||
except:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@user_logged_in.connect_via(app)
|
@user_logged_in.connect_via(app)
|
||||||
|
@ -545,7 +551,8 @@ def create_app(app_name=None):
|
||||||
# mode, and it's not a help file request.
|
# mode, and it's not a help file request.
|
||||||
if not config.SERVER_MODE and app.PGADMIN_KEY != '':
|
if not config.SERVER_MODE and app.PGADMIN_KEY != '':
|
||||||
if (
|
if (
|
||||||
(not 'key' in request.args or request.args['key'] != app.PGADMIN_KEY) and
|
('key' not in request.args or
|
||||||
|
request.args['key'] != app.PGADMIN_KEY) and
|
||||||
request.cookies.get('PGADMIN_KEY') != app.PGADMIN_KEY and
|
request.cookies.get('PGADMIN_KEY') != app.PGADMIN_KEY and
|
||||||
request.endpoint != 'help.static'
|
request.endpoint != 'help.static'
|
||||||
):
|
):
|
||||||
|
@ -558,7 +565,8 @@ def create_app(app_name=None):
|
||||||
# that'll through a nice 500 error for us.
|
# that'll through a nice 500 error for us.
|
||||||
if user is None:
|
if user is None:
|
||||||
app.logger.error(
|
app.logger.error(
|
||||||
'The desktop user %s was not found in the configuration database.'
|
'The desktop user %s was not found in the configuration '
|
||||||
|
'database.'
|
||||||
% config.DESKTOP_USER
|
% config.DESKTOP_USER
|
||||||
)
|
)
|
||||||
abort(401)
|
abort(401)
|
||||||
|
|
|
@ -13,10 +13,10 @@ from abc import ABCMeta, abstractmethod, abstractproperty
|
||||||
import six
|
import six
|
||||||
from socket import error as SOCKETErrorException
|
from socket import error as SOCKETErrorException
|
||||||
from smtplib import SMTPConnectError, SMTPResponseException,\
|
from smtplib import SMTPConnectError, SMTPResponseException,\
|
||||||
SMTPServerDisconnected, SMTPDataError,SMTPHeloError, SMTPException, \
|
SMTPServerDisconnected, SMTPDataError, SMTPHeloError, SMTPException, \
|
||||||
SMTPAuthenticationError, SMTPSenderRefused, SMTPRecipientsRefused
|
SMTPAuthenticationError, SMTPSenderRefused, SMTPRecipientsRefused
|
||||||
from flask import current_app, render_template, url_for, make_response, flash,\
|
from flask import current_app, render_template, url_for, make_response, \
|
||||||
Response, request, after_this_request, redirect
|
flash, Response, request, after_this_request, redirect
|
||||||
from flask_babel import gettext
|
from flask_babel import gettext
|
||||||
from flask_login import current_user, login_required
|
from flask_login import current_user, login_required
|
||||||
from flask_security.decorators import anonymous_user_required
|
from flask_security.decorators import anonymous_user_required
|
||||||
|
@ -40,7 +40,7 @@ from pgadmin import current_blueprint
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import urllib.request as urlreq
|
import urllib.request as urlreq
|
||||||
except:
|
except ImportError as e:
|
||||||
import urllib2 as urlreq
|
import urllib2 as urlreq
|
||||||
|
|
||||||
MODULE_NAME = 'browser'
|
MODULE_NAME = 'browser'
|
||||||
|
@ -55,10 +55,13 @@ class BrowserModule(PgAdminModule):
|
||||||
for (endpoint, filename) in [
|
for (endpoint, filename) in [
|
||||||
('static', 'vendor/codemirror/codemirror.css'),
|
('static', 'vendor/codemirror/codemirror.css'),
|
||||||
('static', 'vendor/codemirror/addon/dialog/dialog.css'),
|
('static', 'vendor/codemirror/addon/dialog/dialog.css'),
|
||||||
('static', 'vendor/jQuery-contextMenu/jquery.contextMenu.css' if current_app.debug
|
('static', 'vendor/jQuery-contextMenu/jquery.contextMenu.css'
|
||||||
else 'vendor/jQuery-contextMenu/jquery.contextMenu.min.css'),
|
if current_app.debug
|
||||||
('static', 'vendor/wcDocker/wcDocker.css' if current_app.debug
|
else
|
||||||
else 'vendor/wcDocker/wcDocker.min.css'),
|
'vendor/jQuery-contextMenu/jquery.contextMenu.min.css'),
|
||||||
|
('static', 'vendor/wcDocker/wcDocker.css'
|
||||||
|
if current_app.debug
|
||||||
|
else 'vendor/wcDocker/wcDocker.min.css'),
|
||||||
('browser.static', 'css/browser.css'),
|
('browser.static', 'css/browser.css'),
|
||||||
('browser.static', 'vendor/aciTree/css/aciTree.css')
|
('browser.static', 'vendor/aciTree/css/aciTree.css')
|
||||||
]:
|
]:
|
||||||
|
@ -82,8 +85,8 @@ class BrowserModule(PgAdminModule):
|
||||||
'name': 'jqueryui.position',
|
'name': 'jqueryui.position',
|
||||||
'path': url_for(
|
'path': url_for(
|
||||||
'static',
|
'static',
|
||||||
filename='vendor/jQuery-contextMenu/jquery.ui.position' if \
|
filename='vendor/jQuery-contextMenu/jquery.ui.position' if
|
||||||
current_app.debug else \
|
current_app.debug else
|
||||||
'vendor/jQuery-contextMenu/jquery.ui.position.min'
|
'vendor/jQuery-contextMenu/jquery.ui.position.min'
|
||||||
),
|
),
|
||||||
'deps': ['jquery'],
|
'deps': ['jquery'],
|
||||||
|
@ -94,8 +97,8 @@ class BrowserModule(PgAdminModule):
|
||||||
'name': 'jquery.contextmenu',
|
'name': 'jquery.contextmenu',
|
||||||
'path': url_for(
|
'path': url_for(
|
||||||
'static',
|
'static',
|
||||||
filename='vendor/jQuery-contextMenu/jquery.contextMenu' if \
|
filename='vendor/jQuery-contextMenu/jquery.contextMenu' if
|
||||||
current_app.debug else \
|
current_app.debug else
|
||||||
'vendor/jQuery-contextMenu/jquery.contextMenu.min'
|
'vendor/jQuery-contextMenu/jquery.contextMenu.min'
|
||||||
),
|
),
|
||||||
'deps': ['jquery', 'jqueryui.position'],
|
'deps': ['jquery', 'jqueryui.position'],
|
||||||
|
@ -164,9 +167,9 @@ class BrowserModule(PgAdminModule):
|
||||||
})
|
})
|
||||||
|
|
||||||
for name, script in [
|
for name, script in [
|
||||||
['pgadmin.browser', 'js/browser'],
|
['pgadmin.browser', 'js/browser'],
|
||||||
['pgadmin.browser.endpoints', 'js/endpoints'],
|
['pgadmin.browser.endpoints', 'js/endpoints'],
|
||||||
['pgadmin.browser.error', 'js/error']]:
|
['pgadmin.browser.error', 'js/error']]:
|
||||||
scripts.append({
|
scripts.append({
|
||||||
'name': name,
|
'name': name,
|
||||||
'path': url_for('browser.index') + script,
|
'path': url_for('browser.index') + script,
|
||||||
|
@ -174,9 +177,9 @@ class BrowserModule(PgAdminModule):
|
||||||
})
|
})
|
||||||
|
|
||||||
for name, script in [
|
for name, script in [
|
||||||
['pgadmin.browser.node', 'js/node'],
|
['pgadmin.browser.node', 'js/node'],
|
||||||
['pgadmin.browser.messages', 'js/messages'],
|
['pgadmin.browser.messages', 'js/messages'],
|
||||||
['pgadmin.browser.collection', 'js/collection']]:
|
['pgadmin.browser.collection', 'js/collection']]:
|
||||||
scripts.append({
|
scripts.append({
|
||||||
'name': name,
|
'name': name,
|
||||||
'path': url_for('browser.index') + script,
|
'path': url_for('browser.index') + script,
|
||||||
|
@ -185,9 +188,9 @@ class BrowserModule(PgAdminModule):
|
||||||
})
|
})
|
||||||
|
|
||||||
for name, end in [
|
for name, end in [
|
||||||
['pgadmin.browser.menu', 'js/menu'],
|
['pgadmin.browser.menu', 'js/menu'],
|
||||||
['pgadmin.browser.panel', 'js/panel'],
|
['pgadmin.browser.panel', 'js/panel'],
|
||||||
['pgadmin.browser.frame', 'js/frame']]:
|
['pgadmin.browser.frame', 'js/frame']]:
|
||||||
scripts.append({
|
scripts.append({
|
||||||
'name': name, 'path': url_for('browser.static', filename=end),
|
'name': name, 'path': url_for('browser.static', filename=end),
|
||||||
'preloaded': True})
|
'preloaded': True})
|
||||||
|
@ -437,6 +440,7 @@ class BrowserModule(PgAdminModule):
|
||||||
"""
|
"""
|
||||||
return ['browser.index', 'browser.nodes']
|
return ['browser.index', 'browser.nodes']
|
||||||
|
|
||||||
|
|
||||||
blueprint = BrowserModule(MODULE_NAME, __name__)
|
blueprint = BrowserModule(MODULE_NAME, __name__)
|
||||||
|
|
||||||
|
|
||||||
|
@ -471,7 +475,8 @@ class BrowserPluginModule(PgAdminModule):
|
||||||
Every module extended from this will be identified as 'NODE-<type>'.
|
Every module extended from this will be identified as 'NODE-<type>'.
|
||||||
|
|
||||||
Also, create a preference 'show_node_<type>' to fetch whether it
|
Also, create a preference 'show_node_<type>' to fetch whether it
|
||||||
can be shown in the browser or not. Also, refer to the browser-preference.
|
can be shown in the browser or not. Also, refer to the
|
||||||
|
browser-preference.
|
||||||
"""
|
"""
|
||||||
kwargs.setdefault("url_prefix", self.node_path)
|
kwargs.setdefault("url_prefix", self.node_path)
|
||||||
kwargs.setdefault("static_url_path", '/static')
|
kwargs.setdefault("static_url_path", '/static')
|
||||||
|
@ -525,7 +530,8 @@ class BrowserPluginModule(PgAdminModule):
|
||||||
if self.module_use_template_javascript:
|
if self.module_use_template_javascript:
|
||||||
scripts.extend([{
|
scripts.extend([{
|
||||||
'name': 'pgadmin.node.%s' % self.node_type,
|
'name': 'pgadmin.node.%s' % self.node_type,
|
||||||
'path': url_for('browser.index') + '%s/module' % self.node_type,
|
'path': url_for('browser.index') +
|
||||||
|
'%s/module' % self.node_type,
|
||||||
'when': self.script_load,
|
'when': self.script_load,
|
||||||
'is_template': True
|
'is_template': True
|
||||||
}])
|
}])
|
||||||
|
@ -533,7 +539,8 @@ class BrowserPluginModule(PgAdminModule):
|
||||||
scripts.extend([{
|
scripts.extend([{
|
||||||
'name': 'pgadmin.node.%s' % self.node_type,
|
'name': 'pgadmin.node.%s' % self.node_type,
|
||||||
'path': url_for(
|
'path': url_for(
|
||||||
'%s.static'% self.name, filename=('js/%s' % self.node_type)
|
'%s.static' % self.name,
|
||||||
|
filename=('js/%s' % self.node_type)
|
||||||
),
|
),
|
||||||
'when': self.script_load,
|
'when': self.script_load,
|
||||||
'is_template': False
|
'is_template': False
|
||||||
|
@ -648,7 +655,8 @@ class BrowserPluginModule(PgAdminModule):
|
||||||
@property
|
@property
|
||||||
def show_node(self):
|
def show_node(self):
|
||||||
"""
|
"""
|
||||||
A proper to check to show node for this module on the browser tree or not.
|
A proper to check to show node for this module on the browser tree or
|
||||||
|
not.
|
||||||
|
|
||||||
Relies on show_node preference object, otherwise on the SHOW_ON_BROWSER
|
Relies on show_node preference object, otherwise on the SHOW_ON_BROWSER
|
||||||
default value.
|
default value.
|
||||||
|
@ -675,14 +683,16 @@ class BrowserPluginModule(PgAdminModule):
|
||||||
Sets the browser_preference, show_system_objects, show_node preference
|
Sets the browser_preference, show_system_objects, show_node preference
|
||||||
objects for this submodule.
|
objects for this submodule.
|
||||||
"""
|
"""
|
||||||
# Add the node informaton for browser, not in respective node preferences
|
# Add the node informaton for browser, not in respective node
|
||||||
|
# preferences
|
||||||
self.browser_preference = blueprint.preference
|
self.browser_preference = blueprint.preference
|
||||||
self.pref_show_system_objects = blueprint.preference.preference(
|
self.pref_show_system_objects = blueprint.preference.preference(
|
||||||
'display', 'show_system_objects'
|
'display', 'show_system_objects'
|
||||||
)
|
)
|
||||||
self.pref_show_node = self.browser_preference.preference(
|
self.pref_show_node = self.browser_preference.preference(
|
||||||
'node', 'show_node_' + self.node_type,
|
'node', 'show_node_' + self.node_type,
|
||||||
self.label, 'boolean', self.SHOW_ON_BROWSER, category_label=gettext('Nodes')
|
self.label, 'boolean', self.SHOW_ON_BROWSER,
|
||||||
|
category_label=gettext('Nodes')
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -721,7 +731,7 @@ def index():
|
||||||
if response.getcode() == 200:
|
if response.getcode() == 200:
|
||||||
data = json.loads(response.read().decode('utf-8'))
|
data = json.loads(response.read().decode('utf-8'))
|
||||||
current_app.logger.debug('Response data: %s' % data)
|
current_app.logger.debug('Response data: %s' % data)
|
||||||
except:
|
except Exception as e:
|
||||||
current_app.logger.exception('Exception when checking for update')
|
current_app.logger.exception('Exception when checking for update')
|
||||||
|
|
||||||
if data is not None:
|
if data is not None:
|
||||||
|
@ -799,7 +809,7 @@ def utils():
|
||||||
from pgadmin.utils.driver import get_driver
|
from pgadmin.utils.driver import get_driver
|
||||||
driver = get_driver(PG_DEFAULT_DRIVER)
|
driver = get_driver(PG_DEFAULT_DRIVER)
|
||||||
pg_libpq_version = driver.libpq_version()
|
pg_libpq_version = driver.libpq_version()
|
||||||
except:
|
except Exception as e:
|
||||||
pg_libpq_version = 0
|
pg_libpq_version = 0
|
||||||
|
|
||||||
for submodule in current_blueprint.submodules:
|
for submodule in current_blueprint.submodules:
|
||||||
|
@ -887,7 +897,9 @@ def browser_css():
|
||||||
sql_font_size = round(float(sql_font_size_pref.get()), 2)
|
sql_font_size = round(float(sql_font_size_pref.get()), 2)
|
||||||
|
|
||||||
if sql_font_size != 0:
|
if sql_font_size != 0:
|
||||||
snippets.append('.CodeMirror { font-size: %sem; }' % str(sql_font_size))
|
snippets.append(
|
||||||
|
'.CodeMirror { font-size: %sem; }' % str(sql_font_size)
|
||||||
|
)
|
||||||
|
|
||||||
for submodule in blueprint.submodules:
|
for submodule in blueprint.submodules:
|
||||||
snippets.extend(submodule.csssnippets)
|
snippets.extend(submodule.csssnippets)
|
||||||
|
@ -911,6 +923,8 @@ def get_nodes():
|
||||||
# Only register route if SECURITY_CHANGEABLE is set to True
|
# Only register route if SECURITY_CHANGEABLE is set to True
|
||||||
# We can't access app context here so cannot
|
# We can't access app context here so cannot
|
||||||
# use app.config['SECURITY_CHANGEABLE']
|
# use app.config['SECURITY_CHANGEABLE']
|
||||||
|
|
||||||
|
|
||||||
if hasattr(config, 'SECURITY_CHANGEABLE') and config.SECURITY_CHANGEABLE:
|
if hasattr(config, 'SECURITY_CHANGEABLE') and config.SECURITY_CHANGEABLE:
|
||||||
@blueprint.route("/change_password", endpoint="change_password",
|
@blueprint.route("/change_password", endpoint="change_password",
|
||||||
methods=['GET', 'POST'])
|
methods=['GET', 'POST'])
|
||||||
|
@ -932,7 +946,10 @@ if hasattr(config, 'SECURITY_CHANGEABLE') and config.SECURITY_CHANGEABLE:
|
||||||
except SOCKETErrorException as e:
|
except SOCKETErrorException as e:
|
||||||
# Handle socket errors which are not covered by SMTPExceptions.
|
# Handle socket errors which are not covered by SMTPExceptions.
|
||||||
logging.exception(str(e), exc_info=True)
|
logging.exception(str(e), exc_info=True)
|
||||||
flash(gettext(u'SMTP Socket error: {}\nYour password has not been changed.').format(e), 'danger')
|
flash(gettext(u'SMTP Socket error: {}\n'
|
||||||
|
u'Your password has not been changed.'
|
||||||
|
).format(e),
|
||||||
|
'danger')
|
||||||
has_error = True
|
has_error = True
|
||||||
except (SMTPConnectError, SMTPResponseException,
|
except (SMTPConnectError, SMTPResponseException,
|
||||||
SMTPServerDisconnected, SMTPDataError, SMTPHeloError,
|
SMTPServerDisconnected, SMTPDataError, SMTPHeloError,
|
||||||
|
@ -940,12 +957,18 @@ if hasattr(config, 'SECURITY_CHANGEABLE') and config.SECURITY_CHANGEABLE:
|
||||||
SMTPRecipientsRefused) as e:
|
SMTPRecipientsRefused) as e:
|
||||||
# Handle smtp specific exceptions.
|
# Handle smtp specific exceptions.
|
||||||
logging.exception(str(e), exc_info=True)
|
logging.exception(str(e), exc_info=True)
|
||||||
flash(gettext(u'SMTP error: {}\nYour password has not been changed.').format(e), 'danger')
|
flash(gettext(u'SMTP error: {}\n'
|
||||||
|
u'Your password has not been changed.'
|
||||||
|
).format(e),
|
||||||
|
'danger')
|
||||||
has_error = True
|
has_error = True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# Handle other exceptions.
|
# Handle other exceptions.
|
||||||
logging.exception(str(e), exc_info=True)
|
logging.exception(str(e), exc_info=True)
|
||||||
flash(gettext(u'Error: {}\nYour password has not been changed.').format(e), 'danger')
|
flash(gettext(u'Error: {}\n'
|
||||||
|
u'Your password has not been changed.'
|
||||||
|
).format(e),
|
||||||
|
'danger')
|
||||||
has_error = True
|
has_error = True
|
||||||
|
|
||||||
if request.json is None and not has_error:
|
if request.json is None and not has_error:
|
||||||
|
@ -984,7 +1007,6 @@ if hasattr(config, 'SECURITY_RECOVERABLE') and config.SECURITY_RECOVERABLE:
|
||||||
current_app._get_current_object(),
|
current_app._get_current_object(),
|
||||||
user=user, token=token)
|
user=user, token=token)
|
||||||
|
|
||||||
|
|
||||||
@blueprint.route("/reset_password", endpoint="forgot_password",
|
@blueprint.route("/reset_password", endpoint="forgot_password",
|
||||||
methods=['GET', 'POST'])
|
methods=['GET', 'POST'])
|
||||||
@anonymous_user_required
|
@anonymous_user_required
|
||||||
|
@ -1004,7 +1026,10 @@ if hasattr(config, 'SECURITY_RECOVERABLE') and config.SECURITY_RECOVERABLE:
|
||||||
except SOCKETErrorException as e:
|
except SOCKETErrorException as e:
|
||||||
# Handle socket errors which are not covered by SMTPExceptions.
|
# Handle socket errors which are not covered by SMTPExceptions.
|
||||||
logging.exception(str(e), exc_info=True)
|
logging.exception(str(e), exc_info=True)
|
||||||
flash(gettext(u'SMTP Socket error: {}\nYour password has not been changed.').format(e), 'danger')
|
flash(gettext(u'SMTP Socket error: {}\n'
|
||||||
|
u'Your password has not been changed.'
|
||||||
|
).format(e),
|
||||||
|
'danger')
|
||||||
has_error = True
|
has_error = True
|
||||||
except (SMTPConnectError, SMTPResponseException,
|
except (SMTPConnectError, SMTPResponseException,
|
||||||
SMTPServerDisconnected, SMTPDataError, SMTPHeloError,
|
SMTPServerDisconnected, SMTPDataError, SMTPHeloError,
|
||||||
|
@ -1013,12 +1038,18 @@ if hasattr(config, 'SECURITY_RECOVERABLE') and config.SECURITY_RECOVERABLE:
|
||||||
|
|
||||||
# Handle smtp specific exceptions.
|
# Handle smtp specific exceptions.
|
||||||
logging.exception(str(e), exc_info=True)
|
logging.exception(str(e), exc_info=True)
|
||||||
flash(gettext(u'SMTP error: {}\nYour password has not been changed.').format(e), 'danger')
|
flash(gettext(u'SMTP error: {}\n'
|
||||||
|
u'Your password has not been changed.'
|
||||||
|
).format(e),
|
||||||
|
'danger')
|
||||||
has_error = True
|
has_error = True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# Handle other exceptions.
|
# Handle other exceptions.
|
||||||
logging.exception(str(e), exc_info=True)
|
logging.exception(str(e), exc_info=True)
|
||||||
flash(gettext(u'Error: {}\nYour password has not been changed.').format(e), 'danger')
|
flash(gettext(u'Error: {}\n'
|
||||||
|
u'Your password has not been changed.'
|
||||||
|
).format(e),
|
||||||
|
'danger')
|
||||||
has_error = True
|
has_error = True
|
||||||
|
|
||||||
if request.json is None and not has_error:
|
if request.json is None and not has_error:
|
||||||
|
@ -1033,8 +1064,8 @@ if hasattr(config, 'SECURITY_RECOVERABLE') and config.SECURITY_RECOVERABLE:
|
||||||
forgot_password_form=form,
|
forgot_password_form=form,
|
||||||
**_ctx('forgot_password'))
|
**_ctx('forgot_password'))
|
||||||
|
|
||||||
|
# We are not in app context so cannot use
|
||||||
# We are not in app context so cannot use url_for('browser.forgot_password')
|
# url_for('browser.forgot_password')
|
||||||
# So hard code the url '/browser/reset_password' while passing as
|
# So hard code the url '/browser/reset_password' while passing as
|
||||||
# parameter to slash_url_suffix function.
|
# parameter to slash_url_suffix function.
|
||||||
@blueprint.route('/reset_password' + slash_url_suffix(
|
@blueprint.route('/reset_password' + slash_url_suffix(
|
||||||
|
@ -1063,7 +1094,10 @@ if hasattr(config, 'SECURITY_RECOVERABLE') and config.SECURITY_RECOVERABLE:
|
||||||
except SOCKETErrorException as e:
|
except SOCKETErrorException as e:
|
||||||
# Handle socket errors which are not covered by SMTPExceptions.
|
# Handle socket errors which are not covered by SMTPExceptions.
|
||||||
logging.exception(str(e), exc_info=True)
|
logging.exception(str(e), exc_info=True)
|
||||||
flash(gettext(u'SMTP Socket error: {}\nYour password has not been changed.').format(e), 'danger')
|
flash(gettext(u'SMTP Socket error: {}\n'
|
||||||
|
u'Your password has not been changed.'
|
||||||
|
).format(e),
|
||||||
|
'danger')
|
||||||
has_error = True
|
has_error = True
|
||||||
except (SMTPConnectError, SMTPResponseException,
|
except (SMTPConnectError, SMTPResponseException,
|
||||||
SMTPServerDisconnected, SMTPDataError, SMTPHeloError,
|
SMTPServerDisconnected, SMTPDataError, SMTPHeloError,
|
||||||
|
@ -1072,12 +1106,18 @@ if hasattr(config, 'SECURITY_RECOVERABLE') and config.SECURITY_RECOVERABLE:
|
||||||
|
|
||||||
# Handle smtp specific exceptions.
|
# Handle smtp specific exceptions.
|
||||||
logging.exception(str(e), exc_info=True)
|
logging.exception(str(e), exc_info=True)
|
||||||
flash(gettext(u'SMTP error: {}\nYour password has not been changed.').format(e), 'danger')
|
flash(gettext(u'SMTP error: {}\n'
|
||||||
|
u'Your password has not been changed.'
|
||||||
|
).format(e),
|
||||||
|
'danger')
|
||||||
has_error = True
|
has_error = True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# Handle other exceptions.
|
# Handle other exceptions.
|
||||||
logging.exception(str(e), exc_info=True)
|
logging.exception(str(e), exc_info=True)
|
||||||
flash(gettext(u'Error: {}\nYour password has not been changed.').format(e), 'danger')
|
flash(gettext(u'Error: {}\n'
|
||||||
|
u'Your password has not been changed.'
|
||||||
|
).format(e),
|
||||||
|
'danger')
|
||||||
has_error = True
|
has_error = True
|
||||||
|
|
||||||
if not has_error:
|
if not has_error:
|
||||||
|
|
|
@ -53,14 +53,14 @@ class CollectionNodeModule(PgAdminModule, PGChildModule):
|
||||||
"""
|
"""
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def get_own_javascripts(self):
|
def get_own_javascripts(self):
|
||||||
scripts = []
|
scripts = []
|
||||||
|
|
||||||
if self.module_use_template_javascript:
|
if self.module_use_template_javascript:
|
||||||
scripts.extend([{
|
scripts.extend([{
|
||||||
'name': 'pgadmin.node.%s' % self.node_type,
|
'name': 'pgadmin.node.%s' % self.node_type,
|
||||||
'path': url_for('browser.index') + '%s/module' % self.node_type,
|
'path': url_for('browser.index') +
|
||||||
|
'%s/module' % self.node_type,
|
||||||
'when': self.script_load,
|
'when': self.script_load,
|
||||||
'is_template': True
|
'is_template': True
|
||||||
}])
|
}])
|
||||||
|
@ -68,7 +68,8 @@ class CollectionNodeModule(PgAdminModule, PGChildModule):
|
||||||
scripts.extend([{
|
scripts.extend([{
|
||||||
'name': 'pgadmin.node.%s' % self.node_type,
|
'name': 'pgadmin.node.%s' % self.node_type,
|
||||||
'path': url_for(
|
'path': url_for(
|
||||||
'%s.static'% self.name, filename=('js/%s' % self.node_type)
|
'%s.static' % self.name,
|
||||||
|
filename=('js/%s' % self.node_type)
|
||||||
),
|
),
|
||||||
'when': self.script_load,
|
'when': self.script_load,
|
||||||
'is_template': False
|
'is_template': False
|
||||||
|
@ -86,7 +87,9 @@ class CollectionNodeModule(PgAdminModule, PGChildModule):
|
||||||
"id": "%s/%s" % (self.node_type, node_id),
|
"id": "%s/%s" % (self.node_type, node_id),
|
||||||
"label": label,
|
"label": label,
|
||||||
"icon": self.node_icon if not icon else icon,
|
"icon": self.node_icon if not icon else icon,
|
||||||
"inode": self.node_inode if 'inode' not in kwargs else kwargs['inode'],
|
"inode": self.node_inode
|
||||||
|
if 'inode' not in kwargs
|
||||||
|
else kwargs['inode'],
|
||||||
"_type": self.node_type,
|
"_type": self.node_type,
|
||||||
"_id": node_id,
|
"_id": node_id,
|
||||||
"_pid": parent_id,
|
"_pid": parent_id,
|
||||||
|
@ -236,7 +239,8 @@ class CollectionNodeModule(PgAdminModule, PGChildModule):
|
||||||
along with that get two browser level preferences show_system_objects,
|
along with that get two browser level preferences show_system_objects,
|
||||||
and show_node will be registered to used by the submodules.
|
and show_node will be registered to used by the submodules.
|
||||||
"""
|
"""
|
||||||
# Add the node informaton for browser, not in respective node preferences
|
# Add the node informaton for browser, not in respective node
|
||||||
|
# preferences
|
||||||
self.browser_preference = Preferences.module('browser')
|
self.browser_preference = Preferences.module('browser')
|
||||||
self.pref_show_system_objects = self.browser_preference.preference(
|
self.pref_show_system_objects = self.browser_preference.preference(
|
||||||
'show_system_objects'
|
'show_system_objects'
|
||||||
|
|
|
@ -19,6 +19,7 @@ from pgadmin.utils.ajax import make_json_response, precondition_required
|
||||||
|
|
||||||
from config import PG_DEFAULT_DRIVER
|
from config import PG_DEFAULT_DRIVER
|
||||||
|
|
||||||
|
|
||||||
def is_version_in_range(sversion, min_ver, max_ver):
|
def is_version_in_range(sversion, min_ver, max_ver):
|
||||||
assert (max_ver is None or isinstance(max_ver, int))
|
assert (max_ver is None or isinstance(max_ver, int))
|
||||||
assert (min_ver is None or isinstance(min_ver, int))
|
assert (min_ver is None or isinstance(min_ver, int))
|
||||||
|
@ -31,13 +32,14 @@ def is_version_in_range(sversion, min_ver, max_ver):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
class PGChildModule(object):
|
class PGChildModule(object):
|
||||||
"""
|
"""
|
||||||
class PGChildModule
|
class PGChildModule
|
||||||
|
|
||||||
This is a base class for children/grand-children of PostgreSQL, and
|
This is a base class for children/grand-children of PostgreSQL, and
|
||||||
all EDB Postgres Advanced Server version (i.e. EDB Postgres Advanced Server, Green Plum,
|
all EDB Postgres Advanced Server version
|
||||||
etc).
|
(i.e. EDB Postgres Advanced Server, Green Plum, etc).
|
||||||
|
|
||||||
Method:
|
Method:
|
||||||
------
|
------
|
||||||
|
@ -68,8 +70,12 @@ class PGChildModule(object):
|
||||||
assert (self.server_type is None or isinstance(self.server_type, list))
|
assert (self.server_type is None or isinstance(self.server_type, list))
|
||||||
|
|
||||||
if self.server_type is None or manager.server_type in self.server_type:
|
if self.server_type is None or manager.server_type in self.server_type:
|
||||||
return is_version_in_range(sversion, self.min_gpdbver if manager.server_type == 'gpdb' else self.min_ver,
|
return is_version_in_range(sversion, self.min_gpdbver
|
||||||
self.max_gpdbver if manager.server_type == 'gpdb' else self.max_ver)
|
if manager.server_type == 'gpdb'
|
||||||
|
else self.min_ver,
|
||||||
|
self.max_gpdbver
|
||||||
|
if manager.server_type == 'gpdb'
|
||||||
|
else self.max_ver)
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -173,8 +179,9 @@ class NodeView(with_metaclass(MethodViewType, View)):
|
||||||
|
|
||||||
id_url = None
|
id_url = None
|
||||||
for p in cls.ids:
|
for p in cls.ids:
|
||||||
id_url = '{0}<{1}:{2}>'.format(common_url if not id_url else id_url,
|
id_url = '{0}<{1}:{2}>'.format(
|
||||||
p['type'], p['id'])
|
common_url if not id_url else id_url,
|
||||||
|
p['type'], p['id'])
|
||||||
|
|
||||||
return id_url, common_url
|
return id_url, common_url
|
||||||
|
|
||||||
|
@ -217,15 +224,16 @@ class NodeView(with_metaclass(MethodViewType, View)):
|
||||||
meth in self.operations[self.cmd][1]) or
|
meth in self.operations[self.cmd][1]) or
|
||||||
(len(self.operations[self.cmd]) > 2 and
|
(len(self.operations[self.cmd]) > 2 and
|
||||||
meth in self.operations[self.cmd][2])), \
|
meth in self.operations[self.cmd][2])), \
|
||||||
"Unimplemented method ({0}) for command ({1}), which {2} an id".format(
|
"Unimplemented method ({0}) for command ({1}), which {2} an id"\
|
||||||
|
.format(
|
||||||
meth, self.cmd,
|
meth, self.cmd,
|
||||||
'requires' if has_id else 'does not require'
|
'requires' if has_id else 'does not require'
|
||||||
)
|
)
|
||||||
|
|
||||||
meth = self.operations[self.cmd][0][meth] if has_id else \
|
meth = self.operations[self.cmd][0][meth] if has_id else \
|
||||||
self.operations[self.cmd][1][meth] if has_args and \
|
self.operations[self.cmd][1][meth] \
|
||||||
meth in self.operations[self.cmd][1] else \
|
if has_args and meth in self.operations[self.cmd][1] \
|
||||||
self.operations[self.cmd][2][meth]
|
else self.operations[self.cmd][2][meth]
|
||||||
|
|
||||||
method = getattr(self, meth, None)
|
method = getattr(self, meth, None)
|
||||||
|
|
||||||
|
@ -367,8 +375,9 @@ class PGChildNodeView(NodeView):
|
||||||
|
|
||||||
# fetch role dependencies
|
# fetch role dependencies
|
||||||
if where_clause.find('subid') < 0:
|
if where_clause.find('subid') < 0:
|
||||||
sql = render_template("/".join([sql_path, 'role_dependencies.sql']),
|
sql = render_template(
|
||||||
where_clause=where_clause)
|
"/".join([sql_path, 'role_dependencies.sql']),
|
||||||
|
where_clause=where_clause)
|
||||||
|
|
||||||
status, result = conn.execute_dict(sql)
|
status, result = conn.execute_dict(sql)
|
||||||
if not status:
|
if not status:
|
||||||
|
@ -385,7 +394,11 @@ class PGChildNodeView(NodeView):
|
||||||
dep_type = 'Owner'
|
dep_type = 'Owner'
|
||||||
|
|
||||||
if row['refclassid'] == 1260:
|
if row['refclassid'] == 1260:
|
||||||
dependencies.append({'type': 'role', 'name': ref_name, 'field': dep_type})
|
dependencies.append(
|
||||||
|
{'type': 'role',
|
||||||
|
'name': ref_name,
|
||||||
|
'field': dep_type}
|
||||||
|
)
|
||||||
|
|
||||||
return dependencies
|
return dependencies
|
||||||
|
|
||||||
|
@ -489,7 +502,8 @@ class PGChildNodeView(NodeView):
|
||||||
type_name = 'table'
|
type_name = 'table'
|
||||||
elif type_str[0] == 'R':
|
elif type_str[0] == 'R':
|
||||||
type_name = 'rule'
|
type_name = 'rule'
|
||||||
ref_name = _ref_name + ' ON ' + ref_name + row['ownertable']
|
ref_name = \
|
||||||
|
_ref_name + ' ON ' + ref_name + row['ownertable']
|
||||||
_ref_name = None
|
_ref_name = None
|
||||||
elif type_str[0] == 'C':
|
elif type_str[0] == 'C':
|
||||||
if type_str[1] == 'c':
|
if type_str[1] == 'c':
|
||||||
|
@ -535,6 +549,12 @@ class PGChildNodeView(NodeView):
|
||||||
else:
|
else:
|
||||||
dep_type = dep_types[dep_str[0]]
|
dep_type = dep_types[dep_str[0]]
|
||||||
|
|
||||||
dependency.append({'type': type_name, 'name': ref_name, 'field': dep_type})
|
dependency.append(
|
||||||
|
{
|
||||||
|
'type': type_name,
|
||||||
|
'name': ref_name,
|
||||||
|
'field': dep_type
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
return dependency
|
return dependency
|
||||||
|
|
|
@ -8,8 +8,6 @@
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
"""A blueprint module implementing the pgAdmin help system."""
|
"""A blueprint module implementing the pgAdmin help system."""
|
||||||
MODULE_NAME = 'help'
|
|
||||||
|
|
||||||
from flask import url_for
|
from flask import url_for
|
||||||
from flask_babel import gettext
|
from flask_babel import gettext
|
||||||
from pgadmin.utils import PgAdminModule
|
from pgadmin.utils import PgAdminModule
|
||||||
|
@ -17,6 +15,8 @@ from pgadmin.utils.menu import MenuItem, Panel
|
||||||
from pgadmin.utils.preferences import Preferences
|
from pgadmin.utils.preferences import Preferences
|
||||||
import config
|
import config
|
||||||
|
|
||||||
|
MODULE_NAME = 'help'
|
||||||
|
|
||||||
|
|
||||||
class HelpModule(PgAdminModule):
|
class HelpModule(PgAdminModule):
|
||||||
def get_own_menuitems(self):
|
def get_own_menuitems(self):
|
||||||
|
|
Loading…
Reference in New Issue