Re: [pgAdmin4][RM#3082] Fix PEP-8 issues

2018-02-09 Thread Dave Page
Thanks, applied.

On Thu, Feb 8, 2018 at 6:10 PM, Murtuza Zabuawala <
murtuza.zabuaw...@enterprisedb.com> wrote:

> Hi Dave,
>
> PFA updated patch.
>
> On Mon, Feb 5, 2018 at 7:55 PM, Dave Page  wrote:
>
>> Hi
>>
>> On Fri, Feb 2, 2018 at 5:46 PM, Murtuza Zabuawala <
>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>
>>> Hi,
>>>
>>> PFA patch to fix PEP-8 issues in feature_tests, dashboard, about and
>>> misc module's python code.
>>>
>>> To verify the changes,
>>> 1) activate virtual environemt
>>> 2) Navigate to ../web directory and run following
>>> pycodestyle --config=.pycodestyle ./pgadmin/misc/
>>> pycodestyle --config=.pycodestyle ./pgadmin/about/
>>> pycodestyle --config=.pycodestyle ./pgadmin/dashboard/
>>> pycodestyle --config=.pycodestyle ./pgadmin/feature_tests/
>>>
>>
>> I seem to be getting the following failure pretty consistently with this
>> patch applied:
>>
>> ==
>> ERROR: runTest (pgadmin.feature_tests.pg_data
>> type_validation_test.PGDataypeFeatureTest)
>> Test checks for PG data-types output
>> --
>> Traceback (most recent call last):
>>   File 
>> "/Users/dpage/git/pgadmin4/web/pgadmin/feature_tests/pg_datatype_validation_test.py",
>> line 135, in runTest
>> self._check_datatype()
>>   File 
>> "/Users/dpage/git/pgadmin4/web/pgadmin/feature_tests/pg_datatype_validation_test.py",
>> line 161, in _check_datatype
>> query = self.construct_select_query(batch)
>>   File 
>> "/Users/dpage/git/pgadmin4/web/pgadmin/feature_tests/pg_datatype_validation_test.py",
>> line 214, in construct_select_query
>> if not self._is_datatype_available_in_current_database(datatype):
>>   File 
>> "/Users/dpage/git/pgadmin4/web/pgadmin/feature_tests/pg_datatype_validation_test.py",
>> line 252, in _is_datatype_available_in_current_database
>> valid_version = self.database_version >=
>> type_minimum_version[datatype]
>> KeyError: u''
>>
> ​
> Fixed
> ​
>
>
>>
>> --
>> Ran 10 tests in 209.730s
>>
>> FAILED (errors=1, skipped=1)
>>
>> ==
>> Test Result Summary
>> ==
>>
>> Regression - PG 10:
>>
>> 8 tests passed
>> 1 test failed:
>> PGDataypeFeatureTest (Test checks for PG data-types output)
>> 1 test skipped:
>> CheckDebuggerForXssFeatureTest (Tests to check if Debugger is vulnerable
>> to XSS)
>>
>> ==
>>
>> I also got the following whilst testing:
>>
>> (pgadmin4)piranha:web dpage$ pycodestyle --config=.pycodestyle
>> ./pgadmin/feature_tests/
>> ./pgadmin/feature_tests/keyboard_shortcut_test.py:33: [E501] line too
>> long (95 > 79 characters)
>> ./pgadmin/feature_tests/keyboard_shortcut_test.py:34: [E501] line too
>> long (95 > 79 characters)
>> ./pgadmin/feature_tests/keyboard_shortcut_test.py:42: [E501] line too
>> long (87 > 79 characters)
>> ./pgadmin/feature_tests/keyboard_shortcut_test.py:51: [E501] line too
>> long (114 > 79 characters)
>> ./pgadmin/feature_tests/keyboard_shortcut_test.py:54: [E501] line too
>> long (90 > 79 characters)
>> ./pgadmin/feature_tests/keyboard_shortcut_test.py:69: [E501] line too
>> long (91 > 79 characters)
>> ./pgadmin/feature_tests/keyboard_shortcut_test.py:75: [E501] line too
>> long (89 > 79 characters)
>> ./pgadmin/feature_tests/keyboard_shortcut_test.py:82: [E501] line too
>> long (100 > 79 characters)
>> ./pgadmin/feature_tests/keyboard_shortcut_test.py:90: [E501] line too
>> long (86 > 79 characters)
>> ./pgadmin/feature_tests/keyboard_shortcut_test.py:95: [W391] blank line
>> at end of file
>> 9   E501 line too long (95 > 79 characters)
>> 1   W391 blank line at end of file
>> 10
>>
>
> ​This file was added after I sent the patch :)​
>
> ​BTW I have the issues now.​
>
>
>>
>> --
>> Dave Page
>> Blog: http://pgsnake.blogspot.com
>> Twitter: @pgsnake
>>
>> EnterpriseDB UK: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>
>


-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


Re: [pgAdmin4][RM#3082] Fix PEP-8 issues

2018-02-08 Thread Murtuza Zabuawala
Hi Dave,

PFA updated patch.

On Mon, Feb 5, 2018 at 7:55 PM, Dave Page  wrote:

> Hi
>
> On Fri, Feb 2, 2018 at 5:46 PM, Murtuza Zabuawala <
> murtuza.zabuaw...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> PFA patch to fix PEP-8 issues in feature_tests, dashboard, about and misc
>> module's python code.
>>
>> To verify the changes,
>> 1) activate virtual environemt
>> 2) Navigate to ../web directory and run following
>> pycodestyle --config=.pycodestyle ./pgadmin/misc/
>> pycodestyle --config=.pycodestyle ./pgadmin/about/
>> pycodestyle --config=.pycodestyle ./pgadmin/dashboard/
>> pycodestyle --config=.pycodestyle ./pgadmin/feature_tests/
>>
>
> I seem to be getting the following failure pretty consistently with this
> patch applied:
>
> ==
> ERROR: runTest (pgadmin.feature_tests.pg_data
> type_validation_test.PGDataypeFeatureTest)
> Test checks for PG data-types output
> --
> Traceback (most recent call last):
>   File 
> "/Users/dpage/git/pgadmin4/web/pgadmin/feature_tests/pg_datatype_validation_test.py",
> line 135, in runTest
> self._check_datatype()
>   File 
> "/Users/dpage/git/pgadmin4/web/pgadmin/feature_tests/pg_datatype_validation_test.py",
> line 161, in _check_datatype
> query = self.construct_select_query(batch)
>   File 
> "/Users/dpage/git/pgadmin4/web/pgadmin/feature_tests/pg_datatype_validation_test.py",
> line 214, in construct_select_query
> if not self._is_datatype_available_in_current_database(datatype):
>   File 
> "/Users/dpage/git/pgadmin4/web/pgadmin/feature_tests/pg_datatype_validation_test.py",
> line 252, in _is_datatype_available_in_current_database
> valid_version = self.database_version >= type_minimum_version[datatype]
> KeyError: u''
>
​
Fixed
​


>
> --
> Ran 10 tests in 209.730s
>
> FAILED (errors=1, skipped=1)
>
> ==
> Test Result Summary
> ==
>
> Regression - PG 10:
>
> 8 tests passed
> 1 test failed:
> PGDataypeFeatureTest (Test checks for PG data-types output)
> 1 test skipped:
> CheckDebuggerForXssFeatureTest (Tests to check if Debugger is vulnerable
> to XSS)
>
> ==
>
> I also got the following whilst testing:
>
> (pgadmin4)piranha:web dpage$ pycodestyle --config=.pycodestyle
> ./pgadmin/feature_tests/
> ./pgadmin/feature_tests/keyboard_shortcut_test.py:33: [E501] line too
> long (95 > 79 characters)
> ./pgadmin/feature_tests/keyboard_shortcut_test.py:34: [E501] line too
> long (95 > 79 characters)
> ./pgadmin/feature_tests/keyboard_shortcut_test.py:42: [E501] line too
> long (87 > 79 characters)
> ./pgadmin/feature_tests/keyboard_shortcut_test.py:51: [E501] line too
> long (114 > 79 characters)
> ./pgadmin/feature_tests/keyboard_shortcut_test.py:54: [E501] line too
> long (90 > 79 characters)
> ./pgadmin/feature_tests/keyboard_shortcut_test.py:69: [E501] line too
> long (91 > 79 characters)
> ./pgadmin/feature_tests/keyboard_shortcut_test.py:75: [E501] line too
> long (89 > 79 characters)
> ./pgadmin/feature_tests/keyboard_shortcut_test.py:82: [E501] line too
> long (100 > 79 characters)
> ./pgadmin/feature_tests/keyboard_shortcut_test.py:90: [E501] line too
> long (86 > 79 characters)
> ./pgadmin/feature_tests/keyboard_shortcut_test.py:95: [W391] blank line
> at end of file
> 9   E501 line too long (95 > 79 characters)
> 1   W391 blank line at end of file
> 10
>

​This file was added after I sent the patch :)​

​BTW I have the issues now.​


>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
diff --git a/web/pgadmin/about/__init__.py b/web/pgadmin/about/__init__.py
index 7a8ef95..98a4dd6 100644
--- a/web/pgadmin/about/__init__.py
+++ b/web/pgadmin/about/__init__.py
@@ -11,32 +11,31 @@
 MODULE_NAME = 'about'
 
 import sys
-
 from flask import Response, render_template, __version__, url_for
 from flask_babel import gettext
 from flask_security import current_user, login_required
 from pgadmin.utils import PgAdminModule
 from pgadmin.utils.menu import MenuItem
-
 import config
 
 
 class AboutModule(PgAdminModule):
 def get_own_menuitems(self):
 appname = config.APP_NAME
+
 if hasattr(str, 'decode'):
 appname = appname.decode('utf-8')
+
 return {
 'help_items': [
-MenuItem(name='mnu_about',
- priority=999,
- module="pgAdmin.About",
- callback='about_show',
- icon='fa fa-info-circle',
- label=gettext(u'About %(appname)s',
-   

Re: [pgAdmin4][RM#3082] Fix PEP-8 issues

2018-02-05 Thread Dave Page
Hi

On Fri, Feb 2, 2018 at 5:46 PM, Murtuza Zabuawala <
murtuza.zabuaw...@enterprisedb.com> wrote:

> Hi,
>
> PFA patch to fix PEP-8 issues in feature_tests, dashboard, about and misc
> module's python code.
>
> To verify the changes,
> 1) activate virtual environemt
> 2) Navigate to ../web directory and run following
> pycodestyle --config=.pycodestyle ./pgadmin/misc/
> pycodestyle --config=.pycodestyle ./pgadmin/about/
> pycodestyle --config=.pycodestyle ./pgadmin/dashboard/
> pycodestyle --config=.pycodestyle ./pgadmin/feature_tests/
>

I seem to be getting the following failure pretty consistently with this
patch applied:

==
ERROR: runTest
(pgadmin.feature_tests.pg_datatype_validation_test.PGDataypeFeatureTest)
Test checks for PG data-types output
--
Traceback (most recent call last):
  File
"/Users/dpage/git/pgadmin4/web/pgadmin/feature_tests/pg_datatype_validation_test.py",
line 135, in runTest
self._check_datatype()
  File
"/Users/dpage/git/pgadmin4/web/pgadmin/feature_tests/pg_datatype_validation_test.py",
line 161, in _check_datatype
query = self.construct_select_query(batch)
  File
"/Users/dpage/git/pgadmin4/web/pgadmin/feature_tests/pg_datatype_validation_test.py",
line 214, in construct_select_query
if not self._is_datatype_available_in_current_database(datatype):
  File
"/Users/dpage/git/pgadmin4/web/pgadmin/feature_tests/pg_datatype_validation_test.py",
line 252, in _is_datatype_available_in_current_database
valid_version = self.database_version >= type_minimum_version[datatype]
KeyError: u''

--
Ran 10 tests in 209.730s

FAILED (errors=1, skipped=1)

==
Test Result Summary
==

Regression - PG 10:

8 tests passed
1 test failed:
PGDataypeFeatureTest (Test checks for PG data-types output)
1 test skipped:
CheckDebuggerForXssFeatureTest (Tests to check if Debugger is vulnerable to
XSS)

==

I also got the following whilst testing:

(pgadmin4)piranha:web dpage$ pycodestyle --config=.pycodestyle
./pgadmin/feature_tests/
./pgadmin/feature_tests/keyboard_shortcut_test.py:33: [E501] line too long
(95 > 79 characters)
./pgadmin/feature_tests/keyboard_shortcut_test.py:34: [E501] line too long
(95 > 79 characters)
./pgadmin/feature_tests/keyboard_shortcut_test.py:42: [E501] line too long
(87 > 79 characters)
./pgadmin/feature_tests/keyboard_shortcut_test.py:51: [E501] line too long
(114 > 79 characters)
./pgadmin/feature_tests/keyboard_shortcut_test.py:54: [E501] line too long
(90 > 79 characters)
./pgadmin/feature_tests/keyboard_shortcut_test.py:69: [E501] line too long
(91 > 79 characters)
./pgadmin/feature_tests/keyboard_shortcut_test.py:75: [E501] line too long
(89 > 79 characters)
./pgadmin/feature_tests/keyboard_shortcut_test.py:82: [E501] line too long
(100 > 79 characters)
./pgadmin/feature_tests/keyboard_shortcut_test.py:90: [E501] line too long
(86 > 79 characters)
./pgadmin/feature_tests/keyboard_shortcut_test.py:95: [W391] blank line at
end of file
9   E501 line too long (95 > 79 characters)
1   W391 blank line at end of file
10

-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


[pgAdmin4][RM#3082] Fix PEP-8 issues

2018-02-02 Thread Murtuza Zabuawala
Hi,

PFA patch to fix PEP-8 issues in feature_tests, dashboard, about and misc
module's python code.

To verify the changes,
1) activate virtual environemt
2) Navigate to ../web directory and run following
pycodestyle --config=.pycodestyle ./pgadmin/misc/
pycodestyle --config=.pycodestyle ./pgadmin/about/
pycodestyle --config=.pycodestyle ./pgadmin/dashboard/
pycodestyle --config=.pycodestyle ./pgadmin/feature_tests/


--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/about/__init__.py b/web/pgadmin/about/__init__.py
index 7a8ef95..98a4dd6 100644
--- a/web/pgadmin/about/__init__.py
+++ b/web/pgadmin/about/__init__.py
@@ -11,32 +11,31 @@
 MODULE_NAME = 'about'
 
 import sys
-
 from flask import Response, render_template, __version__, url_for
 from flask_babel import gettext
 from flask_security import current_user, login_required
 from pgadmin.utils import PgAdminModule
 from pgadmin.utils.menu import MenuItem
-
 import config
 
 
 class AboutModule(PgAdminModule):
 def get_own_menuitems(self):
 appname = config.APP_NAME
+
 if hasattr(str, 'decode'):
 appname = appname.decode('utf-8')
+
 return {
 'help_items': [
-MenuItem(name='mnu_about',
- priority=999,
- module="pgAdmin.About",
- callback='about_show',
- icon='fa fa-info-circle',
- label=gettext(u'About %(appname)s',
-   appname=appname
-   )
- )
+MenuItem(
+name='mnu_about',
+priority=999,
+module="pgAdmin.About",
+callback='about_show',
+icon='fa fa-info-circle',
+label=gettext(u'About %(appname)s', appname=appname)
+)
 ]
 }
 
@@ -50,8 +49,8 @@ class AboutModule(PgAdminModule):
 def get_exposed_url_endpoints(self):
 return ['about.index']
 
-blueprint = AboutModule(MODULE_NAME, __name__,
-static_url_path='')
+
+blueprint = AboutModule(MODULE_NAME, __name__, static_url_path='')
 
 
 ##
@@ -61,20 +60,29 @@ blueprint = AboutModule(MODULE_NAME, __name__,
 @login_required
 def index():
 """Render the about box."""
-info = {'python_version': sys.version, 'flask_version': __version__}
-if config.SERVER_MODE is True:
+info = {
+'python_version': sys.version,
+'flask_version': __version__
+}
+
+if config.SERVER_MODE:
 info['app_mode'] = gettext('Server')
 else:
 info['app_mode'] = gettext('Desktop')
+
 info['current_user'] = current_user.email
 
-return render_template(MODULE_NAME + '/index.html', info=info, _=gettext)
+return render_template(
+MODULE_NAME + '/index.html', info=info, _=gettext
+)
 
 
 @blueprint.route("/about.js")
 @login_required
 def script():
 """render the required javascript"""
-return Response(response=render_template("about/about.js", _=gettext),
-status=200,
-mimetype="application/javascript")
+return Response(
+response=render_template("about/about.js", _=gettext),
+status=200,
+mimetype="application/javascript"
+)
diff --git a/web/pgadmin/dashboard/__init__.py 
b/web/pgadmin/dashboard/__init__.py
index 06c0b0a..0259a8f 100644
--- a/web/pgadmin/dashboard/__init__.py
+++ b/web/pgadmin/dashboard/__init__.py
@@ -61,7 +61,8 @@ class DashboardModule(PgAdminModule):
 isPrivate=False,
 limit=1,
 isIframe=False,
-canHide=True).__dict__
+canHide=True
+).__dict__
 ]
 
 def register_preferences(self):
@@ -70,8 +71,9 @@ class DashboardModule(PgAdminModule):
 Register preferences for this module.
 """
 # Register options for the PG and PPAS help paths
-self.dashboard_preference = Preferences('dashboards',
-gettext('Dashboards'))
+self.dashboard_preference = Preferences(
+'dashboards', gettext('Dashboards')
+)
 
 self.session_stats_refresh = self.dashboard_preference.register(
 'dashboards', 'session_stats_refresh',
@@ -149,6 +151,7 @@ class DashboardModule(PgAdminModule):
 'dashboard.get_config_by_server_id',
 ]
 
+
 blueprint = DashboardModule(MODULE_NAME, __name__)
 
 
@@ -168,11 +171,13 @@ def check_precondition(f):
 kwargs['sid']
 )
 
+stats_type = ('activity', 'prepared', 'locks', 'config')
+
 # Below check handle the case where existing server is deleted
 #