Hello community, here is the log from the commit of package salt-shaptools for openSUSE:Factory checked in at 2020-06-11 14:51:56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/salt-shaptools (Old) and /work/SRC/openSUSE:Factory/.salt-shaptools.new.3606 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "salt-shaptools" Thu Jun 11 14:51:56 2020 rev:17 rq:813402 version:0.3.9+git.1591860067.782f9ce Changes: -------- --- /work/SRC/openSUSE:Factory/salt-shaptools/salt-shaptools.changes 2020-06-09 00:08:00.942004070 +0200 +++ /work/SRC/openSUSE:Factory/.salt-shaptools.new.3606/salt-shaptools.changes 2020-06-11 14:52:32.674884170 +0200 @@ -1,0 +2,6 @@ +Tue Jun 9 13:08:47 UTC 2020 - Xabier Arbulu <xarb...@suse.com> + +- Version 0.3.9 + * hana: Fix imp reload usage in py2 + +------------------------------------------------------------------- Old: ---- salt-shaptools-0.3.8+git.1591605110.7cde32d.tar.gz New: ---- salt-shaptools-0.3.9+git.1591860067.782f9ce.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ salt-shaptools.spec ++++++ --- /var/tmp/diff_new_pack.RTh8cQ/_old 2020-06-11 14:52:33.510886710 +0200 +++ /var/tmp/diff_new_pack.RTh8cQ/_new 2020-06-11 14:52:33.514886723 +0200 @@ -19,7 +19,7 @@ # See also https://en.opensuse.org/openSUSE:Specfile_guidelines Name: salt-shaptools -Version: 0.3.8+git.1591605110.7cde32d +Version: 0.3.9+git.1591860067.782f9ce Release: 0 Summary: Salt modules and states for SAP Applications and SLE-HA components management ++++++ _service ++++++ --- /var/tmp/diff_new_pack.RTh8cQ/_old 2020-06-11 14:52:33.538886796 +0200 +++ /var/tmp/diff_new_pack.RTh8cQ/_new 2020-06-11 14:52:33.538886796 +0200 @@ -4,8 +4,8 @@ <param name="scm">git</param> <param name="exclude">.git</param> <param name="filename">salt-shaptools</param> - <param name="versionformat">0.3.8+git.%ct.%h</param> - <param name="revision">7cde32d3f868d62dd1f65c9cde41f6929e8362c4</param> + <param name="versionformat">0.3.9+git.%ct.%h</param> + <param name="revision">782f9ce5394989bd01af7e2f1cd65cc90e47fef1</param> </service> <service name="recompress" mode="disabled"> ++++++ salt-shaptools-0.3.8+git.1591605110.7cde32d.tar.gz -> salt-shaptools-0.3.9+git.1591860067.782f9ce.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/salt-shaptools-0.3.8+git.1591605110.7cde32d/_service new/salt-shaptools-0.3.9+git.1591860067.782f9ce/_service --- old/salt-shaptools-0.3.8+git.1591605110.7cde32d/_service 2020-06-08 10:31:50.000000000 +0200 +++ new/salt-shaptools-0.3.9+git.1591860067.782f9ce/_service 2020-06-11 09:21:07.000000000 +0200 @@ -4,7 +4,7 @@ <param name="scm">git</param> <param name="exclude">.git</param> <param name="filename">salt-shaptools</param> - <param name="versionformat">0.3.8+git.%ct.%h</param> + <param name="versionformat">0.3.9+git.%ct.%h</param> <param name="revision">%%VERSION%%</param> </service> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/salt-shaptools-0.3.8+git.1591605110.7cde32d/salt/modules/hanamod.py new/salt-shaptools-0.3.9+git.1591860067.782f9ce/salt/modules/hanamod.py --- old/salt-shaptools-0.3.8+git.1591605110.7cde32d/salt/modules/hanamod.py 2020-06-08 10:31:50.000000000 +0200 +++ new/salt-shaptools-0.3.9+git.1591860067.782f9ce/salt/modules/hanamod.py 2020-06-11 09:21:07.000000000 +0200 @@ -26,16 +26,15 @@ import logging import time import re +import sys -try: # pragma: no cover - import importlib as imp -except ImportError: # pragma: no cover +if sys.version_info.major == 2: # pragma: no cover import imp +from salt.ext.six.moves import reload_module from salt import exceptions from salt.utils import files as salt_files - # Import third party libs try: from shaptools import hana @@ -924,12 +923,40 @@ )) -def reload_hdb_connector(): +def reload_hdb_connector(): # pragma: no cover ''' As hdb_connector uses pyhdb or dbapi, if these packages are installed on the fly, we need to reload the connector to import the correct api ''' - imp.reload(hdb_connector) + + def __import_mod(name): + ''' + Find more info in: https://docs.python.org/2/library/imp.html + ''' + try: + return sys.modules[name] + except KeyError: + pass + + file_ptr, pathname, description = imp.find_module(name) + + try: + return imp.load_module(name, file_ptr, pathname, description) + finally: + # Since we may exit via an exception, close file_ptr explicitly. + if file_ptr: + file_ptr.close() + + if sys.version_info.major == 2: + # pyhdbcli has a cyclical import so it raises an error, but the module is loaded properly + try: + __import_mod('pyhdbcli') + except ImportError: + pass + __import_mod('hdbcli/dbapi') + __import_mod('hdbcli') + + reload_module(hdb_connector) def _find_sap_folder(software_folders, folder_pattern): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/salt-shaptools-0.3.8+git.1591605110.7cde32d/salt-shaptools.changes new/salt-shaptools-0.3.9+git.1591860067.782f9ce/salt-shaptools.changes --- old/salt-shaptools-0.3.8+git.1591605110.7cde32d/salt-shaptools.changes 2020-06-08 10:31:50.000000000 +0200 +++ new/salt-shaptools-0.3.9+git.1591860067.782f9ce/salt-shaptools.changes 2020-06-11 09:21:07.000000000 +0200 @@ -1,4 +1,10 @@ ------------------------------------------------------------------- +Tue Jun 9 13:08:47 UTC 2020 - Xabier Arbulu <xarb...@suse.com> + +- Version 0.3.9 + * hana: Fix imp reload usage in py2 + +------------------------------------------------------------------- Fri Jun 5 07:46:01 UTC 2020 - nick wang <nw...@suse.com> - Version 0.3.8 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/salt-shaptools-0.3.8+git.1591605110.7cde32d/tests/unit/modules/test_hanamod.py new/salt-shaptools-0.3.9+git.1591860067.782f9ce/tests/unit/modules/test_hanamod.py --- old/salt-shaptools-0.3.8+git.1591605110.7cde32d/tests/unit/modules/test_hanamod.py 2020-06-08 10:31:50.000000000 +0200 +++ new/salt-shaptools-0.3.9+git.1591860067.782f9ce/tests/unit/modules/test_hanamod.py 2020-06-11 09:21:07.000000000 +0200 @@ -7,6 +7,7 @@ # Import Python Libs from __future__ import absolute_import, print_function, unicode_literals import pytest +import sys from salt import exceptions @@ -816,11 +817,47 @@ assert 'HANA database not available after 2 seconds in 192.168.10.15:30015' in str(err.value) @mock.patch('salt.modules.hanamod.hdb_connector') - @mock.patch('importlib.reload') - def test_reload_hdb_connector(self, mock_reload, mock_hdb_connector): + @mock.patch('salt.modules.hanamod.reload_module') + def test_reload_hdb_connector_py3(self, mock_reload, mock_hdb_connector): + if sys.version_info.major == 2: + self.skipTest('python3 only') hanamod.reload_hdb_connector() mock_reload.assert_called_once_with(mock_hdb_connector) + @mock.patch('salt.modules.hanamod.hdb_connector') + @mock.patch('salt.modules.hanamod.reload_module') + @mock.patch('imp.find_module') + @mock.patch('imp.load_module') + def test_reload_hdb_connector_py2( + self, mock_load, mock_find, mock_reload, mock_hdb_connector): + if sys.version_info.major == 3: + self.skipTest('python2 only') + + pyhdbcli_ptr = mock.Mock() + dbapi_ptr = mock.Mock() + hdbcli_ptr = mock.Mock() + + mock_find.side_effect = [ + (pyhdbcli_ptr, 2, 3), (dbapi_ptr, 6, 7), (hdbcli_ptr, 10, 11)] + + hanamod.reload_hdb_connector() + + mock_reload.assert_called_once_with(mock_hdb_connector) + mock_find.assert_has_calls([ + mock.call('pyhdbcli'), + mock.call('hdbcli/dbapi'), + mock.call('hdbcli') + ]) + mock_load.assert_has_calls([ + mock.call('pyhdbcli', pyhdbcli_ptr, 2, 3), + mock.call('hdbcli/dbapi', dbapi_ptr, 6, 7), + mock.call('hdbcli', hdbcli_ptr, 10, 11) + ]) + + pyhdbcli_ptr.close.assert_called_once_with() + dbapi_ptr.close.assert_called_once_with() + hdbcli_ptr.close.assert_called_once_with() + @mock.patch('logging.Logger.debug') @mock.patch('salt.utils.files.fopen') def test_find_sap_folder_error(self, mock_fopen, mock_debug):