From 49582ccb7c4ec98aa9736c02d300096952d065fe Mon Sep 17 00:00:00 2001 From: Xavier Francisco Date: Mon, 8 Apr 2019 19:46:29 +0100 Subject: [PATCH 1/6] Fix usage of pgservice --- pgcli/main.py | 9 +++++---- pgcli/pgexecute.py | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pgcli/main.py b/pgcli/main.py index d7853e47..adf42283 100644 --- a/pgcli/main.py +++ b/pgcli/main.py @@ -398,11 +398,12 @@ class PGCli(object): dsn='', **kwargs): # Connect to the database. - if not user: - user = getuser() + if not dsn: + if not user: + user = getuser() - if not database: - database = user + if not database: + database = user # If password prompt is not forced but no password is provided, try # getting it from environment variable. diff --git a/pgcli/pgexecute.py b/pgcli/pgexecute.py index 8c3bfa82..6d94ccc6 100644 --- a/pgcli/pgexecute.py +++ b/pgcli/pgexecute.py @@ -233,7 +233,7 @@ class PGExecute(object): } new_params.update(kwargs) conn_params.update({ - k: unicode2utf8(v) for k, v in new_params.items() if v is not None + k: unicode2utf8(v) for k, v in new_params.items() if v }) if 'password' in conn_params and 'dsn' in conn_params: From e0eac14c96b1759cd82c569bd0304cfa5707a847 Mon Sep 17 00:00:00 2001 From: Xavier Francisco Date: Tue, 9 Apr 2019 21:46:20 +0100 Subject: [PATCH 2/6] Revert main changes; Filter unwanted params when dsn present --- pgcli/main.py | 9 ++++----- pgcli/pgexecute.py | 17 ++++++++++++----- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/pgcli/main.py b/pgcli/main.py index adf42283..d7853e47 100644 --- a/pgcli/main.py +++ b/pgcli/main.py @@ -398,12 +398,11 @@ class PGCli(object): dsn='', **kwargs): # Connect to the database. - if not dsn: - if not user: - user = getuser() + if not user: + user = getuser() - if not database: - database = user + if not database: + database = user # If password prompt is not forced but no password is provided, try # getting it from environment variable. diff --git a/pgcli/pgexecute.py b/pgcli/pgexecute.py index 6d94ccc6..78e4fae8 100644 --- a/pgcli/pgexecute.py +++ b/pgcli/pgexecute.py @@ -232,15 +232,22 @@ class PGExecute(object): 'dsn': dsn, } new_params.update(kwargs) + + if 'dsn' in new_params: + new_params = { + 'dsn': new_params['dsn'], + 'password': new_params['password'] + } + + if 'password' in new_params: + new_params['dsn'] = "{0} password={1}".format( + new_params['dsn'], new_params.pop('password') + ) + conn_params.update({ k: unicode2utf8(v) for k, v in new_params.items() if v }) - if 'password' in conn_params and 'dsn' in conn_params: - conn_params['dsn'] = "{0} password={1}".format( - conn_params['dsn'], conn_params.pop('password') - ) - conn = psycopg2.connect(**conn_params) cursor = conn.cursor() conn.set_client_encoding('utf8') From 3366be52fb0491a00c1bd0b4f72b82944fd0d5ec Mon Sep 17 00:00:00 2001 From: Irina Truong Date: Mon, 18 Mar 2019 04:11:21 +0000 Subject: [PATCH 3/6] Build pgcli with 3.7. --- .travis.yml | 8 +++++++- setup.py | 1 + tox.ini | 11 +++++------ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 04e570f2..2bb738e5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,15 @@ +dist: xenial + +sudo: required + language: python + python: - "2.7" - "3.4" - "3.5" - "3.6" + - "3.7" before_install: - which python @@ -43,4 +49,4 @@ services: - postgresql addons: - postgresql: "9.3" + postgresql: "9.6" diff --git a/setup.py b/setup.py index 13c76c02..6c25b7a4 100644 --- a/setup.py +++ b/setup.py @@ -62,6 +62,7 @@ setup( 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', 'Programming Language :: SQL', 'Topic :: Database', 'Topic :: Database :: Front-Ends', diff --git a/tox.ini b/tox.ini index 712db9cb..c8c75517 100644 --- a/tox.ini +++ b/tox.ini @@ -1,11 +1,10 @@ [tox] -envlist = py27, py34, py35, py36 +envlist = py27, py34, py35, py36, py37 [testenv] -deps = pytest - mock - pgspecial - humanize - psycopg2 +deps = pytest>=2.7.0,<=3.0.7 + mock>=1.0.1 + behave>=1.2.4 + pexpect==3.3 commands = py.test behave tests/features passenv = PGHOST From f1fc86428191eabd0b5e7a8710765ed25cb16c6d Mon Sep 17 00:00:00 2001 From: Irina Truong Date: Sat, 4 May 2019 07:33:28 -0400 Subject: [PATCH 4/6] changelog. --- changelog.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/changelog.rst b/changelog.rst index cf86b06e..1546ff8d 100644 --- a/changelog.rst +++ b/changelog.rst @@ -9,6 +9,11 @@ Bug fixes: * Pgcli no longer works with password containing spaces (#1043). (Thanks: `Irina Truong`_) * Load keyring only when keyring is enabled in the config file (#1041). (Thanks: `Zhaolong Zhu`_) +Internal: +--------- + +* Add python 3.7 to travis build matrix. (Thanks: `Irina Truong`_) + 2.1.0 ===== From e5501cb83c47d4e616cc5a432991f6fbf74a36e5 Mon Sep 17 00:00:00 2001 From: Amjith Ramanujam Date: Mon, 6 May 2019 06:34:24 -0700 Subject: [PATCH 5/6] Check if dsn and password values are passed in. --- pgcli/pgexecute.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pgcli/pgexecute.py b/pgcli/pgexecute.py index 78e4fae8..3f78989a 100644 --- a/pgcli/pgexecute.py +++ b/pgcli/pgexecute.py @@ -233,13 +233,13 @@ class PGExecute(object): } new_params.update(kwargs) - if 'dsn' in new_params: + if new_params['dsn'] is not None: new_params = { 'dsn': new_params['dsn'], 'password': new_params['password'] } - if 'password' in new_params: + if new_params['password'] is not None: new_params['dsn'] = "{0} password={1}".format( new_params['dsn'], new_params.pop('password') ) From dc43430a9a7dc72525027f4fda4fd2137d30362e Mon Sep 17 00:00:00 2001 From: Amjith Ramanujam Date: Mon, 6 May 2019 07:29:48 -0700 Subject: [PATCH 6/6] Update changelog. --- changelog.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/changelog.rst b/changelog.rst index 1546ff8d..cb08ae3a 100644 --- a/changelog.rst +++ b/changelog.rst @@ -8,6 +8,7 @@ Bug fixes: * Fix for "no attribute KeyringLocked" (#1040). (Thanks: `Irina Truong`_) * Pgcli no longer works with password containing spaces (#1043). (Thanks: `Irina Truong`_) * Load keyring only when keyring is enabled in the config file (#1041). (Thanks: `Zhaolong Zhu`_) +* Fix the broken support for pgservice . (Thanks: `Xavier Francisco`_) Internal: --------- @@ -969,4 +970,4 @@ Improvements: .. _`Nathan Verzemnieks`: https://github.com/njvrzm .. _`raylu`: https://github.com/raylu .. _`Zhaolong Zhu`: https://github.com/zzl0 - +.. _`Xavier Francisco`: https://github.com/Qu4tro