Skip to content

Commit

Permalink
fix: Replace all warn() with warning()
Browse files Browse the repository at this point in the history
* The warn() has been deprecated for very long time and it
  just become not available in the newest version of Python 3.13
  https://docs.python.org/3.13/whatsnew/3.13.html#logging
* Fixed one unit test
  • Loading branch information
jirihnidek committed Jul 1, 2024
1 parent 036ac99 commit 7eb1111
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -979,8 +979,8 @@ def testLineContinuationInConfig(self):

self.assertEqual(config["server"], 'http://1.2.3.4\nvalue')

@patch('logging.Logger.warn')
def testCommentedOutLineContinuationInConfig(self, logger_warn):
@patch('logging.Logger.warning')
def testCommentedOutLineContinuationInConfig(self, logger_warning):
"""Test that when a config line that starts with space or tab which is followed by a '#',
if we are running python2: it is treated as a continuation of the previous line,
but a warning is logged for the user.
Expand All @@ -1003,8 +1003,8 @@ def testCommentedOutLineContinuationInConfig(self, logger_warn):
config = manager.configs[0][1]
self.assertEqual(config.name, "test1")
self.assertEqual(config["server"], "http://1.2.3.4")
self.assertFalse(logger_warn.called)
self.assertEqual(logger_warn.call_count, 0)
self.assertFalse(logger_warning.called)
self.assertEqual(logger_warning.call_count, 0)


class TestParseList(TestBase):
Expand Down
16 changes: 8 additions & 8 deletions virtwho/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ def parse_file(filename):
except InvalidOption as e:
# When a configuration section has an Invalid Option, continue
# See https://bugzilla.redhat.com/show_bug.cgi?id=1457101 for more info
logger.warn("Invalid configuration detected: %s", str(e))
logger.warning("Invalid configuration detected: %s", str(e))
except DuplicateOptionError as e:
logger.warning(str(e))
except Exception as e:
Expand Down Expand Up @@ -1342,15 +1342,15 @@ def all_drop_dir_config_sections(config_dir=VW_CONF_DIR):
conf_files = set(s for s in all_dir_content if s.endswith('.conf'))
non_conf_files = all_dir_content - conf_files
except OSError:
logger.warn("Configuration directory '%s' doesn't exist or is not accessible",
config_dir)
logger.warning("Configuration directory '%s' doesn't exist or is not accessible",
config_dir)
return {}

if not all_dir_content:
logger.warn("Configuration directory '%s' appears empty", config_dir)
logger.warning("Configuration directory '%s' appears empty", config_dir)
elif not conf_files:
logger.warn("Configuration directory '%s' does not have any '*.conf' files but "
"is not empty", config_dir)
logger.warning("Configuration directory '%s' does not have any '*.conf' files but "
"is not empty", config_dir)
elif non_conf_files:
logger.debug("There are files in '%s' not ending in '*.conf' is this "
"intentional?", config_dir)
Expand All @@ -1372,8 +1372,8 @@ def has_config_files_in_drop_dir(config_dir=VW_CONF_DIR):
all_dir_content = set(os.listdir(config_dir))
conf_files = set(s for s in all_dir_content if s.endswith('.conf'))
except OSError:
logger.warn("Configuration directory '%s' doesn't exist or is not accessible",
config_dir)
logger.warning("Configuration directory '%s' doesn't exist or is not accessible",
config_dir)
return False

if not conf_files:
Expand Down
2 changes: 1 addition & 1 deletion virtwho/manager/satellite/satellite.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def hypervisorCheckIn(self, report, options=None):
self.server_xmlrpc.registration.virt_notify(hypervisor_systemid["system_id"], plan)
except xmlrpc.client.Fault as e:
if e.faultCode == -9:
self.logger.warn("System was deleted from Satellite 5, reregistering")
self.logger.warning("System was deleted from Satellite 5, re-registering")
hypervisor_systemid = self._load_hypervisor(hypervisor.hypervisorId,
hypervisor_type=report.config['type'], force=True)
self.server_xmlrpc.registration.virt_notify(hypervisor_systemid["system_id"], plan)
Expand Down

0 comments on commit 7eb1111

Please sign in to comment.