Fixed the errors, and warnings reported by pylama.

TODO::
- Don't use unicode in Python 3 for removing the support of Python 2 (
  psycopg2 driver - __init__.py, server_manager.py).
- Merge the lastest pgcli (version: 3.0.0) for SQL autocompletion.
This commit is contained in:
Ashesh Vashi
2020-05-08 14:13:32 +05:30
parent 9338bdcb3a
commit e73e2d2502
10 changed files with 43 additions and 49 deletions

View File

@@ -31,7 +31,7 @@ def run_backup_job(tester, job_id, expected_params, assert_in, assert_not_in,
if cnt >= 5:
break
# Check the process list
response1 = tester.get('/misc/bgprocess/?_='.format(
response1 = tester.get('/misc/bgprocess/?_={0}'.format(
random.randint(1, 9999999)))
assert_equal(response1.status_code, 200)
process_list = json.loads(response1.data.decode('utf-8'))
@@ -39,7 +39,7 @@ def run_backup_job(tester, job_id, expected_params, assert_in, assert_not_in,
try:
the_process = next(
p for p in process_list if p['id'] == job_id)
except Exception as _:
except Exception:
the_process = None
if the_process and 'execution_time' in the_process:
@@ -68,12 +68,12 @@ def run_backup_job(tester, job_id, expected_params, assert_in, assert_not_in,
assert_not_in(opt, the_process['details'])
# Check the process details
p_details = tester.get('/misc/bgprocess/{0}?_='.format(
p_details = tester.get('/misc/bgprocess/{0}?_={1}'.format(
job_id, random.randint(1, 9999999))
)
assert_equal(p_details.status_code, 200)
p_details = tester.get('/misc/bgprocess/{0}/{1}/{2}/?_='.format(
p_details = tester.get('/misc/bgprocess/{0}/{1}/{2}/?_={3}'.format(
job_id, 0, 0, random.randint(1, 9999999))
)
assert_equal(p_details.status_code, 200)

View File

@@ -8,7 +8,6 @@
##########################################################################
"""A blueprint module implementing the datagrid frame."""
MODULE_NAME = 'datagrid'
import simplejson as json
import pickle
@@ -17,9 +16,10 @@ import random
from threading import Lock
from flask import Response, url_for, session, request, make_response
from werkzeug.useragents import UserAgent
from flask import current_app as app
from flask import current_app as app, render_template
from flask_babelex import gettext
from flask_security import login_required
from pgadmin.tools.sqleditor.command import *
from pgadmin.tools.sqleditor.command import ObjectRegistry, SQLFilter
from pgadmin.utils import PgAdminModule
from pgadmin.utils.ajax import make_json_response, bad_request, \
internal_server_error
@@ -32,6 +32,7 @@ from pgadmin.utils.preferences import Preferences
from pgadmin.settings import get_setting
from pgadmin.browser.utils import underscore_unescape
MODULE_NAME = 'datagrid'
query_tool_close_session_lock = Lock()
@@ -153,7 +154,7 @@ def initialize_datagrid(trans_id, cmd_type, obj_type, sgid, sid, did, obj_id):
auto_reconnect=False,
use_binary_placeholder=True,
array_to_string=True)
except (ConnectionLost, SSHTunnelConnectionLost) as e:
except (ConnectionLost, SSHTunnelConnectionLost):
raise
except Exception as e:
app.logger.error(e)

View File

@@ -9,13 +9,11 @@
"""A blueprint module implementing the debugger"""
MODULE_NAME = 'debugger'
import simplejson as json
import random
import re
from flask import url_for, Response, render_template, request, session, \
from flask import url_for, Response, render_template, request, \
current_app
from flask_babelex import gettext
from flask_security import login_required
@@ -34,6 +32,8 @@ from config import PG_DEFAULT_DRIVER
from pgadmin.model import db, DebuggerFunctionArguments
from pgadmin.tools.debugger.utils.debugger_instance import DebuggerInstance
MODULE_NAME = 'debugger'
# Constants
ASYNC_OK = 1
@@ -344,7 +344,6 @@ def init_function(node_type, sid, did, scid, fid, trid=None):
# Get the server version, server type and user information
server_type = manager.server_type
user = manager.user_info
# Check server type is ppas or not
ppas_server = False
@@ -2122,7 +2121,7 @@ def close_debugger_session(_trans_id, close_all=False):
dbg_obj['exe_conn_id'],
dbg_obj['database_id'])
manager.release(conn_id=dbg_obj['exe_conn_id'])
except Exception as _:
except Exception:
raise
finally:
de_inst.clear()

View File

@@ -79,7 +79,7 @@ class MaintenanceJobTest(BaseTestGenerator):
if cnt >= 10:
break
# Check the process list
response1 = self.tester.get('/misc/bgprocess/?_='.format(
response1 = self.tester.get('/misc/bgprocess/?_={0}'.format(
random.randint(1, 9999999)))
self.assertEqual(response1.status_code, 200)
process_list = json.loads(response1.data.decode('utf-8'))
@@ -87,7 +87,7 @@ class MaintenanceJobTest(BaseTestGenerator):
try:
the_process = next(
p for p in process_list if p['id'] == job_id)
except Exception as _:
except Exception:
the_process = None
if the_process and 'execution_time' in the_process:
@@ -104,13 +104,15 @@ class MaintenanceJobTest(BaseTestGenerator):
self.assertIn(self.expected_cmd, the_process['details'])
# Check the process details
p_details = self.tester.get('/misc/bgprocess/{0}?_='.format(
p_details = self.tester.get('/misc/bgprocess/{0}?_={1}'.format(
job_id, random.randint(1, 9999999))
)
self.assertEqual(p_details.status_code, 200)
p_details = self.tester.get('/misc/bgprocess/{0}/{1}/{2}/?_='.format(
job_id, 0, 0, random.randint(1, 9999999))
p_details = self.tester.get(
'/misc/bgprocess/{0}/{1}/{2}/?_={3}'.format(
job_id, 0, 0, random.randint(1, 9999999)
)
)
self.assertEqual(p_details.status_code, 200)
p_details_data = json.loads(p_details.data.decode('utf-8'))

View File

@@ -7,7 +7,6 @@
#
##########################################################################
import sys
import time
import random
import os
@@ -120,7 +119,7 @@ class RestoreJobTest(BaseTestGenerator):
if cnt >= 5:
break
# Check the process list
response1 = self.tester.get('/misc/bgprocess/?_='.format(
response1 = self.tester.get('/misc/bgprocess/?_={0}'.format(
random.randint(1, 9999999)))
self.assertEqual(response1.status_code, 200)
process_list = json.loads(response1.data.decode('utf-8'))
@@ -128,7 +127,7 @@ class RestoreJobTest(BaseTestGenerator):
try:
the_process = next(
p for p in process_list if p['id'] == job_id)
except Exception as _:
except Exception:
the_process = None
if the_process and 'execution_time' in the_process:
@@ -150,14 +149,16 @@ class RestoreJobTest(BaseTestGenerator):
self.assertNotIn(opt, the_process['details'])
# Check the process details
p_details = self.tester.get('/misc/bgprocess/{0}?_='.format(
p_details = self.tester.get('/misc/bgprocess/{0}?_={1}'.format(
job_id, random.randint(1, 9999999))
)
self.assertEqual(p_details.status_code, 200)
json.loads(p_details.data.decode('utf-8'))
p_details = self.tester.get('/misc/bgprocess/{0}/{1}/{2}/?_='.format(
job_id, 0, 0, random.randint(1, 9999999))
p_details = self.tester.get(
'/misc/bgprocess/{0}/{1}/{2}/?_={3}'.format(
job_id, 0, 0, random.randint(1, 9999999)
)
)
self.assertEqual(p_details.status_code, 200)
p_details_data = json.loads(p_details.data.decode('utf-8'))