From 1983abc642b593b33cd5b1ff2b3bf996d69d954e Mon Sep 17 00:00:00 2001 From: Chenxiong Qi Date: Sep 30 2016 02:28:11 +0000 Subject: Avoid formatting string in logging method call Signed-off-by: Chenxiong Qi --- diff --git a/pyrpkg/cli.py b/pyrpkg/cli.py index a48d7c9..0552808 100755 --- a/pyrpkg/cli.py +++ b/pyrpkg/cli.py @@ -971,7 +971,7 @@ see API KEY section of copr-cli(1) man page. sets = False urls = [] build_set = [] - self.log.debug('Processing chain %s' % ' '.join(self.args.package)) + self.log.debug('Processing chain %s', ' '.join(self.args.package)) for component in self.args.package: if component == ':': # We've hit the end of a set, add the set as a unit to the @@ -1177,7 +1177,7 @@ see API KEY section of copr-cli(1) man page. try: self.cmd.sources() except Exception as e: - self.log.error('Could not download sources: %s' % e) + self.log.error('Could not download sources: %s', e) sys.exit(1) mockargs = [] @@ -1198,14 +1198,14 @@ see API KEY section of copr-cli(1) man page. self.cmd.mockbuild(mockargs, self.args.root, hashtype=self.args.hash) except Exception as e: - self.log.error('Could not run mockbuild: %s' % e) + self.log.error('Could not run mockbuild: %s', e) sys.exit(1) def mock_config(self): try: print(self.cmd.mock_config(self.args.target, self.args.arch)) except Exception as e: - self.log.error('Could not generate the mock config: %s' % e) + self.log.error('Could not generate the mock config: %s', e) sys.exit(1) def new(self): @@ -1311,8 +1311,8 @@ see API KEY section of copr-cli(1) man page. open += 1 elif status == koji.TASK_STATES['FREE']: free += 1 - self.log.info(" %d free %d open %d done %d failed" % - (free, open, done, failed)) + self.log.info(" %d free %d open %d done %d failed", + free, open, done, failed) def _display_task_results(self, tasks): for task in [task for task in tasks.values() if task.level == 0]: @@ -1320,14 +1320,14 @@ see API KEY section of copr-cli(1) man page. task_label = task.str() if state == koji.TASK_STATES['CLOSED']: - self.log.info('%s completed successfully' % task_label) + self.log.info('%s completed successfully', task_label) elif state == koji.TASK_STATES['FAILED']: - self.log.info('%s failed' % task_label) + self.log.info('%s failed', task_label) elif state == koji.TASK_STATES['CANCELED']: - self.log.info('%s was canceled' % task_label) + self.log.info('%s was canceled', task_label) else: # shouldn't happen - self.log.info('%s has not completed' % task_label) + self.log.info('%s has not completed', task_label) def _watch_koji_tasks(self, session, tasklist): if not tasklist: diff --git a/pyrpkg/lookaside.py b/pyrpkg/lookaside.py index e257208..b89d154 100644 --- a/pyrpkg/lookaside.py +++ b/pyrpkg/lookaside.py @@ -149,7 +149,7 @@ class CGILookasideCache(object): path_dict.update(kwargs) path = self.download_path % path_dict url = '%s/%s' % (self.download_url, path) - self.log.debug("Full url: %s" % url) + self.log.debug("Full url: %s", url) with open(outfile, 'wb') as f: c = pycurl.Curl() @@ -214,7 +214,7 @@ class CGILookasideCache(object): if os.path.exists(self.ca_cert): c.setopt(pycurl.CAINFO, self.ca_cert) else: - self.log.warning("Missing certificate: %s" % self.ca_cert) + self.log.warning("Missing certificate: %s", self.ca_cert) try: c.perform() @@ -255,10 +255,10 @@ class CGILookasideCache(object): filename = os.path.basename(filepath) if self.remote_file_exists(name, filename, hash): - self.log.info("File already uploaded: %s" % filepath) + self.log.info("File already uploaded: %s", filepath) return - self.log.info("Uploading: %s" % filepath) + self.log.info("Uploading: %s", filepath) post_data = [('name', name), ('%ssum' % self.hashtype, hash), ('file', (pycurl.FORM_FILE, filepath))] @@ -275,14 +275,13 @@ class CGILookasideCache(object): if os.path.exists(self.client_cert): c.setopt(pycurl.SSLCERT, self.client_cert) else: - self.log.warning("Missing certificate: %s" - % self.client_cert) + self.log.warning("Missing certificate: %s", self.client_cert) if self.ca_cert is not None: if os.path.exists(self.ca_cert): c.setopt(pycurl.CAINFO, self.ca_cert) else: - self.log.warning("Missing certificate: %s" % self.ca_cert) + self.log.warning("Missing certificate: %s", self.ca_cert) try: c.perform() diff --git a/tests/test_lookaside.py b/tests/test_lookaside.py index 7509e61..c7a251e 100644 --- a/tests/test_lookaside.py +++ b/tests/test_lookaside.py @@ -379,7 +379,7 @@ class CGILookasideCacheTestCase(unittest.TestCase): def mock_setopt(opt, value): curlopts[opt] = value - def mock_warn(msg): + def mock_warn(msg, *args, **kwargs): warn_messages.append(msg) curlopts = {} @@ -530,7 +530,7 @@ class CGILookasideCacheTestCase(unittest.TestCase): def mock_setopt(opt, value): curlopts[opt] = value - def mock_warn(msg): + def mock_warn(msg, *args, **kwargs): warn_messages.append(msg) curlopts = {}