From 1ede09befc8f1b21a397a7c68f3030abefc2ca2f Mon Sep 17 00:00:00 2001 From: Denis Laxalde Date: Thu, 29 Oct 2020 11:58:54 +0100 Subject: [PATCH 01/10] Update installation instructions We now only document installation with pip and drop instructions using sudo, which are not recommended unless people know what they are doing. We also drop mention of the --with-man option, which only works for system-wide installation. The 'Dependencies' section is outdated and no longer needed when installing using pip. We also document Debian installation as an alternative. --- README.md | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 2752a4a7..c7af750c 100644 --- a/README.md +++ b/README.md @@ -5,27 +5,17 @@ Command line tool for PostgreSQL server activity monitoring. [![Latest PyPI version](https://img.shields.io/pypi/v/pg_activity.svg)](https://pypi.python.org/pypi/pg_activity) [![Build Status](https://travis-ci.com/dalibo/pg_activity.svg?branch=master)](https://travis-ci.com/dalibo/pg_activity) - -Dependencies ------------- - - - `python` ≥ **3.6** - - `psycopg2` ≥ **2.5** - - `psutil` ≥ **0.5.1** - -Installation from sources: -`setuptools` ≥ **0.6.14** - -You have to install the package `psycopg2` from `pgdg` [APT](https://wiki.postgresql.org/wiki/Apt) or [YUM](https://yum.postgresql.org/) repositories. `psycopg2` can also been installed from `pip` with `pip install psycopg2` or `pip install psycopg2-binary` for the binary version. - Installation ------------ - sudo python setup.py install +`pg_activity` requires Python 3.6 or later. It can be installed using pip +(available, e.g., as `apt install python3-pip` on Debian-based distributions): + + $ python3 -m pip install pg_activity psycopg2-binary -### Installation with man page +or directly from your Linux distribution, if available, e.g.: - sudo python setup.py install --with-man + $ sudo apt install pg-activity Usage From 6ad57a45d9342af0899728db6f415c6ed092cd4d Mon Sep 17 00:00:00 2001 From: Denis Laxalde Date: Thu, 29 Oct 2020 12:13:13 +0100 Subject: [PATCH 02/10] Wrap long lines in README and configure editor accordingly --- .editorconfig | 3 +++ README.md | 14 +++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.editorconfig b/.editorconfig index 2b78eb51..6068df5a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,4 +1,7 @@ root = true +[*.md] +max_line_length = 80 + [*.py] max_line_length = 89 diff --git a/README.md b/README.md index c7af750c..1a28def5 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,12 @@ or directly from your Linux distribution, if available, e.g.: Usage ----- -`pg_activity` works localy or remotely. In local execution context, to obtain sufficient rights to display system informations, the system user running `pg_activity` must be the same user running postgresql server (`postgres` by default), or have more rights like `root`. Otherwise, `pg_activity` can fallback to a degraded mode without displaying system informations. On the same way, PostgreSQL user used to connect to the database must be super-user. +`pg_activity` works localy or remotely. In local execution context, to obtain +sufficient rights to display system informations, the system user running +`pg_activity` must be the same user running postgresql server (`postgres` by +default), or have more rights like `root`. Otherwise, `pg_activity` can fallback +to a degraded mode without displaying system informations. On the same way, +PostgreSQL user used to connect to the database must be super-user. ex: sudo -u postgres pg_activity -U postgres @@ -73,7 +78,10 @@ Options Notes ----- -Length of SQL query text that pg_activity reports relies on PostgreSQL parameter `track_activity_query_size`. Default value is `1024` (expressed in bytes). If your SQL query text look truncated, you should increase `track_activity_query_size`. +Length of SQL query text that `pg_activity` reports relies on PostgreSQL +parameter `track_activity_query_size`. Default value is `1024` (expressed in +bytes). If your SQL query text look truncated, you should increase +`track_activity_query_size`. Interactives commands @@ -113,7 +121,7 @@ Navigation mode | `Space` | Tag or untag the process | | `q` | Quit | | `Other` | Back to activity | - + Screenshot ---------- From 948fbc57caf51857c97acff83bf2bad1c7be8863 Mon Sep 17 00:00:00 2001 From: Denis Laxalde Date: Fri, 30 Oct 2020 10:03:43 +0100 Subject: [PATCH 03/10] Black reformat setup.py --- pyproject.toml | 1 - setup.py | 32 ++++++++++++++++---------------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 19b8aa4f..5d3b2b0f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,7 +11,6 @@ exclude = ''' | \.venv | dist )/ - | setup.py | pg_activity ) ''' diff --git a/setup.py b/setup.py index 3bd9b447..f51ddc05 100644 --- a/setup.py +++ b/setup.py @@ -2,36 +2,36 @@ data_files = None for opt in sys.argv: - if opt == '--with-man': - data_files = [('/usr/share/man/man1', ['docs/man/pg_activity.1'])] + if opt == "--with-man": + data_files = [("/usr/share/man/man1", ["docs/man/pg_activity.1"])] sys.argv.remove(opt) from setuptools import setup -with open('README.md') as fo: +with open("README.md") as fo: long_description = fo.read() setup( - name = 'pg_activity', - version = '1.6.2', - author = 'Julien Tachoires', - author_email = 'julmon@gmail.com', - scripts = ['pg_activity'], - packages = ['pgactivity'], - url = 'https://github.com/julmon/pg_activity', - license = 'LICENSE.txt', - description = 'Command line tool for PostgreSQL server activity monitoring.', - long_description = long_description, - long_description_content_type='text/markdown', + name="pg_activity", + version="1.6.2", + author="Julien Tachoires", + author_email="julmon@gmail.com", + scripts=["pg_activity"], + packages=["pgactivity"], + url="https://github.com/julmon/pg_activity", + license="LICENSE.txt", + description="Command line tool for PostgreSQL server activity monitoring.", + long_description=long_description, + long_description_content_type="text/markdown", classifiers=[ "Programming Language :: Python :: 3", ], python_requires=">=3.6", - install_requires = [ + install_requires=[ "attrs", "blessed", "humanize", "psutil >= 2.0.0", ], - data_files = data_files, + data_files=data_files, ) From 6d7f0234f06f3d01c0c37afedde95c004ccfca24 Mon Sep 17 00:00:00 2001 From: Denis Laxalde Date: Fri, 30 Oct 2020 10:04:49 +0100 Subject: [PATCH 04/10] Declare tests dependencies in a setuptools extra --- setup.py | 8 ++++++++ tox.ini | 7 ++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index f51ddc05..0344bac6 100644 --- a/setup.py +++ b/setup.py @@ -33,5 +33,13 @@ "humanize", "psutil >= 2.0.0", ], + extras_require={ + "testing": [ + "psycopg2-binary", + "pytest", + "pytest-datadir", + "pytest-postgresql", + ], + }, data_files=data_files, ) diff --git a/tox.ini b/tox.ini index 9174301c..4ce6ec71 100644 --- a/tox.ini +++ b/tox.ini @@ -7,11 +7,8 @@ python = 3.7: check-manifest, lint, mypy, py37 [testenv] -deps = - psycopg2-binary - pytest - pytest-datadir - pytest-postgresql +extras = + testing commands = pytest {toxinidir}/pgactivity {toxinidir}/tests {posargs:-vv} From 5a7c0a8f68232fcf78ec76ba2551b31940981732 Mon Sep 17 00:00:00 2001 From: Denis Laxalde Date: Fri, 30 Oct 2020 10:14:26 +0100 Subject: [PATCH 05/10] Change author information and project URL to Dalibo --- setup.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 0344bac6..1e048c74 100644 --- a/setup.py +++ b/setup.py @@ -14,11 +14,11 @@ setup( name="pg_activity", version="1.6.2", - author="Julien Tachoires", - author_email="julmon@gmail.com", + author="Dalibo", + author_email="contact@dalibo.com", scripts=["pg_activity"], packages=["pgactivity"], - url="https://github.com/julmon/pg_activity", + url="https://github.com/dalibo/pg_activity", license="LICENSE.txt", description="Command line tool for PostgreSQL server activity monitoring.", long_description=long_description, From 4cd1cbf55757bf9bdaf0a8cf9d4aca5f576787cc Mon Sep 17 00:00:00 2001 From: Denis Laxalde Date: Fri, 30 Oct 2020 10:19:04 +0100 Subject: [PATCH 06/10] Wrap long lines in LICENSE.txt and configure editor accordingly --- .editorconfig | 3 +++ LICENSE.txt | 16 +++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.editorconfig b/.editorconfig index 6068df5a..c0fb1a76 100644 --- a/.editorconfig +++ b/.editorconfig @@ -3,5 +3,8 @@ root = true [*.md] max_line_length = 80 +[LICENSE.txt] +max_line_length = 78 + [*.py] max_line_length = 89 diff --git a/LICENSE.txt b/LICENSE.txt index ea391b5f..5bf1ccd3 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,8 +1,18 @@ Copyright (c) 2012 - 2019, Julien Tachoires Copyright (c) 2020, Dalibo -Permission to use, copy, modify, and distribute this software and its documentation for any purpose, without fee, and without a written agreement is hereby granted, provided that the above copyright notice and this paragraph and the following two paragraphs appear in all copies. +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose, without fee, and without a written agreement is +hereby granted, provided that the above copyright notice and this paragraph +and the following two paragraphs appear in all copies. -IN NO EVENT SHALL DALIBO BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF DALIBO HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +IN NO EVENT SHALL DALIBO BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, +INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF +THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF DALIBO HAS BEEN +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -DALIBO SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND DALIBO HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. +DALIBO SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND DALIBO +HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR +MODIFICATIONS. From a5aa3223f71b6ccb7988fff37b3c1fe62a667a72 Mon Sep 17 00:00:00 2001 From: Denis Laxalde Date: Fri, 30 Oct 2020 10:25:24 +0100 Subject: [PATCH 07/10] Declare the license correctly in setup.py We add the correct classifier and set the license field to "PostgreSQL" instead of the license file name. --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 1e048c74..3b8be9e4 100644 --- a/setup.py +++ b/setup.py @@ -19,11 +19,12 @@ scripts=["pg_activity"], packages=["pgactivity"], url="https://github.com/dalibo/pg_activity", - license="LICENSE.txt", + license="PostgreSQL", description="Command line tool for PostgreSQL server activity monitoring.", long_description=long_description, long_description_content_type="text/markdown", classifiers=[ + "License :: OSI Approved :: PostgreSQL License", "Programming Language :: Python :: 3", ], python_requires=">=3.6", From c36111f70e054fa617705ab178349fe376529930 Mon Sep 17 00:00:00 2001 From: Denis Laxalde Date: Fri, 30 Oct 2020 10:35:23 +0100 Subject: [PATCH 08/10] Add more classifiers --- setup.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/setup.py b/setup.py index 3b8be9e4..c66a4434 100644 --- a/setup.py +++ b/setup.py @@ -24,8 +24,12 @@ long_description=long_description, long_description_content_type="text/markdown", classifiers=[ + "Development Status :: 5 - Production/Stable", + "Environment :: Console", + "Environment :: Console :: Curses", "License :: OSI Approved :: PostgreSQL License", "Programming Language :: Python :: 3", + "Topic :: Database", ], python_requires=">=3.6", install_requires=[ From 233afff149b759c4432ffad98b9a44c757673d71 Mon Sep 17 00:00:00 2001 From: Denis Laxalde Date: Fri, 30 Oct 2020 10:37:26 +0100 Subject: [PATCH 09/10] Add keywords in setup.py We simply re-use those declared in github. --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index c66a4434..0dafdd89 100644 --- a/setup.py +++ b/setup.py @@ -31,6 +31,7 @@ "Programming Language :: Python :: 3", "Topic :: Database", ], + keywords="postgresql activity monitoring cli sql top", python_requires=">=3.6", install_requires=[ "attrs", From d56c0db06774ca4b6a4aa96cee0cdc494e20bec6 Mon Sep 17 00:00:00 2001 From: Denis Laxalde Date: Mon, 9 Nov 2020 09:29:36 +0100 Subject: [PATCH 10/10] Let git ignore build/ directory --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 4a0de8fe..cbd12fd5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +build/ htmlcov/ pg_activity.egg-info pgactivity/__pycache__/