From d7b04cf44162ee727d44056fba37e271401cffcc Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Sat, 19 Oct 2024 23:34:41 +0900 Subject: [PATCH] Run pyupgrade to clean up Python 2 syntaxes Update all .py source files by $ pyupgrade --py3-only $(git ls-files | grep ".py$") to modernize the code according to Python 3 syntaxes. Change-Id: Ic6336f745f65161bb05defca797480bc03f7fea7 --- os_refresh_config/os_refresh_config.py | 6 +++--- os_refresh_config/tests/functional/test_cmd.py | 2 +- os_refresh_config/tests/unit/test_main.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/os_refresh_config/os_refresh_config.py b/os_refresh_config/os_refresh_config.py index 9aabea5..a507cd6 100644 --- a/os_refresh_config/os_refresh_config.py +++ b/os_refresh_config/os_refresh_config.py @@ -114,8 +114,8 @@ def main(argv=sys.argv): lock = open(options.lockfile, 'a') try: fcntl.flock(lock, fcntl.LOCK_EX | fcntl.LOCK_NB) - except IOError as e: - log.error('Could not lock %s. %s' % (options.lockfile, e)) + except OSError as e: + log.error('Could not lock {}. {}'.format(options.lockfile, e)) return e.errno lock.truncate(0) @@ -144,7 +144,7 @@ def main(argv=sys.argv): sys.stderr.flush() log.info('Completed phase %s' % phase) except subprocess.CalledProcessError as e: - log.error("during %s phase. [%s]\n" % (phase, e)) + log.error("during {} phase. [{}]\n".format(phase, e)) error_dir = os.path.join(BASE_DIR, 'error.d') if os.path.exists(error_dir): log.info('Calling error handlers.') diff --git a/os_refresh_config/tests/functional/test_cmd.py b/os_refresh_config/tests/functional/test_cmd.py index a409130..599a4f0 100644 --- a/os_refresh_config/tests/functional/test_cmd.py +++ b/os_refresh_config/tests/functional/test_cmd.py @@ -21,7 +21,7 @@ import testtools class TestCmd(testtools.TestCase): def setUp(self): - super(TestCmd, self).setUp() + super().setUp() self.useFixture(fixtures.NestedTempfile()) self.base_dir = self.useFixture(fixtures.TempDir()) self.lockdir = self.useFixture(fixtures.TempDir()) diff --git a/os_refresh_config/tests/unit/test_main.py b/os_refresh_config/tests/unit/test_main.py index a4a4b09..a8a26fc 100644 --- a/os_refresh_config/tests/unit/test_main.py +++ b/os_refresh_config/tests/unit/test_main.py @@ -22,7 +22,7 @@ from os_refresh_config import os_refresh_config class TestMain(testtools.TestCase): def setUp(self): - super(TestMain, self).setUp() + super().setUp() self.useFixture(fixtures.NestedTempfile()) td = self.useFixture(fixtures.TempDir()) self.useFixture(